1
0

Examples.deploy.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. smalltalk.addPackage('Examples', {});
  2. smalltalk.addClass('Counter', smalltalk.Widget, ['count', 'header'], 'Examples');
  3. smalltalk.addMethod(
  4. '_increase',
  5. smalltalk.method({
  6. selector: 'increase',
  7. fn: function (){
  8. var self=this;
  9. self['@count']=((($receiver = self['@count']).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)]));
  10. smalltalk.send(self['@header'], "_contents_", [(function(html){return smalltalk.send(html, "_with_", [smalltalk.send(self['@count'], "_asString", [])]);})]);
  11. return self;}
  12. }),
  13. smalltalk.Counter);
  14. smalltalk.addMethod(
  15. '_decrease',
  16. smalltalk.method({
  17. selector: 'decrease',
  18. fn: function (){
  19. var self=this;
  20. self['@count']=((($receiver = self['@count']).klass === smalltalk.Number) ? $receiver -(1) : smalltalk.send($receiver, "__minus", [(1)]));
  21. smalltalk.send(self['@header'], "_contents_", [(function(html){return smalltalk.send(html, "_with_", [smalltalk.send(self['@count'], "_asString", [])]);})]);
  22. return self;}
  23. }),
  24. smalltalk.Counter);
  25. smalltalk.addMethod(
  26. '_initialize',
  27. smalltalk.method({
  28. selector: 'initialize',
  29. fn: function (){
  30. var self=this;
  31. smalltalk.send(self, "_initialize", [], smalltalk.Widget);
  32. self['@count']=(0);
  33. return self;}
  34. }),
  35. smalltalk.Counter);
  36. smalltalk.addMethod(
  37. '_renderOn_',
  38. smalltalk.method({
  39. selector: 'renderOn:',
  40. fn: function (html){
  41. var self=this;
  42. self['@header']=(function($rec){smalltalk.send($rec, "_with_", [smalltalk.send(self['@count'], "_asString", [])]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(html, "_h1", []));
  43. (function($rec){smalltalk.send($rec, "_with_", [unescape("++")]);return smalltalk.send($rec, "_onClick_", [(function(){return smalltalk.send(self, "_increase", []);})]);})(smalltalk.send(html, "_button", []));
  44. (function($rec){smalltalk.send($rec, "_with_", [unescape("--")]);return smalltalk.send($rec, "_onClick_", [(function(){return smalltalk.send(self, "_decrease", []);})]);})(smalltalk.send(html, "_button", []));
  45. return self;}
  46. }),
  47. smalltalk.Counter);