Trapped-Demo.deploy.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. smalltalk.addPackage('Trapped-Demo', {});
  2. smalltalk.addClass('App', smalltalk.TrappedMWIsolated, [], 'Trapped-Demo');
  3. smalltalk.addMethod(
  4. "_initialize",
  5. smalltalk.method({
  6. selector: "initialize",
  7. fn: function (){
  8. var self=this;
  9. var obj;
  10. smalltalk.send(self,"_initialize",[],smalltalk.TrappedMWIsolated);
  11. smalltalk.send(self,"_dispatcher_",[smalltalk.send((smalltalk.TrappedDumbDispatcher || TrappedDumbDispatcher),"_new",[])]);
  12. obj=smalltalk.HashedCollection._fromPairs_([smalltalk.send("title","__minus_gt",["To-Do List"])]);
  13. smalltalk.send(self,"_model_",[obj]);
  14. smalltalk.send((function(){
  15. smalltalk.send(obj,"_at_put_",["items",[[true, "hello"], [false, "world"]]]);
  16. return smalltalk.send(smalltalk.send(self,"_dispatcher",[]),"_changed_",[[]]);
  17. }),"_valueWithTimeout_",[(2000)]);
  18. return self}
  19. }),
  20. smalltalk.App);
  21. smalltalk.addClass('AppView', smalltalk.Widget, [], 'Trapped-Demo');
  22. smalltalk.addMethod(
  23. "_renderOn_",
  24. smalltalk.method({
  25. selector: "renderOn:",
  26. fn: function (html){
  27. var self=this;
  28. var $1,$2,$3,$4;
  29. smalltalk.send(smalltalk.send(html,"_h2",[]),"_trap_",[["title"]]);
  30. smalltalk.send(smalltalk.send(html,"_div",[]),"_trap_toggle_ifNotPresent_",[["items"],(function(){
  31. smalltalk.send(smalltalk.send(html,"_p",[]),"_with_",[(function(){
  32. smalltalk.send(smalltalk.send(html,"_span",[]),"_trap_",[[smalltalk.symbolFor("size")]]);
  33. return smalltalk.send(html,"_with_",[" item(s)."]);
  34. })]);
  35. smalltalk.send(smalltalk.send(html,"_form",[]),"_with_",[(function(){
  36. return smalltalk.send(smalltalk.send(html,"_ul",[]),"_trapIter_tag_do_",[[],smalltalk.symbolFor("li"),(function(each){
  37. smalltalk.send(smalltalk.send(html,"_root",[]),"_empty",[]);
  38. $1=smalltalk.send(html,"_input",[]);
  39. smalltalk.send($1,"_type_",["checkbox"]);
  40. $2=smalltalk.send($1,"_trap_",[[(1)]]);
  41. $2;
  42. return smalltalk.send(smalltalk.send(html,"_span",[]),"_trap_",[[(2)]]);
  43. })]);
  44. })]);
  45. smalltalk.send(smalltalk.send(html,"_p",[]),"_with_",["... and again, to see the bidirectional binding:"]);
  46. return smalltalk.send(smalltalk.send(html,"_form",[]),"_with_",[(function(){
  47. return smalltalk.send(smalltalk.send(html,"_ul",[]),"_trapIter_tag_do_",[[],smalltalk.symbolFor("li"),(function(each){
  48. smalltalk.send(smalltalk.send(html,"_root",[]),"_empty",[]);
  49. $3=smalltalk.send(html,"_input",[]);
  50. smalltalk.send($3,"_type_",["checkbox"]);
  51. $4=smalltalk.send($3,"_trap_",[[(1)]]);
  52. $4;
  53. return smalltalk.send(smalltalk.send(html,"_span",[]),"_trap_",[[(2)]]);
  54. })]);
  55. })]);
  56. }),(function(){
  57. return smalltalk.send(html,"_with_",["Loading ..."]);
  58. })]);
  59. return self}
  60. }),
  61. smalltalk.AppView);
  62. smalltalk.addClass('TrappedDumbDispatcher', smalltalk.TrappedDispatcher, ['queue'], 'Trapped-Demo');
  63. smalltalk.addMethod(
  64. "_add_",
  65. smalltalk.method({
  66. selector: "add:",
  67. fn: function (aSubscription){
  68. var self=this;
  69. smalltalk.send(self["@queue"],"_add_",[aSubscription]);
  70. return self}
  71. }),
  72. smalltalk.TrappedDumbDispatcher);
  73. smalltalk.addMethod(
  74. "_clean",
  75. smalltalk.method({
  76. selector: "clean",
  77. fn: function (){
  78. var self=this;
  79. self["@queue"]=smalltalk.send(self["@queue"],"_select_",[(function(each){
  80. return smalltalk.send(each,"_isEnabled",[]);
  81. })]);
  82. return self}
  83. }),
  84. smalltalk.TrappedDumbDispatcher);
  85. smalltalk.addMethod(
  86. "_do_",
  87. smalltalk.method({
  88. selector: "do:",
  89. fn: function (aBlock){
  90. var self=this;
  91. smalltalk.send(self["@queue"],"_do_",[aBlock]);
  92. return self}
  93. }),
  94. smalltalk.TrappedDumbDispatcher);
  95. smalltalk.addMethod(
  96. "_initialize",
  97. smalltalk.method({
  98. selector: "initialize",
  99. fn: function (){
  100. var self=this;
  101. self["@queue"]=smalltalk.send((smalltalk.OrderedCollection || OrderedCollection),"_new",[]);
  102. return self}
  103. }),
  104. smalltalk.TrappedDumbDispatcher);