Trapped-Demo.deploy.js 3.9 KB

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