Trapped-Counter.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. define("gh_herby_trapped_counter/Trapped-Counter", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "gh_herby_trapped/Trapped-Backend", "amber_core/Kernel-Objects"], function(smalltalk,nil,_st){
  2. smalltalk.addPackage('Trapped-Counter');
  3. smalltalk.packages["Trapped-Counter"].transport = {"type":"amd","amdNamespace":"gh_herby_trapped_counter"};
  4. smalltalk.addClass('App', smalltalk.ListKeyedIsolatedEntity, [], 'Trapped-Counter');
  5. smalltalk.App.comment="// Code from AngularJS Todo example, http://angularjs.org/#todo-js\x0afunction TodoCtrl($scope) {\x0a $scope.todos = [\x0a {text:'learn angular', done:true},\x0a {text:'build an angular app', done:false}];\x0a \x0a $scope.addTodo = function() {\x0a $scope.todos.push({text:$scope.todoText, done:false});\x0a $scope.todoText = '';\x0a };\x0a \x0a $scope.remaining = function() {\x0a var count = 0;\x0a angular.forEach($scope.todos, function(todo) {\x0a count += todo.done ? 0 : 1;\x0a });\x0a return count;\x0a };\x0a \x0a $scope.archive = function() {\x0a var oldTodos = $scope.todos;\x0a $scope.todos = [];\x0a angular.forEach(oldTodos, function(todo) {\x0a if (!todo.done) $scope.todos.push(todo);\x0a });\x0a };\x0a}";
  6. smalltalk.addMethod(
  7. smalltalk.method({
  8. selector: "initialize",
  9. category: 'initialization',
  10. fn: function (){
  11. var self=this;
  12. function $SimpleKeyedPubSub(){return smalltalk.SimpleKeyedPubSub||(typeof SimpleKeyedPubSub=="undefined"?nil:SimpleKeyedPubSub)}
  13. function $AppModel(){return smalltalk.AppModel||(typeof AppModel=="undefined"?nil:AppModel)}
  14. return smalltalk.withContext(function($ctx1) {
  15. var $1;
  16. smalltalk.App.superclass.fn.prototype._initialize.apply(_st(self), []);
  17. $1=_st($SimpleKeyedPubSub())._new();
  18. $ctx1.sendIdx["new"]=1;
  19. self._dispatcher_($1);
  20. self._model_(_st($AppModel())._new());
  21. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.App)})},
  22. args: [],
  23. source: "initialize\x0a\x09super initialize.\x0a self dispatcher: SimpleKeyedPubSub new.\x0a self model: AppModel new",
  24. messageSends: ["initialize", "dispatcher:", "new", "model:"],
  25. referencedClasses: ["SimpleKeyedPubSub", "AppModel"]
  26. }),
  27. smalltalk.App);
  28. smalltalk.addClass('AppModel', smalltalk.Object, ['value'], 'Trapped-Counter');
  29. smalltalk.AppModel.comment="// Code from AngularJS Todo example, http://angularjs.org/#todo-js\x0afunction TodoCtrl($scope) {\x0a $scope.todos = [\x0a {text:'learn angular', done:true},\x0a {text:'build an angular app', done:false}];\x0a \x0a $scope.addTodo = function() {\x0a $scope.todos.push({text:$scope.todoText, done:false});\x0a $scope.todoText = '';\x0a };\x0a \x0a $scope.remaining = function() {\x0a var count = 0;\x0a angular.forEach($scope.todos, function(todo) {\x0a count += todo.done ? 0 : 1;\x0a });\x0a return count;\x0a };\x0a \x0a $scope.archive = function() {\x0a var oldTodos = $scope.todos;\x0a $scope.todos = [];\x0a angular.forEach(oldTodos, function(todo) {\x0a if (!todo.done) $scope.todos.push(todo);\x0a });\x0a };\x0a}";
  30. smalltalk.addMethod(
  31. smalltalk.method({
  32. selector: "decrement",
  33. category: 'action',
  34. fn: function (){
  35. var self=this;
  36. return smalltalk.withContext(function($ctx1) {
  37. self["@value"]=_st(self["@value"]).__minus((1));
  38. return self}, function($ctx1) {$ctx1.fill(self,"decrement",{},smalltalk.AppModel)})},
  39. args: [],
  40. source: "decrement\x0a\x09value := value - 1",
  41. messageSends: ["-"],
  42. referencedClasses: []
  43. }),
  44. smalltalk.AppModel);
  45. smalltalk.addMethod(
  46. smalltalk.method({
  47. selector: "increment",
  48. category: 'action',
  49. fn: function (){
  50. var self=this;
  51. return smalltalk.withContext(function($ctx1) {
  52. self["@value"]=_st(self["@value"]).__plus((1));
  53. return self}, function($ctx1) {$ctx1.fill(self,"increment",{},smalltalk.AppModel)})},
  54. args: [],
  55. source: "increment\x0a\x09value := value + 1",
  56. messageSends: ["+"],
  57. referencedClasses: []
  58. }),
  59. smalltalk.AppModel);
  60. smalltalk.addMethod(
  61. smalltalk.method({
  62. selector: "initialize",
  63. category: 'initialization',
  64. fn: function (){
  65. var self=this;
  66. return smalltalk.withContext(function($ctx1) {
  67. smalltalk.AppModel.superclass.fn.prototype._initialize.apply(_st(self), []);
  68. self["@value"]=(0);
  69. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.AppModel)})},
  70. args: [],
  71. source: "initialize\x0a\x09super initialize.\x0a\x09value := 0",
  72. messageSends: ["initialize"],
  73. referencedClasses: []
  74. }),
  75. smalltalk.AppModel);
  76. smalltalk.addMethod(
  77. smalltalk.method({
  78. selector: "value",
  79. category: 'accessing',
  80. fn: function (){
  81. var self=this;
  82. return smalltalk.withContext(function($ctx1) {
  83. var $1;
  84. $1=self["@value"];
  85. return $1;
  86. }, function($ctx1) {$ctx1.fill(self,"value",{},smalltalk.AppModel)})},
  87. args: [],
  88. source: "value\x0a\x09^value",
  89. messageSends: [],
  90. referencedClasses: []
  91. }),
  92. smalltalk.AppModel);
  93. smalltalk.addMethod(
  94. smalltalk.method({
  95. selector: "value:",
  96. category: 'accessing',
  97. fn: function (aNumber){
  98. var self=this;
  99. return smalltalk.withContext(function($ctx1) {
  100. self["@value"]=aNumber;
  101. return self}, function($ctx1) {$ctx1.fill(self,"value:",{aNumber:aNumber},smalltalk.AppModel)})},
  102. args: ["aNumber"],
  103. source: "value: aNumber\x0a\x09value := aNumber",
  104. messageSends: [],
  105. referencedClasses: []
  106. }),
  107. smalltalk.AppModel);
  108. });