Examples.deploy.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. smalltalk.addPackage('Examples', {});
  2. smalltalk.addClass('Counter', smalltalk.Widget, ['count', 'header'], 'Examples');
  3. smalltalk.addMethod(
  4. unescape('_decrease'),
  5. smalltalk.method({
  6. selector: unescape('decrease'),
  7. fn: function (){
  8. var self=this;
  9. (self['@count']=((($receiver = self['@count']).klass === smalltalk.Number) ? $receiver -(1) : smalltalk.send($receiver, "__minus", [(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. unescape('_increase'),
  16. smalltalk.method({
  17. selector: unescape('increase'),
  18. fn: function (){
  19. var self=this;
  20. (self['@count']=((($receiver = self['@count']).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(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. unescape('_initialize'),
  27. smalltalk.method({
  28. selector: unescape('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. unescape('_renderOn_'),
  38. smalltalk.method({
  39. selector: unescape('renderOn%3A'),
  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);
  48. smalltalk.addMethod(
  49. unescape('_tryExample'),
  50. smalltalk.method({
  51. selector: unescape('tryExample'),
  52. fn: function (){
  53. var self=this;
  54. smalltalk.send(smalltalk.send(self, "_new", []), "_appendToJQuery_", [smalltalk.send("body", "_asJQuery", [])]);
  55. return self;}
  56. }),
  57. smalltalk.Counter.klass);