Trapped-Processors.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  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('TrappedProcessorInputChecked', smalltalk.TrappedDataExpectingProcessor, [], 'Trapped-Processors');
  39. smalltalk.TrappedProcessorInputChecked.comment="I bind to checkbox checked attribute.";
  40. smalltalk.addMethod(
  41. smalltalk.method({
  42. selector: "installToView:toModel:",
  43. category: 'installation',
  44. fn: function (aDataCarrier,anotherDataCarrier){
  45. var self=this;
  46. var brush;
  47. return smalltalk.withContext(function($ctx1) {
  48. var $1,$2;
  49. brush=_st(aDataCarrier)._target();
  50. _st(brush)._onChange_((function(){
  51. return smalltalk.withContext(function($ctx2) {
  52. $1=_st(anotherDataCarrier)._copy();
  53. _st($1)._value_(_st(_st(_st(brush)._asJQuery())._attr_("checked"))._notNil());
  54. $2=_st($1)._proceed();
  55. return $2;
  56. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  57. return self}, function($ctx1) {$ctx1.fill(self,"installToView:toModel:",{aDataCarrier:aDataCarrier,anotherDataCarrier:anotherDataCarrier,brush:brush},smalltalk.TrappedProcessorInputChecked)})},
  58. args: ["aDataCarrier", "anotherDataCarrier"],
  59. source: "installToView: aDataCarrier toModel: anotherDataCarrier\x0a\x09| brush |\x0a\x09brush := aDataCarrier target.\x0a\x09brush onChange: [ anotherDataCarrier copy value: (brush asJQuery attr: 'checked') notNil; proceed ]",
  60. messageSends: ["target", "onChange:", "value:", "copy", "notNil", "attr:", "asJQuery", "proceed"],
  61. referencedClasses: []
  62. }),
  63. smalltalk.TrappedProcessorInputChecked);
  64. smalltalk.addMethod(
  65. smalltalk.method({
  66. selector: "toView:",
  67. category: 'data transformation',
  68. fn: function (aDataCarrier){
  69. var self=this;
  70. return smalltalk.withContext(function($ctx1) {
  71. _st(aDataCarrier)._toTargetAttr_("checked");
  72. return self}, function($ctx1) {$ctx1.fill(self,"toView:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessorInputChecked)})},
  73. args: ["aDataCarrier"],
  74. source: "toView: aDataCarrier\x0a\x09aDataCarrier toTargetAttr: 'checked'",
  75. messageSends: ["toTargetAttr:"],
  76. referencedClasses: []
  77. }),
  78. smalltalk.TrappedProcessorInputChecked);
  79. smalltalk.addClass('TrappedProcessorInputValue', smalltalk.TrappedDataExpectingProcessor, [], 'Trapped-Processors');
  80. smalltalk.TrappedProcessorInputValue.comment="I bind to input value.";
  81. smalltalk.addMethod(
  82. smalltalk.method({
  83. selector: "installToView:toModel:",
  84. category: 'installation',
  85. fn: function (aDataCarrier,anotherDataCarrier){
  86. var self=this;
  87. var brush;
  88. return smalltalk.withContext(function($ctx1) {
  89. var $1,$2;
  90. brush=_st(aDataCarrier)._target();
  91. _st(brush)._onChange_((function(){
  92. return smalltalk.withContext(function($ctx2) {
  93. $1=_st(anotherDataCarrier)._copy();
  94. _st($1)._value_(_st(_st(brush)._asJQuery())._val());
  95. $2=_st($1)._proceed();
  96. return $2;
  97. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  98. return self}, function($ctx1) {$ctx1.fill(self,"installToView:toModel:",{aDataCarrier:aDataCarrier,anotherDataCarrier:anotherDataCarrier,brush:brush},smalltalk.TrappedProcessorInputValue)})},
  99. args: ["aDataCarrier", "anotherDataCarrier"],
  100. source: "installToView: aDataCarrier toModel: anotherDataCarrier\x0a\x09| brush |\x0a\x09brush := aDataCarrier target.\x0a\x09brush onChange: [ anotherDataCarrier copy value: brush asJQuery val; proceed ]",
  101. messageSends: ["target", "onChange:", "value:", "copy", "val", "asJQuery", "proceed"],
  102. referencedClasses: []
  103. }),
  104. smalltalk.TrappedProcessorInputValue);
  105. smalltalk.addMethod(
  106. smalltalk.method({
  107. selector: "toView:",
  108. category: 'data transformation',
  109. fn: function (aDataCarrier){
  110. var self=this;
  111. return smalltalk.withContext(function($ctx1) {
  112. _st(aDataCarrier)._toTargetValue();
  113. return self}, function($ctx1) {$ctx1.fill(self,"toView:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessorInputValue)})},
  114. args: ["aDataCarrier"],
  115. source: "toView: aDataCarrier\x0a\x09aDataCarrier toTargetValue",
  116. messageSends: ["toTargetValue"],
  117. referencedClasses: []
  118. }),
  119. smalltalk.TrappedProcessorInputValue);
  120. smalltalk.addClass('TrappedProcessorBlackboard', smalltalk.TrappedProcessor, [], 'Trapped-Processors');
  121. 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).";
  122. smalltalk.addMethod(
  123. smalltalk.method({
  124. selector: "installToView:toModel:",
  125. category: 'installation',
  126. fn: function (aDataCarrier,anotherDataCarrier){
  127. var self=this;
  128. var snap;
  129. function $KeyedPubSubUnsubscribe(){return smalltalk.KeyedPubSubUnsubscribe||(typeof KeyedPubSubUnsubscribe=="undefined"?nil:KeyedPubSubUnsubscribe)}
  130. return smalltalk.withContext(function($ctx1) {
  131. var $1,$2,$3;
  132. snap=_st(anotherDataCarrier)._target();
  133. $ctx1.sendIdx["target"]=1;
  134. _st(snap)._watch_((function(data){
  135. return smalltalk.withContext(function($ctx2) {
  136. $1=_st(_st(_st(_st(_st(aDataCarrier)._target())._asJQuery())._closest_("html"))._toArray())._isEmpty();
  137. if(smalltalk.assert($1)){
  138. _st($KeyedPubSubUnsubscribe())._signal();
  139. };
  140. return _st(snap)._do_((function(){
  141. return smalltalk.withContext(function($ctx3) {
  142. $2=_st(aDataCarrier)._copy();
  143. _st($2)._value_(data);
  144. $ctx3.sendIdx["value:"]=1;
  145. $3=_st($2)._proceed();
  146. return $3;
  147. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)})}));
  148. }, function($ctx2) {$ctx2.fillBlock({data:data},$ctx1,1)})}));
  149. _st(aDataCarrier)._value_(false);
  150. return self}, function($ctx1) {$ctx1.fill(self,"installToView:toModel:",{aDataCarrier:aDataCarrier,anotherDataCarrier:anotherDataCarrier,snap:snap},smalltalk.TrappedProcessorBlackboard)})},
  151. args: ["aDataCarrier", "anotherDataCarrier"],
  152. 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",
  153. messageSends: ["target", "watch:", "ifTrue:", "isEmpty", "toArray", "closest:", "asJQuery", "signal", "do:", "value:", "copy", "proceed"],
  154. referencedClasses: ["KeyedPubSubUnsubscribe"]
  155. }),
  156. smalltalk.TrappedProcessorBlackboard);
  157. smalltalk.addMethod(
  158. smalltalk.method({
  159. selector: "toModel:",
  160. category: 'data transformation',
  161. fn: function (aDataCarrier){
  162. var self=this;
  163. return smalltalk.withContext(function($ctx1) {
  164. _st(aDataCarrier)._modifyTarget();
  165. return self}, function($ctx1) {$ctx1.fill(self,"toModel:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessorBlackboard)})},
  166. args: ["aDataCarrier"],
  167. source: "toModel: aDataCarrier\x0a\x09aDataCarrier modifyTarget",
  168. messageSends: ["modifyTarget"],
  169. referencedClasses: []
  170. }),
  171. smalltalk.TrappedProcessorBlackboard);
  172. smalltalk.addClass('TrappedProcessorDescend', smalltalk.TrappedProcessor, [], 'Trapped-Processors');
  173. smalltalk.TrappedProcessorDescend.comment="I intepret data-trap in descendants of my brush.";
  174. smalltalk.addMethod(
  175. smalltalk.method({
  176. selector: "toView:",
  177. category: 'data transformation',
  178. fn: function (aDataCarrier){
  179. var self=this;
  180. function $Trapped(){return smalltalk.Trapped||(typeof Trapped=="undefined"?nil:Trapped)}
  181. return smalltalk.withContext(function($ctx1) {
  182. _st(_st($Trapped())._current())._injectToJQuery_(_st(_st(_st(aDataCarrier)._target())._asJQuery())._children());
  183. return self}, function($ctx1) {$ctx1.fill(self,"toView:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessorDescend)})},
  184. args: ["aDataCarrier"],
  185. source: "toView: aDataCarrier\x0a\x09Trapped current injectToJQuery: aDataCarrier target asJQuery children",
  186. messageSends: ["injectToJQuery:", "current", "children", "asJQuery", "target"],
  187. referencedClasses: ["Trapped"]
  188. }),
  189. smalltalk.TrappedProcessorDescend);
  190. smalltalk.addClass('TrappedProcessorGuardBase', smalltalk.TrappedProcessor, ['guardPath'], 'Trapped-Processors');
  191. 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.";
  192. smalltalk.addMethod(
  193. smalltalk.method({
  194. selector: "guardPath:",
  195. category: 'accessing',
  196. fn: function (anArray){
  197. var self=this;
  198. return smalltalk.withContext(function($ctx1) {
  199. self["@guardPath"]=anArray;
  200. return self}, function($ctx1) {$ctx1.fill(self,"guardPath:",{anArray:anArray},smalltalk.TrappedProcessorGuardBase)})},
  201. args: ["anArray"],
  202. source: "guardPath: anArray\x0a\x09guardPath := anArray",
  203. messageSends: [],
  204. referencedClasses: []
  205. }),
  206. smalltalk.TrappedProcessorGuardBase);
  207. smalltalk.addMethod(
  208. smalltalk.method({
  209. selector: "toModel:",
  210. category: 'data transformation',
  211. fn: function (aDataCarrier){
  212. var self=this;
  213. return smalltalk.withContext(function($ctx1) {
  214. return self}, function($ctx1) {$ctx1.fill(self,"toModel:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessorGuardBase)})},
  215. args: ["aDataCarrier"],
  216. source: "toModel: aDataCarrier\x0a\x09\x22stop\x22",
  217. messageSends: [],
  218. referencedClasses: []
  219. }),
  220. smalltalk.TrappedProcessorGuardBase);
  221. smalltalk.addMethod(
  222. smalltalk.method({
  223. selector: "toView:",
  224. category: 'data transformation',
  225. fn: function (aDataCarrier){
  226. var self=this;
  227. return smalltalk.withContext(function($ctx1) {
  228. self._subclassResponsibility();
  229. return self}, function($ctx1) {$ctx1.fill(self,"toView:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessorGuardBase)})},
  230. args: ["aDataCarrier"],
  231. source: "toView: aDataCarrier\x0a\x09self subclassResponsibility",
  232. messageSends: ["subclassResponsibility"],
  233. referencedClasses: []
  234. }),
  235. smalltalk.TrappedProcessorGuardBase);
  236. smalltalk.addMethod(
  237. smalltalk.method({
  238. selector: "new:",
  239. category: 'instance creation',
  240. fn: function (anArray){
  241. var self=this;
  242. return smalltalk.withContext(function($ctx1) {
  243. var $2,$3,$1;
  244. $2=self._new();
  245. _st($2)._guardPath_(anArray);
  246. $3=_st($2)._yourself();
  247. $1=$3;
  248. return $1;
  249. }, function($ctx1) {$ctx1.fill(self,"new:",{anArray:anArray},smalltalk.TrappedProcessorGuardBase.klass)})},
  250. args: ["anArray"],
  251. source: "new: anArray\x0a\x09^ self new\x0a\x09\x09guardPath: anArray;\x0a\x09\x09yourself",
  252. messageSends: ["guardPath:", "new", "yourself"],
  253. referencedClasses: []
  254. }),
  255. smalltalk.TrappedProcessorGuardBase.klass);
  256. smalltalk.addClass('TrappedProcessorGuardContents', smalltalk.TrappedProcessorGuardBase, [], 'Trapped-Processors');
  257. 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.";
  258. smalltalk.addMethod(
  259. smalltalk.method({
  260. selector: "toView:",
  261. category: 'data transformation',
  262. fn: function (aDataCarrier){
  263. var self=this;
  264. var frozen,contents;
  265. function $Trapped(){return smalltalk.Trapped||(typeof Trapped=="undefined"?nil:Trapped)}
  266. return smalltalk.withContext(function($ctx1) {
  267. var $3,$2,$1,$5,$4;
  268. frozen=_st(aDataCarrier)._copy();
  269. $3=_st(frozen)._target();
  270. $ctx1.sendIdx["target"]=1;
  271. $2=_st($3)._asJQuery();
  272. $ctx1.sendIdx["asJQuery"]=1;
  273. $1=_st($2)._contents();
  274. contents=_st($1)._detach();
  275. _st(_st(frozen)._target())._trapGuard_contents_(self["@guardPath"],(function(html){
  276. return smalltalk.withContext(function($ctx2) {
  277. $5=_st(html)._root();
  278. $ctx2.sendIdx["root"]=1;
  279. $4=_st($5)._asJQuery();
  280. $ctx2.sendIdx["asJQuery"]=2;
  281. _st($4)._append_(contents);
  282. return _st(_st($Trapped())._current())._injectToJQuery_(_st(_st(html)._root())._asJQuery());
  283. }, function($ctx2) {$ctx2.fillBlock({html:html},$ctx1,1)})}));
  284. return self}, function($ctx1) {$ctx1.fill(self,"toView:",{aDataCarrier:aDataCarrier,frozen:frozen,contents:contents},smalltalk.TrappedProcessorGuardContents)})},
  285. args: ["aDataCarrier"],
  286. 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 ]",
  287. messageSends: ["copy", "detach", "contents", "asJQuery", "target", "trapGuard:contents:", "append:", "root", "injectToJQuery:", "current"],
  288. referencedClasses: ["Trapped"]
  289. }),
  290. smalltalk.TrappedProcessorGuardContents);
  291. smalltalk.addClass('TrappedProcessorGuardProc', smalltalk.TrappedProcessorGuardBase, [], 'Trapped-Processors');
  292. 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,";
  293. smalltalk.addMethod(
  294. smalltalk.method({
  295. selector: "toView:",
  296. category: 'data transformation',
  297. fn: function (aDataCarrier){
  298. var self=this;
  299. var frozen;
  300. return smalltalk.withContext(function($ctx1) {
  301. frozen=_st(aDataCarrier)._copy();
  302. $ctx1.sendIdx["copy"]=1;
  303. _st(_st(frozen)._target())._trapGuard_contents_(self["@guardPath"],(function(){
  304. return smalltalk.withContext(function($ctx2) {
  305. return _st(_st(frozen)._copy())._proceed();
  306. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  307. return self}, function($ctx1) {$ctx1.fill(self,"toView:",{aDataCarrier:aDataCarrier,frozen:frozen},smalltalk.TrappedProcessorGuardProc)})},
  308. args: ["aDataCarrier"],
  309. source: "toView: aDataCarrier\x0a\x09| frozen |\x0a\x09frozen := aDataCarrier copy.\x0a\x09frozen target trapGuard: guardPath contents: [ frozen copy proceed ]",
  310. messageSends: ["copy", "trapGuard:contents:", "target", "proceed"],
  311. referencedClasses: []
  312. }),
  313. smalltalk.TrappedProcessorGuardProc);
  314. smalltalk.addClass('TrappedProcessorSignal', smalltalk.TrappedProcessor, ['selector'], 'Trapped-Processors');
  315. smalltalk.TrappedProcessorSignal.comment="Instead of writing data directly to model,\x0aI instead modify it by sending a message specified when instantiating me.";
  316. smalltalk.addMethod(
  317. smalltalk.method({
  318. selector: "selector:",
  319. category: 'accessing',
  320. fn: function (aString){
  321. var self=this;
  322. return smalltalk.withContext(function($ctx1) {
  323. self["@selector"]=aString;
  324. return self}, function($ctx1) {$ctx1.fill(self,"selector:",{aString:aString},smalltalk.TrappedProcessorSignal)})},
  325. args: ["aString"],
  326. source: "selector: aString\x0a\x09selector := aString",
  327. messageSends: [],
  328. referencedClasses: []
  329. }),
  330. smalltalk.TrappedProcessorSignal);
  331. smalltalk.addMethod(
  332. smalltalk.method({
  333. selector: "toModel:",
  334. category: 'data transformation',
  335. fn: function (aDataCarrier){
  336. var self=this;
  337. return smalltalk.withContext(function($ctx1) {
  338. _st(aDataCarrier)._modifyTargetByPerforming_(self["@selector"]);
  339. return self}, function($ctx1) {$ctx1.fill(self,"toModel:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessorSignal)})},
  340. args: ["aDataCarrier"],
  341. source: "toModel: aDataCarrier\x0a\x09aDataCarrier modifyTargetByPerforming: selector",
  342. messageSends: ["modifyTargetByPerforming:"],
  343. referencedClasses: []
  344. }),
  345. smalltalk.TrappedProcessorSignal);
  346. smalltalk.addMethod(
  347. smalltalk.method({
  348. selector: "toView:",
  349. category: 'data transformation',
  350. fn: function (aDataCarrier){
  351. var self=this;
  352. return smalltalk.withContext(function($ctx1) {
  353. return self}, function($ctx1) {$ctx1.fill(self,"toView:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessorSignal)})},
  354. args: ["aDataCarrier"],
  355. source: "toView: aDataCarrier\x0a\x09\x22stop\x22",
  356. messageSends: [],
  357. referencedClasses: []
  358. }),
  359. smalltalk.TrappedProcessorSignal);
  360. smalltalk.addMethod(
  361. smalltalk.method({
  362. selector: "new:",
  363. category: 'instance creation',
  364. fn: function (aString){
  365. var self=this;
  366. return smalltalk.withContext(function($ctx1) {
  367. var $2,$3,$1;
  368. $2=self._new();
  369. _st($2)._selector_(aString);
  370. $3=_st($2)._yourself();
  371. $1=$3;
  372. return $1;
  373. }, function($ctx1) {$ctx1.fill(self,"new:",{aString:aString},smalltalk.TrappedProcessorSignal.klass)})},
  374. args: ["aString"],
  375. source: "new: aString\x0a\x09^self new\x0a\x09\x09selector: aString;\x0a\x09\x09yourself",
  376. messageSends: ["selector:", "new", "yourself"],
  377. referencedClasses: []
  378. }),
  379. smalltalk.TrappedProcessorSignal.klass);
  380. smalltalk.addClass('TrappedProcessorTerminator', smalltalk.TrappedProcessor, [], 'Trapped-Processors');
  381. 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).";
  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. return self}, function($ctx1) {$ctx1.fill(self,"toView:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessorTerminator)})},
  390. args: ["aDataCarrier"],
  391. source: "toView: aDataCarrier\x0a\x09\x22stop\x22",
  392. messageSends: [],
  393. referencedClasses: []
  394. }),
  395. smalltalk.TrappedProcessorTerminator);
  396. smalltalk.addClass('TrappedProcessorWhenClicked', smalltalk.TrappedProcessor, [], 'Trapped-Processors');
  397. smalltalk.TrappedProcessorWhenClicked.comment="I bind to an element and send true to blackboard when clicked.";
  398. smalltalk.addMethod(
  399. smalltalk.method({
  400. selector: "installToView:toModel:",
  401. category: 'installation',
  402. fn: function (aDataCarrier,anotherDataCarrier){
  403. var self=this;
  404. return smalltalk.withContext(function($ctx1) {
  405. _st(_st(aDataCarrier)._target())._onClick_((function(){
  406. return smalltalk.withContext(function($ctx2) {
  407. _st(_st(anotherDataCarrier)._copy())._proceed();
  408. return false;
  409. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  410. return self}, function($ctx1) {$ctx1.fill(self,"installToView:toModel:",{aDataCarrier:aDataCarrier,anotherDataCarrier:anotherDataCarrier},smalltalk.TrappedProcessorWhenClicked)})},
  411. args: ["aDataCarrier", "anotherDataCarrier"],
  412. source: "installToView: aDataCarrier toModel: anotherDataCarrier\x0a\x09aDataCarrier target onClick: [ anotherDataCarrier copy proceed. false ]",
  413. messageSends: ["onClick:", "target", "proceed", "copy"],
  414. referencedClasses: []
  415. }),
  416. smalltalk.TrappedProcessorWhenClicked);
  417. smalltalk.addClass('TrappedProcessorWhenSubmitted', smalltalk.TrappedProcessor, [], 'Trapped-Processors');
  418. smalltalk.TrappedProcessorWhenSubmitted.comment="I bind to a form and send true to blackboard when submitted.";
  419. smalltalk.addMethod(
  420. smalltalk.method({
  421. selector: "installToView:toModel:",
  422. category: 'installation',
  423. fn: function (aDataCarrier,anotherDataCarrier){
  424. var self=this;
  425. return smalltalk.withContext(function($ctx1) {
  426. _st(_st(aDataCarrier)._target())._onSubmit_((function(){
  427. return smalltalk.withContext(function($ctx2) {
  428. _st(_st(anotherDataCarrier)._copy())._proceed();
  429. return false;
  430. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  431. return self}, function($ctx1) {$ctx1.fill(self,"installToView:toModel:",{aDataCarrier:aDataCarrier,anotherDataCarrier:anotherDataCarrier},smalltalk.TrappedProcessorWhenSubmitted)})},
  432. args: ["aDataCarrier", "anotherDataCarrier"],
  433. source: "installToView: aDataCarrier toModel: anotherDataCarrier\x0a\x09aDataCarrier target onSubmit: [ anotherDataCarrier copy proceed. false ]",
  434. messageSends: ["onSubmit:", "target", "proceed", "copy"],
  435. referencedClasses: []
  436. }),
  437. smalltalk.TrappedProcessorWhenSubmitted);
  438. smalltalk.addClass('TrappedProcessorWidget', smalltalk.TrappedProcessor, ['viewName'], 'Trapped-Processors');
  439. smalltalk.TrappedProcessorWidget.comment="I insert a widget instance of the class specified when creating me.";
  440. smalltalk.addMethod(
  441. smalltalk.method({
  442. selector: "toView:",
  443. category: 'data transformation',
  444. fn: function (aDataCarrier){
  445. var self=this;
  446. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  447. return smalltalk.withContext(function($ctx1) {
  448. _st(_st(aDataCarrier)._target())._with_(_st(_st(_st($Smalltalk())._current())._at_(self["@viewName"]))._new());
  449. return self}, function($ctx1) {$ctx1.fill(self,"toView:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessorWidget)})},
  450. args: ["aDataCarrier"],
  451. source: "toView: aDataCarrier\x0a\x09aDataCarrier target with: (Smalltalk current at: viewName) new",
  452. messageSends: ["with:", "target", "new", "at:", "current"],
  453. referencedClasses: ["Smalltalk"]
  454. }),
  455. smalltalk.TrappedProcessorWidget);
  456. smalltalk.addMethod(
  457. smalltalk.method({
  458. selector: "viewName:",
  459. category: 'accessing',
  460. fn: function (aString){
  461. var self=this;
  462. return smalltalk.withContext(function($ctx1) {
  463. self["@viewName"]=aString;
  464. return self}, function($ctx1) {$ctx1.fill(self,"viewName:",{aString:aString},smalltalk.TrappedProcessorWidget)})},
  465. args: ["aString"],
  466. source: "viewName: aString\x0a\x09viewName := aString",
  467. messageSends: [],
  468. referencedClasses: []
  469. }),
  470. smalltalk.TrappedProcessorWidget);
  471. smalltalk.addMethod(
  472. smalltalk.method({
  473. selector: "new:",
  474. category: 'instance creation',
  475. fn: function (aString){
  476. var self=this;
  477. return smalltalk.withContext(function($ctx1) {
  478. var $2,$3,$1;
  479. $2=self._new();
  480. _st($2)._viewName_(aString);
  481. $3=_st($2)._yourself();
  482. $1=$3;
  483. return $1;
  484. }, function($ctx1) {$ctx1.fill(self,"new:",{aString:aString},smalltalk.TrappedProcessorWidget.klass)})},
  485. args: ["aString"],
  486. source: "new: aString\x0a\x09^self new\x0a\x09\x09viewName: aString;\x0a\x09\x09yourself",
  487. messageSends: ["viewName:", "new", "yourself"],
  488. referencedClasses: []
  489. }),
  490. smalltalk.TrappedProcessorWidget.klass);
  491. smalltalk.addMethod(
  492. smalltalk.method({
  493. selector: "modifyTarget",
  494. category: '*Trapped-Processors',
  495. fn: function (){
  496. var self=this;
  497. return smalltalk.withContext(function($ctx1) {
  498. _st(self._target())._modify_((function(){
  499. return smalltalk.withContext(function($ctx2) {
  500. return self._value();
  501. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  502. return self}, function($ctx1) {$ctx1.fill(self,"modifyTarget",{},smalltalk.TrappedDataCarrier)})},
  503. args: [],
  504. source: "modifyTarget\x0a\x09self target modify: [ self value ]",
  505. messageSends: ["modify:", "target", "value"],
  506. referencedClasses: []
  507. }),
  508. smalltalk.TrappedDataCarrier);
  509. smalltalk.addMethod(
  510. smalltalk.method({
  511. selector: "modifyTargetByPerforming:",
  512. category: '*Trapped-Processors',
  513. fn: function (aString){
  514. var self=this;
  515. return smalltalk.withContext(function($ctx1) {
  516. _st(self._target())._modify_((function(m){
  517. return smalltalk.withContext(function($ctx2) {
  518. return _st(m)._perform_(aString);
  519. }, function($ctx2) {$ctx2.fillBlock({m:m},$ctx1,1)})}));
  520. return self}, function($ctx1) {$ctx1.fill(self,"modifyTargetByPerforming:",{aString:aString},smalltalk.TrappedDataCarrier)})},
  521. args: ["aString"],
  522. source: "modifyTargetByPerforming: aString\x0a\x09self target modify: [ :m | m perform: aString ]",
  523. messageSends: ["modify:", "target", "perform:"],
  524. referencedClasses: []
  525. }),
  526. smalltalk.TrappedDataCarrier);
  527. smalltalk.addMethod(
  528. smalltalk.method({
  529. selector: "toTargetAttr:",
  530. category: '*Trapped-Processors',
  531. fn: function (aString){
  532. var self=this;
  533. return smalltalk.withContext(function($ctx1) {
  534. var $1,$3,$2;
  535. $1=_st(self._target())._asJQuery();
  536. $3=self._value();
  537. $ctx1.sendIdx["value"]=1;
  538. if(($receiver = $3) == nil || $receiver == null){
  539. $2=(function(){
  540. return smalltalk.withContext(function($ctx2) {
  541. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})});
  542. } else {
  543. var o;
  544. o=$receiver;
  545. $2=_st(o)._value();
  546. };
  547. _st($1)._attr_put_(aString,$2);
  548. return self}, function($ctx1) {$ctx1.fill(self,"toTargetAttr:",{aString:aString},smalltalk.TrappedDataCarrier)})},
  549. args: ["aString"],
  550. source: "toTargetAttr: aString\x0a\x09self target asJQuery attr: aString put: (self value ifNotNil: [ :o | o value ] ifNil: [[]])",
  551. messageSends: ["attr:put:", "asJQuery", "target", "ifNotNil:ifNil:", "value"],
  552. referencedClasses: []
  553. }),
  554. smalltalk.TrappedDataCarrier);
  555. smalltalk.addMethod(
  556. smalltalk.method({
  557. selector: "toTargetContents",
  558. category: '*Trapped-Processors',
  559. fn: function (){
  560. var self=this;
  561. return smalltalk.withContext(function($ctx1) {
  562. _st(self._target())._contents_(self._value());
  563. return self}, function($ctx1) {$ctx1.fill(self,"toTargetContents",{},smalltalk.TrappedDataCarrier)})},
  564. args: [],
  565. source: "toTargetContents\x0a\x09self target contents: self value",
  566. messageSends: ["contents:", "target", "value"],
  567. referencedClasses: []
  568. }),
  569. smalltalk.TrappedDataCarrier);
  570. smalltalk.addMethod(
  571. smalltalk.method({
  572. selector: "toTargetValue",
  573. category: '*Trapped-Processors',
  574. fn: function (){
  575. var self=this;
  576. return smalltalk.withContext(function($ctx1) {
  577. var $1,$3,$2;
  578. $1=_st(self._target())._asJQuery();
  579. $3=self._value();
  580. $ctx1.sendIdx["value"]=1;
  581. if(($receiver = $3) == nil || $receiver == null){
  582. $2=(function(){
  583. return smalltalk.withContext(function($ctx2) {
  584. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})});
  585. } else {
  586. var o;
  587. o=$receiver;
  588. $2=_st(o)._value();
  589. };
  590. _st($1)._val_($2);
  591. return self}, function($ctx1) {$ctx1.fill(self,"toTargetValue",{},smalltalk.TrappedDataCarrier)})},
  592. args: [],
  593. source: "toTargetValue\x0a\x09self target asJQuery val: (self value ifNotNil: [ :o | o value ] ifNil: [[]])",
  594. messageSends: ["val:", "asJQuery", "target", "ifNotNil:ifNil:", "value"],
  595. referencedClasses: []
  596. }),
  597. smalltalk.TrappedDataCarrier);
  598. });