Examples.deploy.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. smalltalk.addPackage('Examples');
  2. smalltalk.addClass('Counter', smalltalk.Widget, ['count', 'header'], 'Examples');
  3. smalltalk.addMethod(
  4. smalltalk.method({
  5. selector: "decrease",
  6. fn: function (){
  7. var self=this;
  8. return smalltalk.withContext(function($ctx1) {
  9. self["@count"]=_st(self["@count"]).__minus((1));
  10. _st(self["@header"])._contents_((function(html){
  11. return smalltalk.withContext(function($ctx2) {
  12. return _st(html)._with_(_st(self["@count"])._asString());
  13. }, function($ctx2) {$ctx2.fillBlock({html:html},$ctx1)})}));
  14. return self}, function($ctx1) {$ctx1.fill(self,"decrease",{},smalltalk.Counter)})},
  15. messageSends: ["-", "contents:", "with:", "asString"]}),
  16. smalltalk.Counter);
  17. smalltalk.addMethod(
  18. smalltalk.method({
  19. selector: "increase",
  20. fn: function (){
  21. var self=this;
  22. return smalltalk.withContext(function($ctx1) {
  23. self["@count"]=_st(self["@count"]).__plus((1));
  24. _st(self["@header"])._contents_((function(html){
  25. return smalltalk.withContext(function($ctx2) {
  26. return _st(html)._with_(_st(self["@count"])._asString());
  27. }, function($ctx2) {$ctx2.fillBlock({html:html},$ctx1)})}));
  28. return self}, function($ctx1) {$ctx1.fill(self,"increase",{},smalltalk.Counter)})},
  29. messageSends: ["+", "contents:", "with:", "asString"]}),
  30. smalltalk.Counter);
  31. smalltalk.addMethod(
  32. smalltalk.method({
  33. selector: "initialize",
  34. fn: function (){
  35. var self=this;
  36. return smalltalk.withContext(function($ctx1) {
  37. smalltalk.Widget.fn.prototype._initialize.apply(_st(self), []);
  38. self["@count"]=(0);
  39. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.Counter)})},
  40. messageSends: ["initialize"]}),
  41. smalltalk.Counter);
  42. smalltalk.addMethod(
  43. smalltalk.method({
  44. selector: "renderOn:",
  45. fn: function (html){
  46. var self=this;
  47. return smalltalk.withContext(function($ctx1) {
  48. var $1,$2,$3,$4,$5,$6;
  49. $1=_st(html)._h1();
  50. _st($1)._with_(_st(self["@count"])._asString());
  51. $2=_st($1)._yourself();
  52. self["@header"]=$2;
  53. $3=_st(html)._button();
  54. _st($3)._with_("++");
  55. $4=_st($3)._onClick_((function(){
  56. return smalltalk.withContext(function($ctx2) {
  57. return _st(self)._increase();
  58. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  59. $5=_st(html)._button();
  60. _st($5)._with_("--");
  61. $6=_st($5)._onClick_((function(){
  62. return smalltalk.withContext(function($ctx2) {
  63. return _st(self)._decrease();
  64. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  65. return self}, function($ctx1) {$ctx1.fill(self,"renderOn:",{html:html},smalltalk.Counter)})},
  66. messageSends: ["with:", "asString", "h1", "yourself", "button", "onClick:", "increase", "decrease"]}),
  67. smalltalk.Counter);
  68. smalltalk.addMethod(
  69. smalltalk.method({
  70. selector: "tryExample",
  71. fn: function (){
  72. var self=this;
  73. return smalltalk.withContext(function($ctx1) {
  74. _st(_st(self)._new())._appendToJQuery_(_st("body")._asJQuery());
  75. return self}, function($ctx1) {$ctx1.fill(self,"tryExample",{},smalltalk.Counter.klass)})},
  76. messageSends: ["appendToJQuery:", "asJQuery", "new"]}),
  77. smalltalk.Counter.klass);