Trapped-Processors.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  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('TrappedProcessorSignal', smalltalk.TrappedProcessor, ['selector'], 'Trapped-Processors');
  367. smalltalk.TrappedProcessorSignal.comment="Instead of writing data directly to model,\x0aI instead modify it by sending a message specified when instantiating me.";
  368. smalltalk.addMethod(
  369. smalltalk.method({
  370. selector: "selector:",
  371. category: 'accessing',
  372. fn: function (aString){
  373. var self=this;
  374. return smalltalk.withContext(function($ctx1) {
  375. self["@selector"]=aString;
  376. return self}, function($ctx1) {$ctx1.fill(self,"selector:",{aString:aString},smalltalk.TrappedProcessorSignal)})},
  377. args: ["aString"],
  378. source: "selector: aString\x0a\x09selector := aString",
  379. messageSends: [],
  380. referencedClasses: []
  381. }),
  382. smalltalk.TrappedProcessorSignal);
  383. smalltalk.addMethod(
  384. smalltalk.method({
  385. selector: "toModel:",
  386. category: 'data transformation',
  387. fn: function (aDataCarrier){
  388. var self=this;
  389. return smalltalk.withContext(function($ctx1) {
  390. _st(aDataCarrier)._modifyTargetByPerforming_(self["@selector"]);
  391. return self}, function($ctx1) {$ctx1.fill(self,"toModel:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessorSignal)})},
  392. args: ["aDataCarrier"],
  393. source: "toModel: aDataCarrier\x0a\x09aDataCarrier modifyTargetByPerforming: selector",
  394. messageSends: ["modifyTargetByPerforming:"],
  395. referencedClasses: []
  396. }),
  397. smalltalk.TrappedProcessorSignal);
  398. smalltalk.addMethod(
  399. smalltalk.method({
  400. selector: "toView:",
  401. category: 'data transformation',
  402. fn: function (aDataCarrier){
  403. var self=this;
  404. return smalltalk.withContext(function($ctx1) {
  405. return self}, function($ctx1) {$ctx1.fill(self,"toView:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessorSignal)})},
  406. args: ["aDataCarrier"],
  407. source: "toView: aDataCarrier\x0a\x09\x22stop\x22",
  408. messageSends: [],
  409. referencedClasses: []
  410. }),
  411. smalltalk.TrappedProcessorSignal);
  412. smalltalk.addMethod(
  413. smalltalk.method({
  414. selector: "new:",
  415. category: 'instance creation',
  416. fn: function (aString){
  417. var self=this;
  418. return smalltalk.withContext(function($ctx1) {
  419. var $2,$3,$1;
  420. $2=self._new();
  421. _st($2)._selector_(aString);
  422. $3=_st($2)._yourself();
  423. $1=$3;
  424. return $1;
  425. }, function($ctx1) {$ctx1.fill(self,"new:",{aString:aString},smalltalk.TrappedProcessorSignal.klass)})},
  426. args: ["aString"],
  427. source: "new: aString\x0a\x09^self new\x0a\x09\x09selector: aString;\x0a\x09\x09yourself",
  428. messageSends: ["selector:", "new", "yourself"],
  429. referencedClasses: []
  430. }),
  431. smalltalk.TrappedProcessorSignal.klass);
  432. smalltalk.addClass('TrappedProcessorTerminator', smalltalk.TrappedProcessor, [], 'Trapped-Processors');
  433. 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).";
  434. smalltalk.addMethod(
  435. smalltalk.method({
  436. selector: "toView:",
  437. category: 'data transformation',
  438. fn: function (aDataCarrier){
  439. var self=this;
  440. return smalltalk.withContext(function($ctx1) {
  441. return self}, function($ctx1) {$ctx1.fill(self,"toView:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessorTerminator)})},
  442. args: ["aDataCarrier"],
  443. source: "toView: aDataCarrier\x0a\x09\x22stop\x22",
  444. messageSends: [],
  445. referencedClasses: []
  446. }),
  447. smalltalk.TrappedProcessorTerminator);
  448. smalltalk.addClass('TrappedProcessorWhenClicked', smalltalk.TrappedProcessor, [], 'Trapped-Processors');
  449. smalltalk.TrappedProcessorWhenClicked.comment="I bind to an element and send true to blackboard when clicked.";
  450. smalltalk.addMethod(
  451. smalltalk.method({
  452. selector: "installToView:toModel:",
  453. category: 'installation',
  454. fn: function (aDataCarrier,anotherDataCarrier){
  455. var self=this;
  456. return smalltalk.withContext(function($ctx1) {
  457. _st(_st(aDataCarrier)._target())._onClick_((function(){
  458. return smalltalk.withContext(function($ctx2) {
  459. _st(_st(anotherDataCarrier)._copy())._proceed();
  460. return false;
  461. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  462. return self}, function($ctx1) {$ctx1.fill(self,"installToView:toModel:",{aDataCarrier:aDataCarrier,anotherDataCarrier:anotherDataCarrier},smalltalk.TrappedProcessorWhenClicked)})},
  463. args: ["aDataCarrier", "anotherDataCarrier"],
  464. source: "installToView: aDataCarrier toModel: anotherDataCarrier\x0a\x09aDataCarrier target onClick: [ anotherDataCarrier copy proceed. false ]",
  465. messageSends: ["onClick:", "target", "proceed", "copy"],
  466. referencedClasses: []
  467. }),
  468. smalltalk.TrappedProcessorWhenClicked);
  469. smalltalk.addClass('TrappedProcessorWhenSubmitted', smalltalk.TrappedProcessor, [], 'Trapped-Processors');
  470. smalltalk.TrappedProcessorWhenSubmitted.comment="I bind to a form and send true to blackboard when submitted.";
  471. smalltalk.addMethod(
  472. smalltalk.method({
  473. selector: "installToView:toModel:",
  474. category: 'installation',
  475. fn: function (aDataCarrier,anotherDataCarrier){
  476. var self=this;
  477. return smalltalk.withContext(function($ctx1) {
  478. _st(_st(aDataCarrier)._target())._onSubmit_((function(){
  479. return smalltalk.withContext(function($ctx2) {
  480. _st(_st(anotherDataCarrier)._copy())._proceed();
  481. return false;
  482. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  483. return self}, function($ctx1) {$ctx1.fill(self,"installToView:toModel:",{aDataCarrier:aDataCarrier,anotherDataCarrier:anotherDataCarrier},smalltalk.TrappedProcessorWhenSubmitted)})},
  484. args: ["aDataCarrier", "anotherDataCarrier"],
  485. source: "installToView: aDataCarrier toModel: anotherDataCarrier\x0a\x09aDataCarrier target onSubmit: [ anotherDataCarrier copy proceed. false ]",
  486. messageSends: ["onSubmit:", "target", "proceed", "copy"],
  487. referencedClasses: []
  488. }),
  489. smalltalk.TrappedProcessorWhenSubmitted);
  490. smalltalk.addClass('TrappedProcessorWidget', smalltalk.TrappedProcessor, ['viewName'], 'Trapped-Processors');
  491. smalltalk.TrappedProcessorWidget.comment="I insert a widget instance of the class specified when creating me.";
  492. smalltalk.addMethod(
  493. smalltalk.method({
  494. selector: "toView:",
  495. category: 'data transformation',
  496. fn: function (aDataCarrier){
  497. var self=this;
  498. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  499. return smalltalk.withContext(function($ctx1) {
  500. _st(_st(aDataCarrier)._target())._with_(_st(_st(_st($Smalltalk())._current())._at_(self["@viewName"]))._new());
  501. return self}, function($ctx1) {$ctx1.fill(self,"toView:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessorWidget)})},
  502. args: ["aDataCarrier"],
  503. source: "toView: aDataCarrier\x0a\x09aDataCarrier target with: (Smalltalk current at: viewName) new",
  504. messageSends: ["with:", "target", "new", "at:", "current"],
  505. referencedClasses: ["Smalltalk"]
  506. }),
  507. smalltalk.TrappedProcessorWidget);
  508. smalltalk.addMethod(
  509. smalltalk.method({
  510. selector: "viewName:",
  511. category: 'accessing',
  512. fn: function (aString){
  513. var self=this;
  514. return smalltalk.withContext(function($ctx1) {
  515. self["@viewName"]=aString;
  516. return self}, function($ctx1) {$ctx1.fill(self,"viewName:",{aString:aString},smalltalk.TrappedProcessorWidget)})},
  517. args: ["aString"],
  518. source: "viewName: aString\x0a\x09viewName := aString",
  519. messageSends: [],
  520. referencedClasses: []
  521. }),
  522. smalltalk.TrappedProcessorWidget);
  523. smalltalk.addMethod(
  524. smalltalk.method({
  525. selector: "new:",
  526. category: 'instance creation',
  527. fn: function (aString){
  528. var self=this;
  529. return smalltalk.withContext(function($ctx1) {
  530. var $2,$3,$1;
  531. $2=self._new();
  532. _st($2)._viewName_(aString);
  533. $3=_st($2)._yourself();
  534. $1=$3;
  535. return $1;
  536. }, function($ctx1) {$ctx1.fill(self,"new:",{aString:aString},smalltalk.TrappedProcessorWidget.klass)})},
  537. args: ["aString"],
  538. source: "new: aString\x0a\x09^self new\x0a\x09\x09viewName: aString;\x0a\x09\x09yourself",
  539. messageSends: ["viewName:", "new", "yourself"],
  540. referencedClasses: []
  541. }),
  542. smalltalk.TrappedProcessorWidget.klass);
  543. smalltalk.addMethod(
  544. smalltalk.method({
  545. selector: "modifyTarget",
  546. category: '*Trapped-Processors',
  547. fn: function (){
  548. var self=this;
  549. return smalltalk.withContext(function($ctx1) {
  550. _st(self._target())._modify_((function(){
  551. return smalltalk.withContext(function($ctx2) {
  552. return self._value();
  553. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  554. return self}, function($ctx1) {$ctx1.fill(self,"modifyTarget",{},smalltalk.TrappedDataCarrier)})},
  555. args: [],
  556. source: "modifyTarget\x0a\x09self target modify: [ self value ]",
  557. messageSends: ["modify:", "target", "value"],
  558. referencedClasses: []
  559. }),
  560. smalltalk.TrappedDataCarrier);
  561. smalltalk.addMethod(
  562. smalltalk.method({
  563. selector: "modifyTargetByPerforming:",
  564. category: '*Trapped-Processors',
  565. fn: function (aString){
  566. var self=this;
  567. return smalltalk.withContext(function($ctx1) {
  568. _st(self._target())._modify_((function(m){
  569. return smalltalk.withContext(function($ctx2) {
  570. return _st(m)._perform_(aString);
  571. }, function($ctx2) {$ctx2.fillBlock({m:m},$ctx1,1)})}));
  572. return self}, function($ctx1) {$ctx1.fill(self,"modifyTargetByPerforming:",{aString:aString},smalltalk.TrappedDataCarrier)})},
  573. args: ["aString"],
  574. source: "modifyTargetByPerforming: aString\x0a\x09self target modify: [ :m | m perform: aString ]",
  575. messageSends: ["modify:", "target", "perform:"],
  576. referencedClasses: []
  577. }),
  578. smalltalk.TrappedDataCarrier);
  579. smalltalk.addMethod(
  580. smalltalk.method({
  581. selector: "toTargetAttr:",
  582. category: '*Trapped-Processors',
  583. fn: function (aString){
  584. var self=this;
  585. return smalltalk.withContext(function($ctx1) {
  586. var $1,$3,$2;
  587. $1=_st(self._target())._asJQuery();
  588. $3=self._value();
  589. $ctx1.sendIdx["value"]=1;
  590. if(($receiver = $3) == nil || $receiver == null){
  591. $2=(function(){
  592. return smalltalk.withContext(function($ctx2) {
  593. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})});
  594. } else {
  595. var o;
  596. o=$receiver;
  597. $2=_st(o)._value();
  598. };
  599. _st($1)._attr_put_(aString,$2);
  600. return self}, function($ctx1) {$ctx1.fill(self,"toTargetAttr:",{aString:aString},smalltalk.TrappedDataCarrier)})},
  601. args: ["aString"],
  602. source: "toTargetAttr: aString\x0a\x09self target asJQuery attr: aString put: (self value ifNotNil: [ :o | o value ] ifNil: [[]])",
  603. messageSends: ["attr:put:", "asJQuery", "target", "ifNotNil:ifNil:", "value"],
  604. referencedClasses: []
  605. }),
  606. smalltalk.TrappedDataCarrier);
  607. smalltalk.addMethod(
  608. smalltalk.method({
  609. selector: "toTargetContents",
  610. category: '*Trapped-Processors',
  611. fn: function (){
  612. var self=this;
  613. return smalltalk.withContext(function($ctx1) {
  614. _st(self._target())._contents_(self._value());
  615. return self}, function($ctx1) {$ctx1.fill(self,"toTargetContents",{},smalltalk.TrappedDataCarrier)})},
  616. args: [],
  617. source: "toTargetContents\x0a\x09self target contents: self value",
  618. messageSends: ["contents:", "target", "value"],
  619. referencedClasses: []
  620. }),
  621. smalltalk.TrappedDataCarrier);
  622. smalltalk.addMethod(
  623. smalltalk.method({
  624. selector: "toTargetValue",
  625. category: '*Trapped-Processors',
  626. fn: function (){
  627. var self=this;
  628. return smalltalk.withContext(function($ctx1) {
  629. var $1,$3,$2;
  630. $1=_st(self._target())._asJQuery();
  631. $3=self._value();
  632. $ctx1.sendIdx["value"]=1;
  633. if(($receiver = $3) == nil || $receiver == null){
  634. $2=(function(){
  635. return smalltalk.withContext(function($ctx2) {
  636. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})});
  637. } else {
  638. var o;
  639. o=$receiver;
  640. $2=_st(o)._value();
  641. };
  642. _st($1)._val_($2);
  643. return self}, function($ctx1) {$ctx1.fill(self,"toTargetValue",{},smalltalk.TrappedDataCarrier)})},
  644. args: [],
  645. source: "toTargetValue\x0a\x09self target asJQuery val: (self value ifNotNil: [ :o | o value ] ifNil: [[]])",
  646. messageSends: ["val:", "asJQuery", "target", "ifNotNil:ifNil:", "value"],
  647. referencedClasses: []
  648. }),
  649. smalltalk.TrappedDataCarrier);
  650. });