Trapped-Demo.deploy.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. "_do_",
  36. smalltalk.method({
  37. selector: "do:",
  38. fn: function (aBlock){
  39. var self=this;
  40. smalltalk.send(self["@queue"],"_do_",[aBlock]);
  41. return self}
  42. }),
  43. smalltalk.TrappedDumbDispatcher);
  44. smalltalk.addMethod(
  45. "_initialize",
  46. smalltalk.method({
  47. selector: "initialize",
  48. fn: function (){
  49. var self=this;
  50. self["@queue"]=smalltalk.send((smalltalk.OrderedCollection || OrderedCollection),"_new",[]);
  51. return self}
  52. }),
  53. smalltalk.TrappedDumbDispatcher);
  54. smalltalk.addClass('TrappedPlainModel', smalltalk.TrappedModelWrapper, [], 'Trapped-Demo');
  55. smalltalk.addMethod(
  56. "_initialize",
  57. smalltalk.method({
  58. selector: "initialize",
  59. fn: function (){
  60. var self=this;
  61. smalltalk.send(self,"_initialize",[],smalltalk.TrappedModelWrapper);
  62. smalltalk.send(self,"_dispatcher_",[smalltalk.send((smalltalk.TrappedDumbDispatcher || TrappedDumbDispatcher),"_new",[])]);
  63. return self}
  64. }),
  65. smalltalk.TrappedPlainModel);
  66. smalltalk.addMethod(
  67. "_modify_do_",
  68. smalltalk.method({
  69. selector: "modify:do:",
  70. fn: function (path,aBlock){
  71. var self=this;
  72. var newValue;
  73. var eavModel;
  74. eavModel=smalltalk.send(path,"_asEavModel",[]);
  75. newValue=smalltalk.send(aBlock,"_value_",[smalltalk.send(eavModel,"_on_",[smalltalk.send(self,"_payload",[])])]);
  76. smalltalk.send((function(){
  77. return smalltalk.send(eavModel,"_on_put_",[smalltalk.send(self,"_payload",[]),newValue]);
  78. }),"_ensure_",[(function(){
  79. return smalltalk.send(smalltalk.send(self,"_dispatcher",[]),"_changed_",[path]);
  80. })]);
  81. return self}
  82. }),
  83. smalltalk.TrappedPlainModel);
  84. smalltalk.addMethod(
  85. "_read_do_",
  86. smalltalk.method({
  87. selector: "read:do:",
  88. fn: function (path,aBlock){
  89. var self=this;
  90. var eavModel;
  91. eavModel=smalltalk.send(path,"_asEavModel",[]);
  92. smalltalk.send(aBlock,"_value_",[smalltalk.send(eavModel,"_on_",[smalltalk.send(self,"_payload",[])])]);
  93. return self}
  94. }),
  95. smalltalk.TrappedPlainModel);
  96. smalltalk.addClass('App', smalltalk.TrappedPlainModel, [], 'Trapped-Demo');
  97. smalltalk.addMethod(
  98. "_initialize",
  99. smalltalk.method({
  100. selector: "initialize",
  101. fn: function (){
  102. var self=this;
  103. smalltalk.send(self,"_initialize",[],smalltalk.TrappedPlainModel);
  104. smalltalk.send(self,"_payload_",[smalltalk.HashedCollection._fromPairs_([smalltalk.send("title","__minus_gt",["To-Do List"])])]);
  105. smalltalk.send((function(){
  106. smalltalk.send(smalltalk.send(self,"_payload",[]),"_at_put_",["items",["hello", "world"]]);
  107. return smalltalk.send(self,"_payload_",[smalltalk.send(self,"_payload",[])]);
  108. }),"_valueWithTimeout_",[(2000)]);
  109. return self}
  110. }),
  111. smalltalk.App);