Trapped-Demo.deploy.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. smalltalk.addPackage('Trapped-Demo', {});
  2. smalltalk.addClass('AppView', smalltalk.Widget, [], 'Trapped-Demo');
  3. smalltalk.addMethod(
  4. "_renderOn_",
  5. smalltalk.method({
  6. selector: "renderOn:",
  7. fn: function (html){
  8. var self=this;
  9. var $1,$2;
  10. smalltalk.send(smalltalk.send(html,"_h2",[]),"_trapShow_",[["title"]]);
  11. smalltalk.send(smalltalk.send(html,"_div",[]),"_trap_toggle_ifNotPresent_",[["items"],(function(){
  12. smalltalk.send(smalltalk.send(html,"_p",[]),"_with_",[(function(){
  13. smalltalk.send(smalltalk.send(html,"_span",[]),"_trapShow_",[[smalltalk.symbolFor("size")]]);
  14. return smalltalk.send(html,"_with_",[" item(s)."]);
  15. })]);
  16. return smalltalk.send(smalltalk.send(html,"_form",[]),"_with_",[(function(){
  17. return smalltalk.send(smalltalk.send(html,"_ul",[]),"_trapIter_tag_do_",[[],smalltalk.symbolFor("li"),(function(each){
  18. $1=smalltalk.send(html,"_input",[]);
  19. smalltalk.send($1,"_type_",["checkbox"]);
  20. $2=smalltalk.send($1,"_at_put_",["checked",true]);
  21. $2;
  22. return smalltalk.send(html,"_with_",[each]);
  23. })]);
  24. })]);
  25. }),(function(){
  26. return smalltalk.send(html,"_with_",["Loading ..."]);
  27. })]);
  28. return self}
  29. }),
  30. smalltalk.AppView);
  31. smalltalk.addClass('TrappedDumbDispatcher', smalltalk.TrappedDispatcher, ['queue'], 'Trapped-Demo');
  32. smalltalk.addMethod(
  33. "_add_",
  34. smalltalk.method({
  35. selector: "add:",
  36. fn: function (aSubscription){
  37. var self=this;
  38. smalltalk.send(self["@queue"],"_add_",[aSubscription]);
  39. return self}
  40. }),
  41. smalltalk.TrappedDumbDispatcher);
  42. smalltalk.addMethod(
  43. "_clean",
  44. smalltalk.method({
  45. selector: "clean",
  46. fn: function (){
  47. var self=this;
  48. self["@queue"]=smalltalk.send(self["@queue"],"_select_",[(function(each){
  49. return smalltalk.send(each,"_isEnabled",[]);
  50. })]);
  51. return self}
  52. }),
  53. smalltalk.TrappedDumbDispatcher);
  54. smalltalk.addMethod(
  55. "_do_",
  56. smalltalk.method({
  57. selector: "do:",
  58. fn: function (aBlock){
  59. var self=this;
  60. smalltalk.send(self["@queue"],"_do_",[aBlock]);
  61. return self}
  62. }),
  63. smalltalk.TrappedDumbDispatcher);
  64. smalltalk.addMethod(
  65. "_initialize",
  66. smalltalk.method({
  67. selector: "initialize",
  68. fn: function (){
  69. var self=this;
  70. self["@queue"]=smalltalk.send((smalltalk.OrderedCollection || OrderedCollection),"_new",[]);
  71. return self}
  72. }),
  73. smalltalk.TrappedDumbDispatcher);
  74. smalltalk.addClass('TrappedPlainModel', smalltalk.TrappedModelWrapper, [], 'Trapped-Demo');
  75. smalltalk.addMethod(
  76. "_initialize",
  77. smalltalk.method({
  78. selector: "initialize",
  79. fn: function (){
  80. var self=this;
  81. smalltalk.send(self,"_initialize",[],smalltalk.TrappedModelWrapper);
  82. smalltalk.send(self,"_dispatcher_",[smalltalk.send((smalltalk.TrappedDumbDispatcher || TrappedDumbDispatcher),"_new",[])]);
  83. return self}
  84. }),
  85. smalltalk.TrappedPlainModel);
  86. smalltalk.addMethod(
  87. "_modify_do_",
  88. smalltalk.method({
  89. selector: "modify:do:",
  90. fn: function (path,aBlock){
  91. var self=this;
  92. var newValue;
  93. var eavModel;
  94. eavModel=smalltalk.send(path,"_asEavModel",[]);
  95. newValue=smalltalk.send(aBlock,"_value_",[smalltalk.send(eavModel,"_on_",[smalltalk.send(self,"_payload",[])])]);
  96. smalltalk.send((function(){
  97. return smalltalk.send(eavModel,"_on_put_",[smalltalk.send(self,"_payload",[]),newValue]);
  98. }),"_ensure_",[(function(){
  99. return smalltalk.send(smalltalk.send(self,"_dispatcher",[]),"_changed_",[path]);
  100. })]);
  101. return self}
  102. }),
  103. smalltalk.TrappedPlainModel);
  104. smalltalk.addMethod(
  105. "_read_do_",
  106. smalltalk.method({
  107. selector: "read:do:",
  108. fn: function (path,aBlock){
  109. var self=this;
  110. var eavModel;
  111. eavModel=smalltalk.send(path,"_asEavModel",[]);
  112. smalltalk.send(aBlock,"_value_",[smalltalk.send(eavModel,"_on_",[smalltalk.send(self,"_payload",[])])]);
  113. return self}
  114. }),
  115. smalltalk.TrappedPlainModel);
  116. smalltalk.addClass('App', smalltalk.TrappedPlainModel, [], 'Trapped-Demo');
  117. smalltalk.addMethod(
  118. "_initialize",
  119. smalltalk.method({
  120. selector: "initialize",
  121. fn: function (){
  122. var self=this;
  123. smalltalk.send(self,"_initialize",[],smalltalk.TrappedPlainModel);
  124. smalltalk.send(self,"_payload_",[smalltalk.HashedCollection._fromPairs_([smalltalk.send("title","__minus_gt",["To-Do List"])])]);
  125. smalltalk.send((function(){
  126. smalltalk.send(smalltalk.send(self,"_payload",[]),"_at_put_",["items",["hello", "world"]]);
  127. return smalltalk.send(self,"_payload_",[smalltalk.send(self,"_payload",[])]);
  128. }),"_valueWithTimeout_",[(2000)]);
  129. return self}
  130. }),
  131. smalltalk.App);