Trapped-Counter.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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.addMethod(
  30. smalltalk.method({
  31. selector: "decrement",
  32. category: 'action',
  33. fn: function (){
  34. var self=this;
  35. return smalltalk.withContext(function($ctx1) {
  36. self["@value"]=_st(self["@value"]).__minus((1));
  37. return self}, function($ctx1) {$ctx1.fill(self,"decrement",{},smalltalk.AppModel)})},
  38. args: [],
  39. source: "decrement\x0a\x09value := value - 1",
  40. messageSends: ["-"],
  41. referencedClasses: []
  42. }),
  43. smalltalk.AppModel);
  44. smalltalk.addMethod(
  45. smalltalk.method({
  46. selector: "increment",
  47. category: 'action',
  48. fn: function (){
  49. var self=this;
  50. return smalltalk.withContext(function($ctx1) {
  51. self["@value"]=_st(self["@value"]).__plus((1));
  52. return self}, function($ctx1) {$ctx1.fill(self,"increment",{},smalltalk.AppModel)})},
  53. args: [],
  54. source: "increment\x0a\x09value := value + 1",
  55. messageSends: ["+"],
  56. referencedClasses: []
  57. }),
  58. smalltalk.AppModel);
  59. smalltalk.addMethod(
  60. smalltalk.method({
  61. selector: "initialize",
  62. category: 'initialization',
  63. fn: function (){
  64. var self=this;
  65. return smalltalk.withContext(function($ctx1) {
  66. smalltalk.AppModel.superclass.fn.prototype._initialize.apply(_st(self), []);
  67. self["@value"]=(0);
  68. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.AppModel)})},
  69. args: [],
  70. source: "initialize\x0a\x09super initialize.\x0a\x09value := 0",
  71. messageSends: ["initialize"],
  72. referencedClasses: []
  73. }),
  74. smalltalk.AppModel);
  75. smalltalk.addMethod(
  76. smalltalk.method({
  77. selector: "value",
  78. category: 'accessing',
  79. fn: function (){
  80. var self=this;
  81. return smalltalk.withContext(function($ctx1) {
  82. var $1;
  83. $1=self["@value"];
  84. return $1;
  85. }, function($ctx1) {$ctx1.fill(self,"value",{},smalltalk.AppModel)})},
  86. args: [],
  87. source: "value\x0a\x09^value",
  88. messageSends: [],
  89. referencedClasses: []
  90. }),
  91. smalltalk.AppModel);
  92. smalltalk.addMethod(
  93. smalltalk.method({
  94. selector: "value:",
  95. category: 'accessing',
  96. fn: function (aNumber){
  97. var self=this;
  98. return smalltalk.withContext(function($ctx1) {
  99. self["@value"]=aNumber;
  100. return self}, function($ctx1) {$ctx1.fill(self,"value:",{aNumber:aNumber},smalltalk.AppModel)})},
  101. args: ["aNumber"],
  102. source: "value: aNumber\x0a\x09value := aNumber",
  103. messageSends: [],
  104. referencedClasses: []
  105. }),
  106. smalltalk.AppModel);
  107. });