Trapped-Processors.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816
  1. define("gh_herby_trapped/Trapped-Processors", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "gh_herby_trapped/Trapped-Frontend"], function(smalltalk,nil,_st){
  2. smalltalk.addPackage('Trapped-Processors');
  3. smalltalk.packages["Trapped-Processors"].transport = {"type":"amd","amdNamespace":"gh_herby_trapped"};
  4. smalltalk.addClass('TrappedDataExpectingProcessor', smalltalk.TrappedProcessor, [], 'Trapped-Processors');
  5. smalltalk.TrappedDataExpectingProcessor.comment="I answer true to isExpectingModelData and serve as a base class\x0afor processor that present / change model data.\x0a\x0aWhen at least one of my instances is present in the chain,\x0aautomatic databinding processor is added at the beginning\x0a(the data-binding scenario); otherwise, the chain\x0ais run immediately with true as data (run-once scenario).";
  6. smalltalk.addMethod(
  7. smalltalk.method({
  8. selector: "isExpectingModelData",
  9. category: 'testing',
  10. fn: function (){
  11. var self=this;
  12. return smalltalk.withContext(function($ctx1) {
  13. return true;
  14. }, function($ctx1) {$ctx1.fill(self,"isExpectingModelData",{},smalltalk.TrappedDataExpectingProcessor)})},
  15. args: [],
  16. source: "isExpectingModelData\x0a\x09^true",
  17. messageSends: [],
  18. referencedClasses: []
  19. }),
  20. smalltalk.TrappedDataExpectingProcessor);
  21. smalltalk.addClass('TrappedProcessorContents', smalltalk.TrappedDataExpectingProcessor, [], 'Trapped-Processors');
  22. smalltalk.TrappedProcessorContents.comment="I put data into target via contents: in toView:";
  23. smalltalk.addMethod(
  24. smalltalk.method({
  25. selector: "toView:",
  26. category: 'data transformation',
  27. fn: function (aDataCarrier){
  28. var self=this;
  29. return smalltalk.withContext(function($ctx1) {
  30. _st(aDataCarrier)._toTargetContents();
  31. return self}, function($ctx1) {$ctx1.fill(self,"toView:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessorContents)})},
  32. args: ["aDataCarrier"],
  33. source: "toView: aDataCarrier\x0a\x09aDataCarrier toTargetContents",
  34. messageSends: ["toTargetContents"],
  35. referencedClasses: []
  36. }),
  37. smalltalk.TrappedProcessorContents);
  38. smalltalk.addClass('TrappedProcessorDataAdhoc', smalltalk.TrappedDataExpectingProcessor, ['toViewBlock'], 'Trapped-Processors');
  39. smalltalk.TrappedProcessorDataAdhoc.comment="I put data into target via contents: in toView:";
  40. smalltalk.addMethod(
  41. smalltalk.method({
  42. selector: "toView:",
  43. category: 'data transformation',
  44. fn: function (aDataCarrier){
  45. var self=this;
  46. return smalltalk.withContext(function($ctx1) {
  47. _st(self["@toViewBlock"])._value_(aDataCarrier);
  48. return self}, function($ctx1) {$ctx1.fill(self,"toView:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessorDataAdhoc)})},
  49. args: ["aDataCarrier"],
  50. source: "toView: aDataCarrier\x0a\x09toViewBlock value: aDataCarrier",
  51. messageSends: ["value:"],
  52. referencedClasses: []
  53. }),
  54. smalltalk.TrappedProcessorDataAdhoc);
  55. smalltalk.addMethod(
  56. smalltalk.method({
  57. selector: "toViewBlock:",
  58. category: 'accessing',
  59. fn: function (aBlock){
  60. var self=this;
  61. return smalltalk.withContext(function($ctx1) {
  62. self["@toViewBlock"]=aBlock;
  63. return self}, function($ctx1) {$ctx1.fill(self,"toViewBlock:",{aBlock:aBlock},smalltalk.TrappedProcessorDataAdhoc)})},
  64. args: ["aBlock"],
  65. source: "toViewBlock: aBlock\x0a\x09toViewBlock := aBlock",
  66. messageSends: [],
  67. referencedClasses: []
  68. }),
  69. smalltalk.TrappedProcessorDataAdhoc);
  70. smalltalk.addMethod(
  71. smalltalk.method({
  72. selector: "newToView:",
  73. category: 'instance creation',
  74. fn: function (aBlock){
  75. var self=this;
  76. return smalltalk.withContext(function($ctx1) {
  77. var $2,$3,$1;
  78. $2=self._new();
  79. _st($2)._toViewBlock_(aBlock);
  80. $3=_st($2)._yourself();
  81. $1=$3;
  82. return $1;
  83. }, function($ctx1) {$ctx1.fill(self,"newToView:",{aBlock:aBlock},smalltalk.TrappedProcessorDataAdhoc.klass)})},
  84. args: ["aBlock"],
  85. source: "newToView: aBlock\x0a\x09^self new\x0a\x09\x09toViewBlock: aBlock;\x0a\x09\x09yourself",
  86. messageSends: ["toViewBlock:", "new", "yourself"],
  87. referencedClasses: []
  88. }),
  89. smalltalk.TrappedProcessorDataAdhoc.klass);
  90. smalltalk.addClass('TrappedProcessorInputChecked', smalltalk.TrappedDataExpectingProcessor, [], 'Trapped-Processors');
  91. smalltalk.TrappedProcessorInputChecked.comment="I bind to checkbox checked attribute.";
  92. smalltalk.addMethod(
  93. smalltalk.method({
  94. selector: "installToView:toModel:",
  95. category: 'installation',
  96. fn: function (aDataCarrier,anotherDataCarrier){
  97. var self=this;
  98. var brush;
  99. return smalltalk.withContext(function($ctx1) {
  100. var $1,$2;
  101. brush=_st(aDataCarrier)._target();
  102. _st(brush)._onChange_((function(){
  103. return smalltalk.withContext(function($ctx2) {
  104. $1=_st(anotherDataCarrier)._copy();
  105. _st($1)._value_(_st(_st(_st(brush)._asJQuery())._attr_("checked"))._notNil());
  106. $2=_st($1)._proceed();
  107. return $2;
  108. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  109. return self}, function($ctx1) {$ctx1.fill(self,"installToView:toModel:",{aDataCarrier:aDataCarrier,anotherDataCarrier:anotherDataCarrier,brush:brush},smalltalk.TrappedProcessorInputChecked)})},
  110. args: ["aDataCarrier", "anotherDataCarrier"],
  111. source: "installToView: aDataCarrier toModel: anotherDataCarrier\x0a\x09| brush |\x0a\x09brush := aDataCarrier target.\x0a\x09brush onChange: [ anotherDataCarrier copy value: (brush asJQuery attr: 'checked') notNil; proceed ]",
  112. messageSends: ["target", "onChange:", "value:", "copy", "notNil", "attr:", "asJQuery", "proceed"],
  113. referencedClasses: []
  114. }),
  115. smalltalk.TrappedProcessorInputChecked);
  116. smalltalk.addMethod(
  117. smalltalk.method({
  118. selector: "toView:",
  119. category: 'data transformation',
  120. fn: function (aDataCarrier){
  121. var self=this;
  122. return smalltalk.withContext(function($ctx1) {
  123. _st(aDataCarrier)._toTargetAttr_("checked");
  124. return self}, function($ctx1) {$ctx1.fill(self,"toView:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessorInputChecked)})},
  125. args: ["aDataCarrier"],
  126. source: "toView: aDataCarrier\x0a\x09aDataCarrier toTargetAttr: 'checked'",
  127. messageSends: ["toTargetAttr:"],
  128. referencedClasses: []
  129. }),
  130. smalltalk.TrappedProcessorInputChecked);
  131. smalltalk.addClass('TrappedProcessorInputValue', smalltalk.TrappedDataExpectingProcessor, [], 'Trapped-Processors');
  132. smalltalk.TrappedProcessorInputValue.comment="I bind to input value.";
  133. smalltalk.addMethod(
  134. smalltalk.method({
  135. selector: "installToView:toModel:",
  136. category: 'installation',
  137. fn: function (aDataCarrier,anotherDataCarrier){
  138. var self=this;
  139. var brush;
  140. return smalltalk.withContext(function($ctx1) {
  141. var $1,$2;
  142. brush=_st(aDataCarrier)._target();
  143. _st(brush)._onChange_((function(){
  144. return smalltalk.withContext(function($ctx2) {
  145. $1=_st(anotherDataCarrier)._copy();
  146. _st($1)._value_(_st(_st(brush)._asJQuery())._val());
  147. $2=_st($1)._proceed();
  148. return $2;
  149. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  150. return self}, function($ctx1) {$ctx1.fill(self,"installToView:toModel:",{aDataCarrier:aDataCarrier,anotherDataCarrier:anotherDataCarrier,brush:brush},smalltalk.TrappedProcessorInputValue)})},
  151. args: ["aDataCarrier", "anotherDataCarrier"],
  152. source: "installToView: aDataCarrier toModel: anotherDataCarrier\x0a\x09| brush |\x0a\x09brush := aDataCarrier target.\x0a\x09brush onChange: [ anotherDataCarrier copy value: brush asJQuery val; proceed ]",
  153. messageSends: ["target", "onChange:", "value:", "copy", "val", "asJQuery", "proceed"],
  154. referencedClasses: []
  155. }),
  156. smalltalk.TrappedProcessorInputValue);
  157. smalltalk.addMethod(
  158. smalltalk.method({
  159. selector: "toView:",
  160. category: 'data transformation',
  161. fn: function (aDataCarrier){
  162. var self=this;
  163. return smalltalk.withContext(function($ctx1) {
  164. _st(aDataCarrier)._toTargetValue();
  165. return self}, function($ctx1) {$ctx1.fill(self,"toView:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessorInputValue)})},
  166. args: ["aDataCarrier"],
  167. source: "toView: aDataCarrier\x0a\x09aDataCarrier toTargetValue",
  168. messageSends: ["toTargetValue"],
  169. referencedClasses: []
  170. }),
  171. smalltalk.TrappedProcessorInputValue);
  172. smalltalk.addClass('TrappedProcessorBlackboard', smalltalk.TrappedProcessor, [], 'Trapped-Processors');
  173. smalltalk.TrappedProcessorBlackboard.comment="I am used internally to fetch data from blackboard\x0aor write it back.\x0a\x0aI am added to the beginning of the chain\x0awhen the chain contains at least one element\x0athat isExpectingModelData (see TrappedDataExpectingProcessor).";
  174. smalltalk.addMethod(
  175. smalltalk.method({
  176. selector: "installToView:toModel:",
  177. category: 'installation',
  178. fn: function (aDataCarrier,anotherDataCarrier){
  179. var self=this;
  180. var snap;
  181. function $KeyedPubSubUnsubscribe(){return smalltalk.KeyedPubSubUnsubscribe||(typeof KeyedPubSubUnsubscribe=="undefined"?nil:KeyedPubSubUnsubscribe)}
  182. return smalltalk.withContext(function($ctx1) {
  183. var $1,$2,$3;
  184. snap=_st(anotherDataCarrier)._target();
  185. $ctx1.sendIdx["target"]=1;
  186. _st(snap)._watch_((function(data){
  187. return smalltalk.withContext(function($ctx2) {
  188. $1=_st(_st(_st(_st(_st(aDataCarrier)._target())._asJQuery())._closest_("html"))._toArray())._isEmpty();
  189. if(smalltalk.assert($1)){
  190. _st($KeyedPubSubUnsubscribe())._signal();
  191. };
  192. return _st(snap)._do_((function(){
  193. return smalltalk.withContext(function($ctx3) {
  194. $2=_st(aDataCarrier)._copy();
  195. _st($2)._value_(data);
  196. $ctx3.sendIdx["value:"]=1;
  197. $3=_st($2)._proceed();
  198. return $3;
  199. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)})}));
  200. }, function($ctx2) {$ctx2.fillBlock({data:data},$ctx1,1)})}));
  201. _st(aDataCarrier)._value_(false);
  202. return self}, function($ctx1) {$ctx1.fill(self,"installToView:toModel:",{aDataCarrier:aDataCarrier,anotherDataCarrier:anotherDataCarrier,snap:snap},smalltalk.TrappedProcessorBlackboard)})},
  203. args: ["aDataCarrier", "anotherDataCarrier"],
  204. source: "installToView: aDataCarrier toModel: anotherDataCarrier\x0a\x09| snap |\x0a\x09snap := anotherDataCarrier target.\x0a\x09snap watch: [ :data |\x0a\x09\x09(aDataCarrier target asJQuery closest: 'html') toArray isEmpty ifTrue: [ KeyedPubSubUnsubscribe signal ].\x0a snap do: [ aDataCarrier copy value: data; proceed ] ].\x0a\x09aDataCarrier value: false",
  205. messageSends: ["target", "watch:", "ifTrue:", "isEmpty", "toArray", "closest:", "asJQuery", "signal", "do:", "value:", "copy", "proceed"],
  206. referencedClasses: ["KeyedPubSubUnsubscribe"]
  207. }),
  208. smalltalk.TrappedProcessorBlackboard);
  209. smalltalk.addMethod(
  210. smalltalk.method({
  211. selector: "toModel:",
  212. category: 'data transformation',
  213. fn: function (aDataCarrier){
  214. var self=this;
  215. return smalltalk.withContext(function($ctx1) {
  216. _st(aDataCarrier)._modifyTarget();
  217. return self}, function($ctx1) {$ctx1.fill(self,"toModel:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessorBlackboard)})},
  218. args: ["aDataCarrier"],
  219. source: "toModel: aDataCarrier\x0a\x09aDataCarrier modifyTarget",
  220. messageSends: ["modifyTarget"],
  221. referencedClasses: []
  222. }),
  223. smalltalk.TrappedProcessorBlackboard);
  224. smalltalk.addClass('TrappedProcessorDescend', smalltalk.TrappedProcessor, [], 'Trapped-Processors');
  225. smalltalk.TrappedProcessorDescend.comment="I intepret data-trap in descendants of my brush.";
  226. smalltalk.addMethod(
  227. smalltalk.method({
  228. selector: "toView:",
  229. category: 'data transformation',
  230. fn: function (aDataCarrier){
  231. var self=this;
  232. function $Trapped(){return smalltalk.Trapped||(typeof Trapped=="undefined"?nil:Trapped)}
  233. return smalltalk.withContext(function($ctx1) {
  234. _st(_st($Trapped())._current())._injectToJQuery_(_st(_st(_st(aDataCarrier)._target())._asJQuery())._children());
  235. return self}, function($ctx1) {$ctx1.fill(self,"toView:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessorDescend)})},
  236. args: ["aDataCarrier"],
  237. source: "toView: aDataCarrier\x0a\x09Trapped current injectToJQuery: aDataCarrier target asJQuery children",
  238. messageSends: ["injectToJQuery:", "current", "children", "asJQuery", "target"],
  239. referencedClasses: ["Trapped"]
  240. }),
  241. smalltalk.TrappedProcessorDescend);
  242. smalltalk.addClass('TrappedProcessorGuardBase', smalltalk.TrappedProcessor, ['guardPath'], 'Trapped-Processors');
  243. smalltalk.TrappedProcessorGuardBase.comment="I serve as base class for brush-guarding processors.\x0a\x0aI cover instantiation and subclasses have to provide\x0aimplementation of toVIew: that react appropriately to guard releasing.";
  244. smalltalk.addMethod(
  245. smalltalk.method({
  246. selector: "guardPath:",
  247. category: 'accessing',
  248. fn: function (anArray){
  249. var self=this;
  250. return smalltalk.withContext(function($ctx1) {
  251. self["@guardPath"]=anArray;
  252. return self}, function($ctx1) {$ctx1.fill(self,"guardPath:",{anArray:anArray},smalltalk.TrappedProcessorGuardBase)})},
  253. args: ["anArray"],
  254. source: "guardPath: anArray\x0a\x09guardPath := anArray",
  255. messageSends: [],
  256. referencedClasses: []
  257. }),
  258. smalltalk.TrappedProcessorGuardBase);
  259. smalltalk.addMethod(
  260. smalltalk.method({
  261. selector: "toModel:",
  262. category: 'data transformation',
  263. fn: function (aDataCarrier){
  264. var self=this;
  265. return smalltalk.withContext(function($ctx1) {
  266. return self}, function($ctx1) {$ctx1.fill(self,"toModel:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessorGuardBase)})},
  267. args: ["aDataCarrier"],
  268. source: "toModel: aDataCarrier\x0a\x09\x22stop\x22",
  269. messageSends: [],
  270. referencedClasses: []
  271. }),
  272. smalltalk.TrappedProcessorGuardBase);
  273. smalltalk.addMethod(
  274. smalltalk.method({
  275. selector: "toView:",
  276. category: 'data transformation',
  277. fn: function (aDataCarrier){
  278. var self=this;
  279. return smalltalk.withContext(function($ctx1) {
  280. self._subclassResponsibility();
  281. return self}, function($ctx1) {$ctx1.fill(self,"toView:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessorGuardBase)})},
  282. args: ["aDataCarrier"],
  283. source: "toView: aDataCarrier\x0a\x09self subclassResponsibility",
  284. messageSends: ["subclassResponsibility"],
  285. referencedClasses: []
  286. }),
  287. smalltalk.TrappedProcessorGuardBase);
  288. smalltalk.addMethod(
  289. smalltalk.method({
  290. selector: "new:",
  291. category: 'instance creation',
  292. fn: function (anArray){
  293. var self=this;
  294. return smalltalk.withContext(function($ctx1) {
  295. var $2,$3,$1;
  296. $2=self._new();
  297. _st($2)._guardPath_(anArray);
  298. $3=_st($2)._yourself();
  299. $1=$3;
  300. return $1;
  301. }, function($ctx1) {$ctx1.fill(self,"new:",{anArray:anArray},smalltalk.TrappedProcessorGuardBase.klass)})},
  302. args: ["anArray"],
  303. source: "new: anArray\x0a\x09^ self new\x0a\x09\x09guardPath: anArray;\x0a\x09\x09yourself",
  304. messageSends: ["guardPath:", "new", "yourself"],
  305. referencedClasses: []
  306. }),
  307. smalltalk.TrappedProcessorGuardBase.klass);
  308. smalltalk.addClass('TrappedProcessorGuardContents', smalltalk.TrappedProcessorGuardBase, [], 'Trapped-Processors');
  309. smalltalk.TrappedProcessorGuardContents.comment="I am used to guard contents of the brush I am installed on.\x0a\x0aI save the brush contents, then I observe guard expression in the model,\x0aand when it changes to nil or false, I delete the brush contents;\x0aon the other hand, when it changes to non-nil and non-false,\x0aI restore it from remembered state and interpret all contained\x0adata-trap attributes inside.";
  310. smalltalk.addMethod(
  311. smalltalk.method({
  312. selector: "toView:",
  313. category: 'data transformation',
  314. fn: function (aDataCarrier){
  315. var self=this;
  316. var frozen,contents;
  317. function $Trapped(){return smalltalk.Trapped||(typeof Trapped=="undefined"?nil:Trapped)}
  318. return smalltalk.withContext(function($ctx1) {
  319. var $3,$2,$1,$5,$4;
  320. frozen=_st(aDataCarrier)._copy();
  321. $3=_st(frozen)._target();
  322. $ctx1.sendIdx["target"]=1;
  323. $2=_st($3)._asJQuery();
  324. $ctx1.sendIdx["asJQuery"]=1;
  325. $1=_st($2)._contents();
  326. contents=_st($1)._detach();
  327. _st(_st(frozen)._target())._trapGuard_contents_(self["@guardPath"],(function(html){
  328. return smalltalk.withContext(function($ctx2) {
  329. $5=_st(html)._root();
  330. $ctx2.sendIdx["root"]=1;
  331. $4=_st($5)._asJQuery();
  332. $ctx2.sendIdx["asJQuery"]=2;
  333. _st($4)._append_(contents);
  334. return _st(_st($Trapped())._current())._injectToJQuery_(_st(_st(html)._root())._asJQuery());
  335. }, function($ctx2) {$ctx2.fillBlock({html:html},$ctx1,1)})}));
  336. return self}, function($ctx1) {$ctx1.fill(self,"toView:",{aDataCarrier:aDataCarrier,frozen:frozen,contents:contents},smalltalk.TrappedProcessorGuardContents)})},
  337. args: ["aDataCarrier"],
  338. source: "toView: aDataCarrier\x0a\x09| frozen contents |\x0a\x09frozen := aDataCarrier copy.\x0a\x09contents := frozen target asJQuery contents detach.\x0a\x09frozen target trapGuard: guardPath contents: [ :html |\x0a\x09\x09html root asJQuery append: contents.\x0a\x09\x09Trapped current injectToJQuery: html root asJQuery ]",
  339. messageSends: ["copy", "detach", "contents", "asJQuery", "target", "trapGuard:contents:", "append:", "root", "injectToJQuery:", "current"],
  340. referencedClasses: ["Trapped"]
  341. }),
  342. smalltalk.TrappedProcessorGuardContents);
  343. smalltalk.addClass('TrappedProcessorGuardProc', smalltalk.TrappedProcessorGuardBase, [], 'Trapped-Processors');
  344. smalltalk.TrappedProcessorGuardProc.comment="I am used to guard contents filling process of the brush I am installed on.\x0a\x0aI observe guard expression in the model,\x0aand when it changes to nil or false, I delete the brush contents;\x0aon the other hand, when it changes to non-nil and non-false,\x0aI run the rest on the chain, which should be one-time\x0athat sets up the contents,";
  345. smalltalk.addMethod(
  346. smalltalk.method({
  347. selector: "toView:",
  348. category: 'data transformation',
  349. fn: function (aDataCarrier){
  350. var self=this;
  351. var frozen;
  352. return smalltalk.withContext(function($ctx1) {
  353. frozen=_st(aDataCarrier)._copy();
  354. $ctx1.sendIdx["copy"]=1;
  355. _st(_st(frozen)._target())._trapGuard_contents_(self["@guardPath"],(function(){
  356. return smalltalk.withContext(function($ctx2) {
  357. return _st(_st(frozen)._copy())._proceed();
  358. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  359. return self}, function($ctx1) {$ctx1.fill(self,"toView:",{aDataCarrier:aDataCarrier,frozen:frozen},smalltalk.TrappedProcessorGuardProc)})},
  360. args: ["aDataCarrier"],
  361. source: "toView: aDataCarrier\x0a\x09| frozen |\x0a\x09frozen := aDataCarrier copy.\x0a\x09frozen target trapGuard: guardPath contents: [ frozen copy proceed ]",
  362. messageSends: ["copy", "trapGuard:contents:", "target", "proceed"],
  363. referencedClasses: []
  364. }),
  365. smalltalk.TrappedProcessorGuardProc);
  366. smalltalk.addClass('TrappedProcessorLoopBase', smalltalk.TrappedProcessor, [], 'Trapped-Processors');
  367. smalltalk.TrappedProcessorLoopBase.comment="I serve as base class for looping processors.\x0a\x0aI cover instantiation and subclasses have to provide\x0aimplementation of toVIew: that loops appropriately.";
  368. smalltalk.addMethod(
  369. smalltalk.method({
  370. selector: "toModel:",
  371. category: 'data transformation',
  372. fn: function (aDataCarrier){
  373. var self=this;
  374. return smalltalk.withContext(function($ctx1) {
  375. return self}, function($ctx1) {$ctx1.fill(self,"toModel:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessorLoopBase)})},
  376. args: ["aDataCarrier"],
  377. source: "toModel: aDataCarrier\x0a\x09\x22stop\x22",
  378. messageSends: [],
  379. referencedClasses: []
  380. }),
  381. smalltalk.TrappedProcessorLoopBase);
  382. smalltalk.addMethod(
  383. smalltalk.method({
  384. selector: "toView:",
  385. category: 'data transformation',
  386. fn: function (aDataCarrier){
  387. var self=this;
  388. return smalltalk.withContext(function($ctx1) {
  389. self._subclassResponsibility();
  390. return self}, function($ctx1) {$ctx1.fill(self,"toView:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessorLoopBase)})},
  391. args: ["aDataCarrier"],
  392. source: "toView: aDataCarrier\x0a\x09self subclassResponsibility",
  393. messageSends: ["subclassResponsibility"],
  394. referencedClasses: []
  395. }),
  396. smalltalk.TrappedProcessorLoopBase);
  397. smalltalk.addClass('TrappedProcessorLoopContents', smalltalk.TrappedProcessorLoopBase, [], 'Trapped-Processors');
  398. smalltalk.TrappedProcessorLoopContents.comment="I am used to loop over data and repeat the contents\x0aof the brush I am installed on.\x0a\x0aI save the brush contents, then I observe the data in the model,\x0aand when it changes, I loop over it\x0aand restore the contents from remembered state\x0aand interpret all contained data-trap attributes inside\x0afor each element, putting the result _after_ my brush.\x0a\x0aMy brush itself should be as least visible as possible,\x0aas it only serve as a position flag (use for example\x0anoscript, ins or del).";
  399. smalltalk.addMethod(
  400. smalltalk.method({
  401. selector: "toView:",
  402. category: 'data transformation',
  403. fn: function (aDataCarrier){
  404. var self=this;
  405. var frozen,contents;
  406. function $Trapped(){return smalltalk.Trapped||(typeof Trapped=="undefined"?nil:Trapped)}
  407. return smalltalk.withContext(function($ctx1) {
  408. var $3,$2,$1,$5,$4;
  409. frozen=_st(aDataCarrier)._copy();
  410. $3=_st(frozen)._target();
  411. $ctx1.sendIdx["target"]=1;
  412. $2=_st($3)._asJQuery();
  413. $ctx1.sendIdx["asJQuery"]=1;
  414. $1=_st($2)._contents();
  415. contents=_st($1)._detach();
  416. _st(_st(frozen)._target())._trapIter_after_([],(function(html){
  417. return smalltalk.withContext(function($ctx2) {
  418. $5=_st(html)._root();
  419. $ctx2.sendIdx["root"]=1;
  420. $4=_st($5)._asJQuery();
  421. $ctx2.sendIdx["asJQuery"]=2;
  422. _st($4)._append_(_st(contents)._clone());
  423. return _st(_st($Trapped())._current())._injectToJQuery_(_st(_st(html)._root())._asJQuery());
  424. }, function($ctx2) {$ctx2.fillBlock({html:html},$ctx1,1)})}));
  425. return self}, function($ctx1) {$ctx1.fill(self,"toView:",{aDataCarrier:aDataCarrier,frozen:frozen,contents:contents},smalltalk.TrappedProcessorLoopContents)})},
  426. args: ["aDataCarrier"],
  427. source: "toView: aDataCarrier\x0a\x09| frozen contents |\x0a\x09frozen := aDataCarrier copy.\x0a\x09contents := frozen target asJQuery contents detach.\x0a\x09frozen target trapIter: #() after: [ :html |\x0a\x09\x09html root asJQuery append: contents clone.\x0a\x09\x09Trapped current injectToJQuery: html root asJQuery ]",
  428. messageSends: ["copy", "detach", "contents", "asJQuery", "target", "trapIter:after:", "append:", "root", "clone", "injectToJQuery:", "current"],
  429. referencedClasses: ["Trapped"]
  430. }),
  431. smalltalk.TrappedProcessorLoopContents);
  432. smalltalk.addClass('TrappedProcessorLoopProc', smalltalk.TrappedProcessorLoopBase, [], 'Trapped-Processors');
  433. smalltalk.TrappedProcessorLoopProc.comment="I am used to loop over data and repeat the contents filling process\x0aof the brush I am installed on.\x0a\x0aI observe the data in the model,\x0aand when it changes, I loop over it\x0aand run the rest of the processing chain\x0afor each element, putting the result _after_ my brush.\x0a\x0aMy brush itself should be as least visible as possible,\x0aas it only serve as a position flag (use for example\x0anoscript, ins or del).";
  434. smalltalk.addMethod(
  435. smalltalk.method({
  436. selector: "toView:",
  437. category: 'data transformation',
  438. fn: function (aDataCarrier){
  439. var self=this;
  440. var frozen;
  441. return smalltalk.withContext(function($ctx1) {
  442. var $1,$2;
  443. frozen=_st(aDataCarrier)._copy();
  444. $ctx1.sendIdx["copy"]=1;
  445. _st(_st(frozen)._target())._trapIter_after_([],(function(html){
  446. return smalltalk.withContext(function($ctx2) {
  447. $1=_st(frozen)._copy();
  448. _st($1)._target_(_st(html)._root());
  449. $2=_st($1)._proceed();
  450. return $2;
  451. }, function($ctx2) {$ctx2.fillBlock({html:html},$ctx1,1)})}));
  452. return self}, function($ctx1) {$ctx1.fill(self,"toView:",{aDataCarrier:aDataCarrier,frozen:frozen},smalltalk.TrappedProcessorLoopProc)})},
  453. args: ["aDataCarrier"],
  454. source: "toView: aDataCarrier\x0a\x09| frozen |\x0a\x09frozen := aDataCarrier copy.\x0a\x09frozen target trapIter: #() after: [ :html | frozen copy target: html root; proceed ]",
  455. messageSends: ["copy", "trapIter:after:", "target", "target:", "root", "proceed"],
  456. referencedClasses: []
  457. }),
  458. smalltalk.TrappedProcessorLoopProc);
  459. smalltalk.addClass('TrappedProcessorSignal', smalltalk.TrappedProcessor, ['selector'], 'Trapped-Processors');
  460. smalltalk.TrappedProcessorSignal.comment="Instead of writing data directly to model,\x0aI instead modify it by sending a message specified when instantiating me.";
  461. smalltalk.addMethod(
  462. smalltalk.method({
  463. selector: "selector:",
  464. category: 'accessing',
  465. fn: function (aString){
  466. var self=this;
  467. return smalltalk.withContext(function($ctx1) {
  468. self["@selector"]=aString;
  469. return self}, function($ctx1) {$ctx1.fill(self,"selector:",{aString:aString},smalltalk.TrappedProcessorSignal)})},
  470. args: ["aString"],
  471. source: "selector: aString\x0a\x09selector := aString",
  472. messageSends: [],
  473. referencedClasses: []
  474. }),
  475. smalltalk.TrappedProcessorSignal);
  476. smalltalk.addMethod(
  477. smalltalk.method({
  478. selector: "toModel:",
  479. category: 'data transformation',
  480. fn: function (aDataCarrier){
  481. var self=this;
  482. return smalltalk.withContext(function($ctx1) {
  483. _st(aDataCarrier)._modifyTargetByPerforming_(self["@selector"]);
  484. return self}, function($ctx1) {$ctx1.fill(self,"toModel:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessorSignal)})},
  485. args: ["aDataCarrier"],
  486. source: "toModel: aDataCarrier\x0a\x09aDataCarrier modifyTargetByPerforming: selector",
  487. messageSends: ["modifyTargetByPerforming:"],
  488. referencedClasses: []
  489. }),
  490. smalltalk.TrappedProcessorSignal);
  491. smalltalk.addMethod(
  492. smalltalk.method({
  493. selector: "toView:",
  494. category: 'data transformation',
  495. fn: function (aDataCarrier){
  496. var self=this;
  497. return smalltalk.withContext(function($ctx1) {
  498. return self}, function($ctx1) {$ctx1.fill(self,"toView:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessorSignal)})},
  499. args: ["aDataCarrier"],
  500. source: "toView: aDataCarrier\x0a\x09\x22stop\x22",
  501. messageSends: [],
  502. referencedClasses: []
  503. }),
  504. smalltalk.TrappedProcessorSignal);
  505. smalltalk.addMethod(
  506. smalltalk.method({
  507. selector: "new:",
  508. category: 'instance creation',
  509. fn: function (aString){
  510. var self=this;
  511. return smalltalk.withContext(function($ctx1) {
  512. var $2,$3,$1;
  513. $2=self._new();
  514. _st($2)._selector_(aString);
  515. $3=_st($2)._yourself();
  516. $1=$3;
  517. return $1;
  518. }, function($ctx1) {$ctx1.fill(self,"new:",{aString:aString},smalltalk.TrappedProcessorSignal.klass)})},
  519. args: ["aString"],
  520. source: "new: aString\x0a\x09^self new\x0a\x09\x09selector: aString;\x0a\x09\x09yourself",
  521. messageSends: ["selector:", "new", "yourself"],
  522. referencedClasses: []
  523. }),
  524. smalltalk.TrappedProcessorSignal.klass);
  525. smalltalk.addClass('TrappedProcessorTerminator', smalltalk.TrappedProcessor, [], 'Trapped-Processors');
  526. smalltalk.TrappedProcessorTerminator.comment="I do not proceed in toView:.\x0a\x0aI am added automatically to end of chain when it does not contain\x0aany element that isExpectingModelData (see TrappedDataExpectingProcessor).";
  527. smalltalk.addMethod(
  528. smalltalk.method({
  529. selector: "toView:",
  530. category: 'data transformation',
  531. fn: function (aDataCarrier){
  532. var self=this;
  533. return smalltalk.withContext(function($ctx1) {
  534. return self}, function($ctx1) {$ctx1.fill(self,"toView:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessorTerminator)})},
  535. args: ["aDataCarrier"],
  536. source: "toView: aDataCarrier\x0a\x09\x22stop\x22",
  537. messageSends: [],
  538. referencedClasses: []
  539. }),
  540. smalltalk.TrappedProcessorTerminator);
  541. smalltalk.addClass('TrappedProcessorWhenClicked', smalltalk.TrappedProcessor, [], 'Trapped-Processors');
  542. smalltalk.TrappedProcessorWhenClicked.comment="I bind to an element and send true to blackboard when clicked.";
  543. smalltalk.addMethod(
  544. smalltalk.method({
  545. selector: "installToView:toModel:",
  546. category: 'installation',
  547. fn: function (aDataCarrier,anotherDataCarrier){
  548. var self=this;
  549. return smalltalk.withContext(function($ctx1) {
  550. _st(_st(aDataCarrier)._target())._onClick_((function(){
  551. return smalltalk.withContext(function($ctx2) {
  552. _st(_st(anotherDataCarrier)._copy())._proceed();
  553. return false;
  554. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  555. return self}, function($ctx1) {$ctx1.fill(self,"installToView:toModel:",{aDataCarrier:aDataCarrier,anotherDataCarrier:anotherDataCarrier},smalltalk.TrappedProcessorWhenClicked)})},
  556. args: ["aDataCarrier", "anotherDataCarrier"],
  557. source: "installToView: aDataCarrier toModel: anotherDataCarrier\x0a\x09aDataCarrier target onClick: [ anotherDataCarrier copy proceed. false ]",
  558. messageSends: ["onClick:", "target", "proceed", "copy"],
  559. referencedClasses: []
  560. }),
  561. smalltalk.TrappedProcessorWhenClicked);
  562. smalltalk.addClass('TrappedProcessorWhenSubmitted', smalltalk.TrappedProcessor, [], 'Trapped-Processors');
  563. smalltalk.TrappedProcessorWhenSubmitted.comment="I bind to a form and send true to blackboard when submitted.";
  564. smalltalk.addMethod(
  565. smalltalk.method({
  566. selector: "installToView:toModel:",
  567. category: 'installation',
  568. fn: function (aDataCarrier,anotherDataCarrier){
  569. var self=this;
  570. return smalltalk.withContext(function($ctx1) {
  571. _st(_st(aDataCarrier)._target())._onSubmit_((function(){
  572. return smalltalk.withContext(function($ctx2) {
  573. _st(_st(anotherDataCarrier)._copy())._proceed();
  574. return false;
  575. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  576. return self}, function($ctx1) {$ctx1.fill(self,"installToView:toModel:",{aDataCarrier:aDataCarrier,anotherDataCarrier:anotherDataCarrier},smalltalk.TrappedProcessorWhenSubmitted)})},
  577. args: ["aDataCarrier", "anotherDataCarrier"],
  578. source: "installToView: aDataCarrier toModel: anotherDataCarrier\x0a\x09aDataCarrier target onSubmit: [ anotherDataCarrier copy proceed. false ]",
  579. messageSends: ["onSubmit:", "target", "proceed", "copy"],
  580. referencedClasses: []
  581. }),
  582. smalltalk.TrappedProcessorWhenSubmitted);
  583. smalltalk.addClass('TrappedProcessorWidget', smalltalk.TrappedProcessor, ['viewName'], 'Trapped-Processors');
  584. smalltalk.TrappedProcessorWidget.comment="I insert a widget instance of the class specified when creating me.";
  585. smalltalk.addMethod(
  586. smalltalk.method({
  587. selector: "toView:",
  588. category: 'data transformation',
  589. fn: function (aDataCarrier){
  590. var self=this;
  591. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  592. return smalltalk.withContext(function($ctx1) {
  593. _st(_st(aDataCarrier)._target())._with_(_st(_st(_st($Smalltalk())._current())._at_(self["@viewName"]))._new());
  594. return self}, function($ctx1) {$ctx1.fill(self,"toView:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessorWidget)})},
  595. args: ["aDataCarrier"],
  596. source: "toView: aDataCarrier\x0a\x09aDataCarrier target with: (Smalltalk current at: viewName) new",
  597. messageSends: ["with:", "target", "new", "at:", "current"],
  598. referencedClasses: ["Smalltalk"]
  599. }),
  600. smalltalk.TrappedProcessorWidget);
  601. smalltalk.addMethod(
  602. smalltalk.method({
  603. selector: "viewName:",
  604. category: 'accessing',
  605. fn: function (aString){
  606. var self=this;
  607. return smalltalk.withContext(function($ctx1) {
  608. self["@viewName"]=aString;
  609. return self}, function($ctx1) {$ctx1.fill(self,"viewName:",{aString:aString},smalltalk.TrappedProcessorWidget)})},
  610. args: ["aString"],
  611. source: "viewName: aString\x0a\x09viewName := aString",
  612. messageSends: [],
  613. referencedClasses: []
  614. }),
  615. smalltalk.TrappedProcessorWidget);
  616. smalltalk.addMethod(
  617. smalltalk.method({
  618. selector: "new:",
  619. category: 'instance creation',
  620. fn: function (aString){
  621. var self=this;
  622. return smalltalk.withContext(function($ctx1) {
  623. var $2,$3,$1;
  624. $2=self._new();
  625. _st($2)._viewName_(aString);
  626. $3=_st($2)._yourself();
  627. $1=$3;
  628. return $1;
  629. }, function($ctx1) {$ctx1.fill(self,"new:",{aString:aString},smalltalk.TrappedProcessorWidget.klass)})},
  630. args: ["aString"],
  631. source: "new: aString\x0a\x09^self new\x0a\x09\x09viewName: aString;\x0a\x09\x09yourself",
  632. messageSends: ["viewName:", "new", "yourself"],
  633. referencedClasses: []
  634. }),
  635. smalltalk.TrappedProcessorWidget.klass);
  636. smalltalk.addMethod(
  637. smalltalk.method({
  638. selector: "modifyTarget",
  639. category: '*Trapped-Processors',
  640. fn: function (){
  641. var self=this;
  642. return smalltalk.withContext(function($ctx1) {
  643. _st(self._target())._modify_((function(){
  644. return smalltalk.withContext(function($ctx2) {
  645. return self._value();
  646. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  647. return self}, function($ctx1) {$ctx1.fill(self,"modifyTarget",{},smalltalk.TrappedDataCarrier)})},
  648. args: [],
  649. source: "modifyTarget\x0a\x09self target modify: [ self value ]",
  650. messageSends: ["modify:", "target", "value"],
  651. referencedClasses: []
  652. }),
  653. smalltalk.TrappedDataCarrier);
  654. smalltalk.addMethod(
  655. smalltalk.method({
  656. selector: "modifyTargetByPerforming:",
  657. category: '*Trapped-Processors',
  658. fn: function (aString){
  659. var self=this;
  660. return smalltalk.withContext(function($ctx1) {
  661. _st(self._target())._modify_((function(m){
  662. return smalltalk.withContext(function($ctx2) {
  663. return _st(m)._perform_(aString);
  664. }, function($ctx2) {$ctx2.fillBlock({m:m},$ctx1,1)})}));
  665. return self}, function($ctx1) {$ctx1.fill(self,"modifyTargetByPerforming:",{aString:aString},smalltalk.TrappedDataCarrier)})},
  666. args: ["aString"],
  667. source: "modifyTargetByPerforming: aString\x0a\x09self target modify: [ :m | m perform: aString ]",
  668. messageSends: ["modify:", "target", "perform:"],
  669. referencedClasses: []
  670. }),
  671. smalltalk.TrappedDataCarrier);
  672. smalltalk.addMethod(
  673. smalltalk.method({
  674. selector: "toTargetAttr:",
  675. category: '*Trapped-Processors',
  676. fn: function (aString){
  677. var self=this;
  678. return smalltalk.withContext(function($ctx1) {
  679. var $1,$3,$2;
  680. $1=_st(self._target())._asJQuery();
  681. $3=self._value();
  682. $ctx1.sendIdx["value"]=1;
  683. if(($receiver = $3) == nil || $receiver == null){
  684. $2=(function(){
  685. return smalltalk.withContext(function($ctx2) {
  686. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})});
  687. } else {
  688. var o;
  689. o=$receiver;
  690. $2=_st(o)._value();
  691. };
  692. _st($1)._attr_put_(aString,$2);
  693. return self}, function($ctx1) {$ctx1.fill(self,"toTargetAttr:",{aString:aString},smalltalk.TrappedDataCarrier)})},
  694. args: ["aString"],
  695. source: "toTargetAttr: aString\x0a\x09self target asJQuery attr: aString put: (self value ifNotNil: [ :o | o value ] ifNil: [[]])",
  696. messageSends: ["attr:put:", "asJQuery", "target", "ifNotNil:ifNil:", "value"],
  697. referencedClasses: []
  698. }),
  699. smalltalk.TrappedDataCarrier);
  700. smalltalk.addMethod(
  701. smalltalk.method({
  702. selector: "toTargetContents",
  703. category: '*Trapped-Processors',
  704. fn: function (){
  705. var self=this;
  706. return smalltalk.withContext(function($ctx1) {
  707. _st(self._target())._contents_(self._value());
  708. return self}, function($ctx1) {$ctx1.fill(self,"toTargetContents",{},smalltalk.TrappedDataCarrier)})},
  709. args: [],
  710. source: "toTargetContents\x0a\x09self target contents: self value",
  711. messageSends: ["contents:", "target", "value"],
  712. referencedClasses: []
  713. }),
  714. smalltalk.TrappedDataCarrier);
  715. smalltalk.addMethod(
  716. smalltalk.method({
  717. selector: "toTargetValue",
  718. category: '*Trapped-Processors',
  719. fn: function (){
  720. var self=this;
  721. return smalltalk.withContext(function($ctx1) {
  722. var $1,$3,$2;
  723. $1=_st(self._target())._asJQuery();
  724. $3=self._value();
  725. $ctx1.sendIdx["value"]=1;
  726. if(($receiver = $3) == nil || $receiver == null){
  727. $2=(function(){
  728. return smalltalk.withContext(function($ctx2) {
  729. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})});
  730. } else {
  731. var o;
  732. o=$receiver;
  733. $2=_st(o)._value();
  734. };
  735. _st($1)._val_($2);
  736. return self}, function($ctx1) {$ctx1.fill(self,"toTargetValue",{},smalltalk.TrappedDataCarrier)})},
  737. args: [],
  738. source: "toTargetValue\x0a\x09self target asJQuery val: (self value ifNotNil: [ :o | o value ] ifNil: [[]])",
  739. messageSends: ["val:", "asJQuery", "target", "ifNotNil:ifNil:", "value"],
  740. referencedClasses: []
  741. }),
  742. smalltalk.TrappedDataCarrier);
  743. });