Trapped-Demo.deploy.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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",["hello", "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;
  29. smalltalk.send(smalltalk.send(html,"_h2",[]),"_trapShow_",[["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",[]),"_trapShow_",[[smalltalk.symbolFor("size")]]);
  33. return smalltalk.send(html,"_with_",[" item(s)."]);
  34. })]);
  35. return 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. $1=smalltalk.send(html,"_input",[]);
  38. smalltalk.send($1,"_type_",["checkbox"]);
  39. $2=smalltalk.send($1,"_at_put_",["checked",true]);
  40. $2;
  41. return smalltalk.send(html,"_with_",[each]);
  42. })]);
  43. })]);
  44. }),(function(){
  45. return smalltalk.send(html,"_with_",["Loading ..."]);
  46. })]);
  47. return self}
  48. }),
  49. smalltalk.AppView);
  50. smalltalk.addClass('TrappedDumbDispatcher', smalltalk.TrappedDispatcher, ['queue'], 'Trapped-Demo');
  51. smalltalk.addMethod(
  52. "_add_",
  53. smalltalk.method({
  54. selector: "add:",
  55. fn: function (aSubscription){
  56. var self=this;
  57. smalltalk.send(self["@queue"],"_add_",[aSubscription]);
  58. return self}
  59. }),
  60. smalltalk.TrappedDumbDispatcher);
  61. smalltalk.addMethod(
  62. "_clean",
  63. smalltalk.method({
  64. selector: "clean",
  65. fn: function (){
  66. var self=this;
  67. self["@queue"]=smalltalk.send(self["@queue"],"_select_",[(function(each){
  68. return smalltalk.send(each,"_isEnabled",[]);
  69. })]);
  70. return self}
  71. }),
  72. smalltalk.TrappedDumbDispatcher);
  73. smalltalk.addMethod(
  74. "_do_",
  75. smalltalk.method({
  76. selector: "do:",
  77. fn: function (aBlock){
  78. var self=this;
  79. smalltalk.send(self["@queue"],"_do_",[aBlock]);
  80. return self}
  81. }),
  82. smalltalk.TrappedDumbDispatcher);
  83. smalltalk.addMethod(
  84. "_initialize",
  85. smalltalk.method({
  86. selector: "initialize",
  87. fn: function (){
  88. var self=this;
  89. self["@queue"]=smalltalk.send((smalltalk.OrderedCollection || OrderedCollection),"_new",[]);
  90. return self}
  91. }),
  92. smalltalk.TrappedDumbDispatcher);