|
| 1 | +package angularjs |
| 2 | + |
| 3 | +func NewModule(name string, requires []string, configFn func()) *Module { return nil } |
| 4 | + |
| 5 | +const js_NewModule = ` |
| 6 | + requires = requires ? requires.Go$toArray() : []; |
| 7 | + return new Module(angular.module(name, requires, configFn)); |
| 8 | +` |
| 9 | + |
| 10 | +type Module struct { |
| 11 | + native interface{} |
| 12 | + SCE *SCE |
| 13 | +} |
| 14 | + |
| 15 | +func (m *Module) NewController(name string, constructor func(scope *Scope)) {} |
| 16 | + |
| 17 | +const js_Module_NewController = ` |
| 18 | + this.native.controller(name, function($scope, $sce) { |
| 19 | + constructor(new Scope($scope, new SCE($sce))); |
| 20 | + }); |
| 21 | +` |
| 22 | + |
| 23 | +func (m *Module) NewFilter(name string, fn func(text string, arguments []string) string) {} |
| 24 | + |
| 25 | +const js_Module_NewFilter = ` |
| 26 | + this.native.filter(name, function() { |
| 27 | + return function(text) { |
| 28 | + return fn(text, new Go$Slice(Array.prototype.slice.call(arguments, 1))); |
| 29 | + }; |
| 30 | + }); |
| 31 | +` |
| 32 | + |
| 33 | +type Scope struct { |
| 34 | + native interface{} |
| 35 | +} |
| 36 | + |
| 37 | +func (s *Scope) GetString(key string) string { return "" } |
| 38 | + |
| 39 | +const js_Scope_GetString = ` |
| 40 | + return String(this.native[key]); |
| 41 | +` |
| 42 | + |
| 43 | +func (s *Scope) GetInt(key string) int { return 0 } |
| 44 | + |
| 45 | +const js_Scope_GetInt = ` |
| 46 | + return parseInt(this.native[key]); |
| 47 | +` |
| 48 | + |
| 49 | +func (s *Scope) GetFloat(key string) float64 { return 0 } |
| 50 | + |
| 51 | +const js_Scope_GetFloat = ` |
| 52 | + return parseFloat(this.native[key]); |
| 53 | +` |
| 54 | + |
| 55 | +func (s *Scope) GetSlice(key string) []interface{} { return nil } |
| 56 | + |
| 57 | +const js_Scope_GetSlice = ` |
| 58 | + return new Go$Slice(this.native[key]); |
| 59 | +` |
| 60 | + |
| 61 | +func (s *Scope) Set(key string, value interface{}) {} |
| 62 | + |
| 63 | +const js_Scope_Set = ` |
| 64 | + if (value.constructor === Go$Slice) { |
| 65 | + value = value.Go$toArray(); |
| 66 | + } |
| 67 | + this.native[key] = value.v !== undefined ? value.v : value; |
| 68 | +` |
| 69 | + |
| 70 | +type SCE struct { |
| 71 | + native interface{} |
| 72 | +} |
0 commit comments