Trapped-Demo.deploy.js 3.5 KB

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