Trapped-Frontend.js 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371
  1. define("gh_herby_trapped/Trapped-Frontend", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_core/Kernel-Objects", "amber_core/Kernel-Collections", "amber_core/Canvas"], function(smalltalk,nil,_st){
  2. smalltalk.addPackage('Trapped-Frontend');
  3. smalltalk.packages["Trapped-Frontend"].transport = {"type":"amd","amdNamespace":"gh_herby_trapped"};
  4. smalltalk.addClass('TrappedDataCarrier', smalltalk.Object, ['target', 'model', 'chain'], 'Trapped-Frontend');
  5. smalltalk.addMethod(
  6. smalltalk.method({
  7. selector: "chain:",
  8. category: 'accessing',
  9. fn: function (aProcessingChain){
  10. var self=this;
  11. return smalltalk.withContext(function($ctx1) {
  12. self["@chain"]=aProcessingChain;
  13. return self}, function($ctx1) {$ctx1.fill(self,"chain:",{aProcessingChain:aProcessingChain},smalltalk.TrappedDataCarrier)})},
  14. args: ["aProcessingChain"],
  15. source: "chain: aProcessingChain\x0a\x09chain := aProcessingChain",
  16. messageSends: [],
  17. referencedClasses: []
  18. }),
  19. smalltalk.TrappedDataCarrier);
  20. smalltalk.addMethod(
  21. smalltalk.method({
  22. selector: "initialize",
  23. category: 'initialization',
  24. fn: function (){
  25. var self=this;
  26. return smalltalk.withContext(function($ctx1) {
  27. smalltalk.TrappedDataCarrier.superclass.fn.prototype._initialize.apply(_st(self), []);
  28. self["@model"]=true;
  29. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.TrappedDataCarrier)})},
  30. args: [],
  31. source: "initialize\x0a\x09super initialize.\x0a\x09model := true",
  32. messageSends: ["initialize"],
  33. referencedClasses: []
  34. }),
  35. smalltalk.TrappedDataCarrier);
  36. smalltalk.addMethod(
  37. smalltalk.method({
  38. selector: "target",
  39. category: 'accessing',
  40. fn: function (){
  41. var self=this;
  42. return smalltalk.withContext(function($ctx1) {
  43. var $1;
  44. $1=self["@target"];
  45. return $1;
  46. }, function($ctx1) {$ctx1.fill(self,"target",{},smalltalk.TrappedDataCarrier)})},
  47. args: [],
  48. source: "target\x0a\x09^target",
  49. messageSends: [],
  50. referencedClasses: []
  51. }),
  52. smalltalk.TrappedDataCarrier);
  53. smalltalk.addMethod(
  54. smalltalk.method({
  55. selector: "target:",
  56. category: 'accessing',
  57. fn: function (anObject){
  58. var self=this;
  59. return smalltalk.withContext(function($ctx1) {
  60. self["@target"]=anObject;
  61. return self}, function($ctx1) {$ctx1.fill(self,"target:",{anObject:anObject},smalltalk.TrappedDataCarrier)})},
  62. args: ["anObject"],
  63. source: "target: anObject\x0a\x09target := anObject",
  64. messageSends: [],
  65. referencedClasses: []
  66. }),
  67. smalltalk.TrappedDataCarrier);
  68. smalltalk.addMethod(
  69. smalltalk.method({
  70. selector: "value",
  71. category: 'accessing',
  72. fn: function (){
  73. var self=this;
  74. return smalltalk.withContext(function($ctx1) {
  75. var $1;
  76. $1=self["@model"];
  77. return $1;
  78. }, function($ctx1) {$ctx1.fill(self,"value",{},smalltalk.TrappedDataCarrier)})},
  79. args: [],
  80. source: "value\x0a\x09^model",
  81. messageSends: [],
  82. referencedClasses: []
  83. }),
  84. smalltalk.TrappedDataCarrier);
  85. smalltalk.addMethod(
  86. smalltalk.method({
  87. selector: "value:",
  88. category: 'accessing',
  89. fn: function (anObject){
  90. var self=this;
  91. return smalltalk.withContext(function($ctx1) {
  92. self["@model"]=anObject;
  93. return self}, function($ctx1) {$ctx1.fill(self,"value:",{anObject:anObject},smalltalk.TrappedDataCarrier)})},
  94. args: ["anObject"],
  95. source: "value: anObject\x0a\x09model := anObject",
  96. messageSends: [],
  97. referencedClasses: []
  98. }),
  99. smalltalk.TrappedDataCarrier);
  100. smalltalk.addMethod(
  101. smalltalk.method({
  102. selector: "on:target:",
  103. category: 'not yet classified',
  104. fn: function (aProcessingChain,anObject){
  105. var self=this;
  106. return smalltalk.withContext(function($ctx1) {
  107. var $2,$3,$1;
  108. $2=self._new();
  109. _st($2)._chain_(aProcessingChain);
  110. _st($2)._target_(anObject);
  111. $3=_st($2)._yourself();
  112. $1=$3;
  113. return $1;
  114. }, function($ctx1) {$ctx1.fill(self,"on:target:",{aProcessingChain:aProcessingChain,anObject:anObject},smalltalk.TrappedDataCarrier.klass)})},
  115. args: ["aProcessingChain", "anObject"],
  116. source: "on: aProcessingChain target: anObject\x0a\x09^self new\x0a\x09\x09chain: aProcessingChain;\x0a\x09\x09target: anObject;\x0a\x09\x09yourself",
  117. messageSends: ["chain:", "new", "target:", "yourself"],
  118. referencedClasses: []
  119. }),
  120. smalltalk.TrappedDataCarrier.klass);
  121. smalltalk.addClass('TrappedDataCarrierToModel', smalltalk.TrappedDataCarrier, ['index'], 'Trapped-Frontend');
  122. smalltalk.addMethod(
  123. smalltalk.method({
  124. selector: "proceed",
  125. category: 'not yet classified',
  126. fn: function (){
  127. var self=this;
  128. return smalltalk.withContext(function($ctx1) {
  129. var $1;
  130. $1=self["@index"];
  131. if(($receiver = $1) == nil || $receiver == null){
  132. self["@index"]=_st(self["@chain"])._lastProcessorNo();
  133. } else {
  134. self["@index"]=_st(self["@index"]).__minus((1));
  135. };
  136. _st(_st(self["@chain"])._processorNo_(self["@index"]))._toModel_(self);
  137. return self}, function($ctx1) {$ctx1.fill(self,"proceed",{},smalltalk.TrappedDataCarrierToModel)})},
  138. args: [],
  139. source: "proceed\x0a\x09index := index ifNil: [ chain lastProcessorNo ] ifNotNil: [ index - 1 ].\x0a\x09(chain processorNo: index) toModel: self",
  140. messageSends: ["ifNil:ifNotNil:", "lastProcessorNo", "-", "toModel:", "processorNo:"],
  141. referencedClasses: []
  142. }),
  143. smalltalk.TrappedDataCarrierToModel);
  144. smalltalk.addClass('TrappedDataCarrierToView', smalltalk.TrappedDataCarrier, ['index'], 'Trapped-Frontend');
  145. smalltalk.addMethod(
  146. smalltalk.method({
  147. selector: "proceed",
  148. category: 'not yet classified',
  149. fn: function (){
  150. var self=this;
  151. return smalltalk.withContext(function($ctx1) {
  152. var $1;
  153. $1=self["@index"];
  154. if(($receiver = $1) == nil || $receiver == null){
  155. self["@index"]=_st(self["@chain"])._firstProcessorNo();
  156. } else {
  157. self["@index"]=_st(self["@index"]).__plus((1));
  158. };
  159. _st(_st(self["@chain"])._processorNo_(self["@index"]))._toView_(self);
  160. return self}, function($ctx1) {$ctx1.fill(self,"proceed",{},smalltalk.TrappedDataCarrierToView)})},
  161. args: [],
  162. source: "proceed\x0a\x09index := index ifNil: [ chain firstProcessorNo ] ifNotNil: [ index + 1 ].\x0a\x09(chain processorNo: index) toView: self",
  163. messageSends: ["ifNil:ifNotNil:", "firstProcessorNo", "+", "toView:", "processorNo:"],
  164. referencedClasses: []
  165. }),
  166. smalltalk.TrappedDataCarrierToView);
  167. smalltalk.addClass('TrappedProcessingChain', smalltalk.Object, ['processors'], 'Trapped-Frontend');
  168. smalltalk.addMethod(
  169. smalltalk.method({
  170. selector: "firstProcessorNo",
  171. category: 'accessing',
  172. fn: function (){
  173. var self=this;
  174. return smalltalk.withContext(function($ctx1) {
  175. return (1);
  176. }, function($ctx1) {$ctx1.fill(self,"firstProcessorNo",{},smalltalk.TrappedProcessingChain)})},
  177. args: [],
  178. source: "firstProcessorNo\x0a\x09^1",
  179. messageSends: [],
  180. referencedClasses: []
  181. }),
  182. smalltalk.TrappedProcessingChain);
  183. smalltalk.addMethod(
  184. smalltalk.method({
  185. selector: "forSnapshot:andBrush:",
  186. category: 'action',
  187. fn: function (aSnapshot,aTagBrush){
  188. var self=this;
  189. var toViewCarrier,toModelCarrier;
  190. function $TrappedDataCarrierToView(){return smalltalk.TrappedDataCarrierToView||(typeof TrappedDataCarrierToView=="undefined"?nil:TrappedDataCarrierToView)}
  191. function $TrappedDataCarrierToModel(){return smalltalk.TrappedDataCarrierToModel||(typeof TrappedDataCarrierToModel=="undefined"?nil:TrappedDataCarrierToModel)}
  192. return smalltalk.withContext(function($ctx1) {
  193. var $1;
  194. toViewCarrier=_st($TrappedDataCarrierToView())._on_target_(self,aTagBrush);
  195. $ctx1.sendIdx["on:target:"]=1;
  196. toModelCarrier=_st($TrappedDataCarrierToModel())._on_target_(self,aSnapshot);
  197. _st(self["@processors"])._do_((function(each){
  198. return smalltalk.withContext(function($ctx2) {
  199. return _st(each)._installToView_toModel_(toViewCarrier,toModelCarrier);
  200. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  201. $1=_st(_st(toViewCarrier)._value()).__eq(true);
  202. if(smalltalk.assert($1)){
  203. _st(_st(toViewCarrier)._copy())._proceed();
  204. };
  205. return self}, function($ctx1) {$ctx1.fill(self,"forSnapshot:andBrush:",{aSnapshot:aSnapshot,aTagBrush:aTagBrush,toViewCarrier:toViewCarrier,toModelCarrier:toModelCarrier},smalltalk.TrappedProcessingChain)})},
  206. args: ["aSnapshot", "aTagBrush"],
  207. source: "forSnapshot: aSnapshot andBrush: aTagBrush\x0a\x09| toViewCarrier toModelCarrier |\x0a\x09toViewCarrier := TrappedDataCarrierToView on: self target: aTagBrush.\x0a\x09toModelCarrier := TrappedDataCarrierToModel on: self target: aSnapshot.\x0a\x09processors do: [ :each | each installToView: toViewCarrier toModel: toModelCarrier ].\x0a\x09toViewCarrier value = true ifTrue: [ toViewCarrier copy proceed ]",
  208. messageSends: ["on:target:", "do:", "installToView:toModel:", "ifTrue:", "=", "value", "proceed", "copy"],
  209. referencedClasses: ["TrappedDataCarrierToView", "TrappedDataCarrierToModel"]
  210. }),
  211. smalltalk.TrappedProcessingChain);
  212. smalltalk.addMethod(
  213. smalltalk.method({
  214. selector: "lastProcessorNo",
  215. category: 'accessing',
  216. fn: function (){
  217. var self=this;
  218. return smalltalk.withContext(function($ctx1) {
  219. var $1;
  220. $1=_st(self["@processors"])._size();
  221. return $1;
  222. }, function($ctx1) {$ctx1.fill(self,"lastProcessorNo",{},smalltalk.TrappedProcessingChain)})},
  223. args: [],
  224. source: "lastProcessorNo\x0a\x09^processors size",
  225. messageSends: ["size"],
  226. referencedClasses: []
  227. }),
  228. smalltalk.TrappedProcessingChain);
  229. smalltalk.addMethod(
  230. smalltalk.method({
  231. selector: "processorNo:",
  232. category: 'accessing',
  233. fn: function (aNumber){
  234. var self=this;
  235. return smalltalk.withContext(function($ctx1) {
  236. var $1;
  237. $1=_st(self["@processors"])._at_(aNumber);
  238. return $1;
  239. }, function($ctx1) {$ctx1.fill(self,"processorNo:",{aNumber:aNumber},smalltalk.TrappedProcessingChain)})},
  240. args: ["aNumber"],
  241. source: "processorNo: aNumber\x0a\x09^processors at: aNumber",
  242. messageSends: ["at:"],
  243. referencedClasses: []
  244. }),
  245. smalltalk.TrappedProcessingChain);
  246. smalltalk.addMethod(
  247. smalltalk.method({
  248. selector: "processors:",
  249. category: 'accessing',
  250. fn: function (anArray){
  251. var self=this;
  252. return smalltalk.withContext(function($ctx1) {
  253. self["@processors"]=anArray;
  254. return self}, function($ctx1) {$ctx1.fill(self,"processors:",{anArray:anArray},smalltalk.TrappedProcessingChain)})},
  255. args: ["anArray"],
  256. source: "processors: anArray\x0a\x09processors := anArray",
  257. messageSends: [],
  258. referencedClasses: []
  259. }),
  260. smalltalk.TrappedProcessingChain);
  261. smalltalk.addMethod(
  262. smalltalk.method({
  263. selector: "blackboardReaderWriter",
  264. category: 'private',
  265. fn: function (){
  266. var self=this;
  267. function $TrappedProcessorBlackboard(){return smalltalk.TrappedProcessorBlackboard||(typeof TrappedProcessorBlackboard=="undefined"?nil:TrappedProcessorBlackboard)}
  268. return smalltalk.withContext(function($ctx1) {
  269. var $1;
  270. $1=_st($TrappedProcessorBlackboard())._new();
  271. return $1;
  272. }, function($ctx1) {$ctx1.fill(self,"blackboardReaderWriter",{},smalltalk.TrappedProcessingChain.klass)})},
  273. args: [],
  274. source: "blackboardReaderWriter\x0a\x09^TrappedProcessorBlackboard new",
  275. messageSends: ["new"],
  276. referencedClasses: ["TrappedProcessorBlackboard"]
  277. }),
  278. smalltalk.TrappedProcessingChain.klass);
  279. smalltalk.addMethod(
  280. smalltalk.method({
  281. selector: "dataTerminator",
  282. category: 'private',
  283. fn: function (){
  284. var self=this;
  285. function $TrappedProcessorTerminator(){return smalltalk.TrappedProcessorTerminator||(typeof TrappedProcessorTerminator=="undefined"?nil:TrappedProcessorTerminator)}
  286. return smalltalk.withContext(function($ctx1) {
  287. var $1;
  288. $1=_st($TrappedProcessorTerminator())._new();
  289. return $1;
  290. }, function($ctx1) {$ctx1.fill(self,"dataTerminator",{},smalltalk.TrappedProcessingChain.klass)})},
  291. args: [],
  292. source: "dataTerminator\x0a\x09^TrappedProcessorTerminator new",
  293. messageSends: ["new"],
  294. referencedClasses: ["TrappedProcessorTerminator"]
  295. }),
  296. smalltalk.TrappedProcessingChain.klass);
  297. smalltalk.addMethod(
  298. smalltalk.method({
  299. selector: "new:",
  300. category: 'instance creation',
  301. fn: function (anArray){
  302. var self=this;
  303. return smalltalk.withContext(function($ctx1) {
  304. var $1,$3,$4,$2;
  305. $1=_st(anArray)._anySatisfy_((function(each){
  306. return smalltalk.withContext(function($ctx2) {
  307. return _st(each)._isExpectingModelData();
  308. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  309. if(smalltalk.assert($1)){
  310. _st(anArray)._addFirst_(self._blackboardReaderWriter());
  311. } else {
  312. _st(anArray)._add_(self._dataTerminator());
  313. };
  314. $3=self._new();
  315. _st($3)._processors_(anArray);
  316. $4=_st($3)._yourself();
  317. $2=$4;
  318. return $2;
  319. }, function($ctx1) {$ctx1.fill(self,"new:",{anArray:anArray},smalltalk.TrappedProcessingChain.klass)})},
  320. args: ["anArray"],
  321. source: "new: anArray\x0a\x09(anArray anySatisfy: [ :each | each isExpectingModelData ])\x0a\x09\x09ifFalse: [ anArray add: self dataTerminator ]\x0a\x09\x09ifTrue: [ anArray addFirst: self blackboardReaderWriter ].\x0a\x09^self new\x0a\x09\x09processors: anArray;\x0a\x09\x09yourself",
  322. messageSends: ["ifFalse:ifTrue:", "anySatisfy:", "isExpectingModelData", "add:", "dataTerminator", "addFirst:", "blackboardReaderWriter", "processors:", "new", "yourself"],
  323. referencedClasses: []
  324. }),
  325. smalltalk.TrappedProcessingChain.klass);
  326. smalltalk.addMethod(
  327. smalltalk.method({
  328. selector: "newFromProcessorSpecs:",
  329. category: 'instance creation',
  330. fn: function (anArray){
  331. var self=this;
  332. function $TrappedProcessor(){return smalltalk.TrappedProcessor||(typeof TrappedProcessor=="undefined"?nil:TrappedProcessor)}
  333. return smalltalk.withContext(function($ctx1) {
  334. var $2,$3,$1;
  335. $1=self._new_(_st(_st(anArray)._ifEmpty_((function(){
  336. return smalltalk.withContext(function($ctx2) {
  337. return ["contents"];
  338. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})})))._collect_((function(each){
  339. return smalltalk.withContext(function($ctx2) {
  340. $2=_st(each)._isString();
  341. if(smalltalk.assert($2)){
  342. return _st($TrappedProcessor())._perform_(each);
  343. } else {
  344. var selector,args;
  345. selector="";
  346. selector;
  347. args=[];
  348. args;
  349. _st(each)._withIndexDo_((function(element,index){
  350. return smalltalk.withContext(function($ctx3) {
  351. $3=_st(index)._odd();
  352. if(smalltalk.assert($3)){
  353. selector=_st(selector).__comma(element);
  354. $ctx3.sendIdx[","]=1;
  355. return selector;
  356. } else {
  357. selector=_st(selector).__comma(":");
  358. selector;
  359. return _st(args)._add_(element);
  360. };
  361. }, function($ctx3) {$ctx3.fillBlock({element:element,index:index},$ctx2,5)})}));
  362. return _st($TrappedProcessor())._perform_withArguments_(selector,args);
  363. };
  364. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})})));
  365. return $1;
  366. }, function($ctx1) {$ctx1.fill(self,"newFromProcessorSpecs:",{anArray:anArray},smalltalk.TrappedProcessingChain.klass)})},
  367. args: ["anArray"],
  368. source: "newFromProcessorSpecs: anArray\x0a\x09^self new: ((anArray ifEmpty: [ #(contents) ]) collect: [ :each | each isString\x0a\x09\x09ifTrue: [ TrappedProcessor perform: each ]\x0a\x09\x09ifFalse: [\x0a\x09\x09\x09| selector args |\x0a\x09\x09\x09selector := ''.\x0a\x09\x09\x09args := #().\x0a\x09\x09\x09each withIndexDo: [ :element :index | index odd\x0a\x09\x09\x09\x09ifTrue: [ selector := selector, element ]\x0a\x09\x09\x09\x09ifFalse: [ selector := selector, ':'. args add: element ] ].\x0a\x09\x09\x09TrappedProcessor perform: selector withArguments: args ] ])",
  369. messageSends: ["new:", "collect:", "ifEmpty:", "ifTrue:ifFalse:", "isString", "perform:", "withIndexDo:", "odd", ",", "add:", "perform:withArguments:"],
  370. referencedClasses: ["TrappedProcessor"]
  371. }),
  372. smalltalk.TrappedProcessingChain.klass);
  373. smalltalk.addClass('TrappedProcessor', smalltalk.Object, [], 'Trapped-Frontend');
  374. smalltalk.TrappedProcessor.comment="I am a processing step in TrappedProcessingChain.\x0aI am stateless flyweight (aka servant)\x0aand will get all necessary data as arguments in API calls.\x0a\x0aMy public API is:\x0a - installToView:toModel:\x0a This gets two TrappedDataCarriers set up without actual data\x0a and at the beginning of their chains. It should do one-time\x0a installation task needed (install event handlers etc.).\x0a To start a chain, do: dataCarrier copy value: data; proceed.\x0a - toView:\x0a This performs transformation of TrappedDataCarrier on its way from model to view.\x0a Should call aDataCarrier proceed to proceed to subsequent step.\x0a - toModel:\x0a This performs transformation of TrappedDataCarrier on its way from view to model.\x0a Should call aDataCarrier proceed to proceed to subsequent step.\x0a";
  375. smalltalk.addMethod(
  376. smalltalk.method({
  377. selector: "installToView:toModel:",
  378. category: 'installation',
  379. fn: function (aDataCarrier,anotherDataCarrier){
  380. var self=this;
  381. return smalltalk.withContext(function($ctx1) {
  382. return self}, function($ctx1) {$ctx1.fill(self,"installToView:toModel:",{aDataCarrier:aDataCarrier,anotherDataCarrier:anotherDataCarrier},smalltalk.TrappedProcessor)})},
  383. args: ["aDataCarrier", "anotherDataCarrier"],
  384. source: "installToView: aDataCarrier toModel: anotherDataCarrier\x0a\x09\x22by default, do nothing\x22",
  385. messageSends: [],
  386. referencedClasses: []
  387. }),
  388. smalltalk.TrappedProcessor);
  389. smalltalk.addMethod(
  390. smalltalk.method({
  391. selector: "isExpectingModelData",
  392. category: 'testing',
  393. fn: function (){
  394. var self=this;
  395. return smalltalk.withContext(function($ctx1) {
  396. return false;
  397. }, function($ctx1) {$ctx1.fill(self,"isExpectingModelData",{},smalltalk.TrappedProcessor)})},
  398. args: [],
  399. source: "isExpectingModelData\x0a\x09^false",
  400. messageSends: [],
  401. referencedClasses: []
  402. }),
  403. smalltalk.TrappedProcessor);
  404. smalltalk.addMethod(
  405. smalltalk.method({
  406. selector: "toModel:",
  407. category: 'data transformation',
  408. fn: function (aDataCarrier){
  409. var self=this;
  410. return smalltalk.withContext(function($ctx1) {
  411. _st(aDataCarrier)._proceed();
  412. return self}, function($ctx1) {$ctx1.fill(self,"toModel:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessor)})},
  413. args: ["aDataCarrier"],
  414. source: "toModel: aDataCarrier\x0a\x09\x22by default, proceed\x22\x0a\x09aDataCarrier proceed",
  415. messageSends: ["proceed"],
  416. referencedClasses: []
  417. }),
  418. smalltalk.TrappedProcessor);
  419. smalltalk.addMethod(
  420. smalltalk.method({
  421. selector: "toView:",
  422. category: 'data transformation',
  423. fn: function (aDataCarrier){
  424. var self=this;
  425. return smalltalk.withContext(function($ctx1) {
  426. _st(aDataCarrier)._proceed();
  427. return self}, function($ctx1) {$ctx1.fill(self,"toView:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessor)})},
  428. args: ["aDataCarrier"],
  429. source: "toView: aDataCarrier\x0a\x09\x22by default, proceed\x22\x0a\x09aDataCarrier proceed",
  430. messageSends: ["proceed"],
  431. referencedClasses: []
  432. }),
  433. smalltalk.TrappedProcessor);
  434. smalltalk.addMethod(
  435. smalltalk.method({
  436. selector: "contents",
  437. category: 'factory',
  438. fn: function (){
  439. var self=this;
  440. function $TrappedProcessorContents(){return smalltalk.TrappedProcessorContents||(typeof TrappedProcessorContents=="undefined"?nil:TrappedProcessorContents)}
  441. return smalltalk.withContext(function($ctx1) {
  442. var $1;
  443. $1=_st($TrappedProcessorContents())._new();
  444. return $1;
  445. }, function($ctx1) {$ctx1.fill(self,"contents",{},smalltalk.TrappedProcessor.klass)})},
  446. args: [],
  447. source: "contents\x0a\x09^TrappedProcessorContents new",
  448. messageSends: ["new"],
  449. referencedClasses: ["TrappedProcessorContents"]
  450. }),
  451. smalltalk.TrappedProcessor.klass);
  452. smalltalk.addClass('TrappedDataExpectingProcessor', smalltalk.TrappedProcessor, [], 'Trapped-Frontend');
  453. 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).";
  454. smalltalk.addMethod(
  455. smalltalk.method({
  456. selector: "isExpectingModelData",
  457. category: 'testing',
  458. fn: function (){
  459. var self=this;
  460. return smalltalk.withContext(function($ctx1) {
  461. return true;
  462. }, function($ctx1) {$ctx1.fill(self,"isExpectingModelData",{},smalltalk.TrappedDataExpectingProcessor)})},
  463. args: [],
  464. source: "isExpectingModelData\x0a\x09^true",
  465. messageSends: [],
  466. referencedClasses: []
  467. }),
  468. smalltalk.TrappedDataExpectingProcessor);
  469. smalltalk.addClass('TrappedProcessorContents', smalltalk.TrappedDataExpectingProcessor, [], 'Trapped-Frontend');
  470. smalltalk.TrappedProcessorContents.comment="I put data into target via contents: in toView:";
  471. smalltalk.addMethod(
  472. smalltalk.method({
  473. selector: "toView:",
  474. category: 'data transformation',
  475. fn: function (aDataCarrier){
  476. var self=this;
  477. return smalltalk.withContext(function($ctx1) {
  478. _st(aDataCarrier)._toTargetContents();
  479. return self}, function($ctx1) {$ctx1.fill(self,"toView:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessorContents)})},
  480. args: ["aDataCarrier"],
  481. source: "toView: aDataCarrier\x0a\x09aDataCarrier toTargetContents",
  482. messageSends: ["toTargetContents"],
  483. referencedClasses: []
  484. }),
  485. smalltalk.TrappedProcessorContents);
  486. smalltalk.addClass('TrappedProcessorBlackboard', smalltalk.TrappedProcessor, [], 'Trapped-Frontend');
  487. 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).";
  488. smalltalk.addMethod(
  489. smalltalk.method({
  490. selector: "installToView:toModel:",
  491. category: 'installation',
  492. fn: function (aDataCarrier,anotherDataCarrier){
  493. var self=this;
  494. var snap;
  495. function $KeyedPubSubUnsubscribe(){return smalltalk.KeyedPubSubUnsubscribe||(typeof KeyedPubSubUnsubscribe=="undefined"?nil:KeyedPubSubUnsubscribe)}
  496. return smalltalk.withContext(function($ctx1) {
  497. var $1,$2,$3;
  498. snap=_st(anotherDataCarrier)._target();
  499. $ctx1.sendIdx["target"]=1;
  500. _st(snap)._watch_((function(data){
  501. return smalltalk.withContext(function($ctx2) {
  502. $1=_st(_st(_st(_st(_st(aDataCarrier)._target())._asJQuery())._closest_("html"))._toArray())._isEmpty();
  503. if(smalltalk.assert($1)){
  504. _st($KeyedPubSubUnsubscribe())._signal();
  505. };
  506. return _st(snap)._do_((function(){
  507. return smalltalk.withContext(function($ctx3) {
  508. $2=_st(aDataCarrier)._copy();
  509. _st($2)._value_(data);
  510. $ctx3.sendIdx["value:"]=1;
  511. $3=_st($2)._proceed();
  512. return $3;
  513. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)})}));
  514. }, function($ctx2) {$ctx2.fillBlock({data:data},$ctx1,1)})}));
  515. _st(aDataCarrier)._value_(false);
  516. return self}, function($ctx1) {$ctx1.fill(self,"installToView:toModel:",{aDataCarrier:aDataCarrier,anotherDataCarrier:anotherDataCarrier,snap:snap},smalltalk.TrappedProcessorBlackboard)})},
  517. args: ["aDataCarrier", "anotherDataCarrier"],
  518. 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",
  519. messageSends: ["target", "watch:", "ifTrue:", "isEmpty", "toArray", "closest:", "asJQuery", "signal", "do:", "value:", "copy", "proceed"],
  520. referencedClasses: ["KeyedPubSubUnsubscribe"]
  521. }),
  522. smalltalk.TrappedProcessorBlackboard);
  523. smalltalk.addMethod(
  524. smalltalk.method({
  525. selector: "toModel:",
  526. category: 'data transformation',
  527. fn: function (aDataCarrier){
  528. var self=this;
  529. return smalltalk.withContext(function($ctx1) {
  530. _st(aDataCarrier)._modifyTarget();
  531. return self}, function($ctx1) {$ctx1.fill(self,"toModel:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessorBlackboard)})},
  532. args: ["aDataCarrier"],
  533. source: "toModel: aDataCarrier\x0a\x09aDataCarrier modifyTarget",
  534. messageSends: ["modifyTarget"],
  535. referencedClasses: []
  536. }),
  537. smalltalk.TrappedProcessorBlackboard);
  538. smalltalk.addClass('TrappedProcessorTerminator', smalltalk.TrappedProcessor, [], 'Trapped-Frontend');
  539. 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).";
  540. smalltalk.addMethod(
  541. smalltalk.method({
  542. selector: "toView:",
  543. category: 'data transformation',
  544. fn: function (aDataCarrier){
  545. var self=this;
  546. return smalltalk.withContext(function($ctx1) {
  547. return self}, function($ctx1) {$ctx1.fill(self,"toView:",{aDataCarrier:aDataCarrier},smalltalk.TrappedProcessorTerminator)})},
  548. args: ["aDataCarrier"],
  549. source: "toView: aDataCarrier\x0a\x09\x22stop\x22",
  550. messageSends: [],
  551. referencedClasses: []
  552. }),
  553. smalltalk.TrappedProcessorTerminator);
  554. smalltalk.addClass('TrappedSingleton', smalltalk.Object, [], 'Trapped-Frontend');
  555. smalltalk.addMethod(
  556. smalltalk.method({
  557. selector: "start:",
  558. category: 'action',
  559. fn: function (args){
  560. var self=this;
  561. return smalltalk.withContext(function($ctx1) {
  562. var $1;
  563. $1=self._subclassResponsibility();
  564. return $1;
  565. }, function($ctx1) {$ctx1.fill(self,"start:",{args:args},smalltalk.TrappedSingleton)})},
  566. args: ["args"],
  567. source: "start: args\x0a\x09^ self subclassResponsibility",
  568. messageSends: ["subclassResponsibility"],
  569. referencedClasses: []
  570. }),
  571. smalltalk.TrappedSingleton);
  572. smalltalk.TrappedSingleton.klass.iVarNames = ['current'];
  573. smalltalk.addMethod(
  574. smalltalk.method({
  575. selector: "current",
  576. category: 'accessing',
  577. fn: function (){
  578. var self=this;
  579. return smalltalk.withContext(function($ctx1) {
  580. var $2,$1;
  581. $2=self["@current"];
  582. if(($receiver = $2) == nil || $receiver == null){
  583. self["@current"]=self._new();
  584. $1=self["@current"];
  585. } else {
  586. $1=$2;
  587. };
  588. return $1;
  589. }, function($ctx1) {$ctx1.fill(self,"current",{},smalltalk.TrappedSingleton.klass)})},
  590. args: [],
  591. source: "current\x0a\x09^ current ifNil: [ current := self new ]",
  592. messageSends: ["ifNil:", "new"],
  593. referencedClasses: []
  594. }),
  595. smalltalk.TrappedSingleton.klass);
  596. smalltalk.addMethod(
  597. smalltalk.method({
  598. selector: "start:",
  599. category: 'action',
  600. fn: function (args){
  601. var self=this;
  602. return smalltalk.withContext(function($ctx1) {
  603. _st(self._current())._start_(args);
  604. return self}, function($ctx1) {$ctx1.fill(self,"start:",{args:args},smalltalk.TrappedSingleton.klass)})},
  605. args: ["args"],
  606. source: "start: args\x0a\x09self current start: args",
  607. messageSends: ["start:", "current"],
  608. referencedClasses: []
  609. }),
  610. smalltalk.TrappedSingleton.klass);
  611. smalltalk.addClass('Trapped', smalltalk.TrappedSingleton, ['registry'], 'Trapped-Frontend');
  612. smalltalk.addMethod(
  613. smalltalk.method({
  614. selector: "byName:",
  615. category: 'accessing',
  616. fn: function (aString){
  617. var self=this;
  618. return smalltalk.withContext(function($ctx1) {
  619. var $1;
  620. $1=_st(self["@registry"])._at_(aString);
  621. return $1;
  622. }, function($ctx1) {$ctx1.fill(self,"byName:",{aString:aString},smalltalk.Trapped)})},
  623. args: ["aString"],
  624. source: "byName: aString\x0a\x09^ registry at: aString",
  625. messageSends: ["at:"],
  626. referencedClasses: []
  627. }),
  628. smalltalk.Trapped);
  629. smalltalk.addMethod(
  630. smalltalk.method({
  631. selector: "descend:snapshotDo:",
  632. category: 'action',
  633. fn: function (anArray,aBlock){
  634. var self=this;
  635. var tpsc;
  636. function $TrappedPathStack(){return smalltalk.TrappedPathStack||(typeof TrappedPathStack=="undefined"?nil:TrappedPathStack)}
  637. function $TrappedSnapshot(){return smalltalk.TrappedSnapshot||(typeof TrappedSnapshot=="undefined"?nil:TrappedSnapshot)}
  638. return smalltalk.withContext(function($ctx1) {
  639. tpsc=_st($TrappedPathStack())._current();
  640. _st(tpsc)._append_do_(anArray,(function(){
  641. var path,model;
  642. return smalltalk.withContext(function($ctx2) {
  643. path=_st(_st(tpsc)._elements())._copy();
  644. path;
  645. model=self._byName_(_st(path)._first());
  646. model;
  647. return _st(aBlock)._value_(_st(_st($TrappedSnapshot())._new())._path_model_(path,model));
  648. }, function($ctx2) {$ctx2.fillBlock({path:path,model:model},$ctx1,1)})}));
  649. return self}, function($ctx1) {$ctx1.fill(self,"descend:snapshotDo:",{anArray:anArray,aBlock:aBlock,tpsc:tpsc},smalltalk.Trapped)})},
  650. args: ["anArray", "aBlock"],
  651. source: "descend: anArray snapshotDo: aBlock\x0a\x09| tpsc |\x0a tpsc := TrappedPathStack current.\x0a tpsc append: anArray do: [\x0a | path model |\x0a path := tpsc elements copy.\x0a \x09 model := self byName: path first.\x0a aBlock value: (TrappedSnapshot new path: path model: model)\x0a ]",
  652. messageSends: ["current", "append:do:", "copy", "elements", "byName:", "first", "value:", "path:model:", "new"],
  653. referencedClasses: ["TrappedPathStack", "TrappedSnapshot"]
  654. }),
  655. smalltalk.Trapped);
  656. smalltalk.addMethod(
  657. smalltalk.method({
  658. selector: "initialize",
  659. category: 'initialization',
  660. fn: function (){
  661. var self=this;
  662. return smalltalk.withContext(function($ctx1) {
  663. smalltalk.Trapped.superclass.fn.prototype._initialize.apply(_st(self), []);
  664. self["@registry"]=smalltalk.HashedCollection._from_([]);
  665. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.Trapped)})},
  666. args: [],
  667. source: "initialize\x0a\x09super initialize.\x0a\x09registry := #{}.",
  668. messageSends: ["initialize"],
  669. referencedClasses: []
  670. }),
  671. smalltalk.Trapped);
  672. smalltalk.addMethod(
  673. smalltalk.method({
  674. selector: "injectToJQuery:",
  675. category: 'action',
  676. fn: function (aJQuery){
  677. var self=this;
  678. function $Trapped(){return smalltalk.Trapped||(typeof Trapped=="undefined"?nil:Trapped)}
  679. function $HTMLCanvas(){return smalltalk.HTMLCanvas||(typeof HTMLCanvas=="undefined"?nil:HTMLCanvas)}
  680. return smalltalk.withContext(function($ctx1) {
  681. var $1;
  682. _st(aJQuery)._each_((function(index,elem){
  683. var jq;
  684. return smalltalk.withContext(function($ctx2) {
  685. jq=_st(elem)._asJQuery();
  686. jq;
  687. $1=_st(jq)._is_("[data-trap]");
  688. if(smalltalk.assert($1)){
  689. var parsed;
  690. parsed=_st($Trapped())._parse_(_st(jq)._attr_("data-trap"));
  691. parsed;
  692. _st(jq)._removeAttr_("data-trap");
  693. _st(parsed)._do_((function(rule){
  694. return smalltalk.withContext(function($ctx3) {
  695. return _st(_st(_st($HTMLCanvas())._onJQuery_(jq))._root())._trap_processors_(_st(rule)._first(),_st(rule)._at_ifAbsent_((2),(function(){
  696. return smalltalk.withContext(function($ctx4) {
  697. return [];
  698. }, function($ctx4) {$ctx4.fillBlock({},$ctx3,4)})})));
  699. }, function($ctx3) {$ctx3.fillBlock({rule:rule},$ctx2,3)})}));
  700. };
  701. return self._injectToJQuery_(_st(jq)._children());
  702. }, function($ctx2) {$ctx2.fillBlock({index:index,elem:elem,jq:jq},$ctx1,1)})}));
  703. return self}, function($ctx1) {$ctx1.fill(self,"injectToJQuery:",{aJQuery:aJQuery},smalltalk.Trapped)})},
  704. args: ["aJQuery"],
  705. source: "injectToJQuery: aJQuery\x0a\x09aJQuery each: [ :index :elem |\x0a\x09\x09| jq |\x0a\x09\x09jq := elem asJQuery.\x0a\x09\x09(jq is: '[data-trap]')\x0a\x09\x09\x09ifTrue: [\x0a\x09\x09\x09\x09| parsed |\x0a\x09\x09\x09\x09parsed := Trapped parse: (jq attr: 'data-trap').\x0a\x09\x09\x09\x09jq removeAttr: 'data-trap'.\x0a\x09\x09\x09\x09parsed do: [ :rule |\x0a\x09\x09\x09\x09\x09(HTMLCanvas onJQuery: jq) root trap: rule first processors: (rule at: 2 ifAbsent: [#()]) ] ].\x0a\x09\x09\x09self injectToJQuery: jq children ]",
  706. messageSends: ["each:", "asJQuery", "ifTrue:", "is:", "parse:", "attr:", "removeAttr:", "do:", "trap:processors:", "root", "onJQuery:", "first", "at:ifAbsent:", "injectToJQuery:", "children"],
  707. referencedClasses: ["Trapped", "HTMLCanvas"]
  708. }),
  709. smalltalk.Trapped);
  710. smalltalk.addMethod(
  711. smalltalk.method({
  712. selector: "register:",
  713. category: 'accessing',
  714. fn: function (aListKeyedEntity){
  715. var self=this;
  716. return smalltalk.withContext(function($ctx1) {
  717. self._register_name_(aListKeyedEntity,_st(_st(aListKeyedEntity)._class())._name());
  718. return self}, function($ctx1) {$ctx1.fill(self,"register:",{aListKeyedEntity:aListKeyedEntity},smalltalk.Trapped)})},
  719. args: ["aListKeyedEntity"],
  720. source: "register: aListKeyedEntity\x0a\x09self register: aListKeyedEntity name: aListKeyedEntity class name",
  721. messageSends: ["register:name:", "name", "class"],
  722. referencedClasses: []
  723. }),
  724. smalltalk.Trapped);
  725. smalltalk.addMethod(
  726. smalltalk.method({
  727. selector: "register:name:",
  728. category: 'accessing',
  729. fn: function (aListKeyedEntity,aString){
  730. var self=this;
  731. return smalltalk.withContext(function($ctx1) {
  732. _st(self["@registry"])._at_put_(aString,aListKeyedEntity);
  733. return self}, function($ctx1) {$ctx1.fill(self,"register:name:",{aListKeyedEntity:aListKeyedEntity,aString:aString},smalltalk.Trapped)})},
  734. args: ["aListKeyedEntity", "aString"],
  735. source: "register: aListKeyedEntity name: aString\x0a\x09registry at: aString put: aListKeyedEntity",
  736. messageSends: ["at:put:"],
  737. referencedClasses: []
  738. }),
  739. smalltalk.Trapped);
  740. smalltalk.addMethod(
  741. smalltalk.method({
  742. selector: "start:",
  743. category: 'action',
  744. fn: function (args){
  745. var self=this;
  746. return smalltalk.withContext(function($ctx1) {
  747. _st(args)._do_((function(each){
  748. return smalltalk.withContext(function($ctx2) {
  749. return self._register_(each);
  750. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  751. self._injectToJQuery_("html"._asJQuery());
  752. return self}, function($ctx1) {$ctx1.fill(self,"start:",{args:args},smalltalk.Trapped)})},
  753. args: ["args"],
  754. source: "start: args\x0a\x09args do: [ :each | self register: each ].\x0a\x09self injectToJQuery: 'html' asJQuery",
  755. messageSends: ["do:", "register:", "injectToJQuery:", "asJQuery"],
  756. referencedClasses: []
  757. }),
  758. smalltalk.Trapped);
  759. smalltalk.addMethod(
  760. smalltalk.method({
  761. selector: "envelope:loop:before:do:",
  762. category: 'private',
  763. fn: function (envelope,model,endjq,aBlock){
  764. var self=this;
  765. var envjq;
  766. return smalltalk.withContext(function($ctx1) {
  767. envjq=_st(envelope)._asJQuery();
  768. _st(model)._withIndexDo_((function(item,i){
  769. return smalltalk.withContext(function($ctx2) {
  770. _st([i])._trapDescend_((function(){
  771. return smalltalk.withContext(function($ctx3) {
  772. return _st(envelope)._with_(aBlock);
  773. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}));
  774. return _st(_st(_st(envjq)._children())._detach())._insertBefore_(endjq);
  775. }, function($ctx2) {$ctx2.fillBlock({item:item,i:i},$ctx1,1)})}));
  776. _st(envjq)._remove();
  777. return self}, function($ctx1) {$ctx1.fill(self,"envelope:loop:before:do:",{envelope:envelope,model:model,endjq:endjq,aBlock:aBlock,envjq:envjq},smalltalk.Trapped.klass)})},
  778. args: ["envelope", "model", "endjq", "aBlock"],
  779. source: "envelope: envelope loop: model before: endjq do: aBlock\x0a \x09| envjq |\x0a envjq := envelope asJQuery.\x0a model withIndexDo: [ :item :i |\x0a {i} trapDescend: [ envelope with: aBlock ].\x0a envjq children detach insertBefore: endjq.\x0a ].\x0a envjq remove",
  780. messageSends: ["asJQuery", "withIndexDo:", "trapDescend:", "with:", "insertBefore:", "detach", "children", "remove"],
  781. referencedClasses: []
  782. }),
  783. smalltalk.Trapped.klass);
  784. smalltalk.addMethod(
  785. smalltalk.method({
  786. selector: "loop:between:and:do:",
  787. category: 'private',
  788. fn: function (model,start,end,aBlock){
  789. var self=this;
  790. return smalltalk.withContext(function($ctx1) {
  791. var $2,$1;
  792. $2=_st(start)._asJQuery();
  793. $ctx1.sendIdx["asJQuery"]=1;
  794. $1=_st($2)._nextUntil_(_st(end)._element());
  795. _st($1)._remove();
  796. _st(start)._with_((function(html){
  797. return smalltalk.withContext(function($ctx2) {
  798. if(($receiver = model) == nil || $receiver == null){
  799. return model;
  800. } else {
  801. return self._envelope_loop_before_do_(_st(html)._div(),model,_st(end)._asJQuery(),aBlock);
  802. };
  803. }, function($ctx2) {$ctx2.fillBlock({html:html},$ctx1,1)})}));
  804. return self}, function($ctx1) {$ctx1.fill(self,"loop:between:and:do:",{model:model,start:start,end:end,aBlock:aBlock},smalltalk.Trapped.klass)})},
  805. args: ["model", "start", "end", "aBlock"],
  806. source: "loop: model between: start and: end do: aBlock\x0a (start asJQuery nextUntil: end element) remove.\x0a start with: [ :html | model ifNotNil: [\x0a \x09self envelope: html div loop: model before: end asJQuery do: aBlock\x0a\x09]]",
  807. messageSends: ["remove", "nextUntil:", "asJQuery", "element", "with:", "ifNotNil:", "envelope:loop:before:do:", "div"],
  808. referencedClasses: []
  809. }),
  810. smalltalk.Trapped.klass);
  811. smalltalk.addMethod(
  812. smalltalk.method({
  813. selector: "parse:",
  814. category: 'accessing',
  815. fn: function (aString){
  816. var self=this;
  817. return smalltalk.withContext(function($ctx1) {
  818. var $2,$3,$4,$5,$6,$8,$7,$9,$10,$11,$12,$13,$14,$1;
  819. $2=_st(aString)._tokenize_(".");
  820. $ctx1.sendIdx["tokenize:"]=1;
  821. $1=_st($2)._collect_((function(rule){
  822. return smalltalk.withContext(function($ctx2) {
  823. $3=_st(rule)._tokenize_(":");
  824. $ctx2.sendIdx["tokenize:"]=2;
  825. return _st($3)._collect_((function(message){
  826. var result,stack,anArray;
  827. return smalltalk.withContext(function($ctx3) {
  828. anArray=_st(message)._tokenize_(" ");
  829. anArray;
  830. result=[];
  831. result;
  832. stack=[result];
  833. stack;
  834. _st(anArray)._do_((function(each){
  835. var asNum,inner,close;
  836. return smalltalk.withContext(function($ctx4) {
  837. close=(0);
  838. close;
  839. inner=each;
  840. inner;
  841. _st((function(){
  842. return smalltalk.withContext(function($ctx5) {
  843. $4=_st(inner)._notEmpty();
  844. $ctx5.sendIdx["notEmpty"]=1;
  845. return _st($4)._and_((function(){
  846. return smalltalk.withContext(function($ctx6) {
  847. $5=_st(inner)._first();
  848. $ctx6.sendIdx["first"]=1;
  849. return _st($5).__eq("(");
  850. $ctx6.sendIdx["="]=1;
  851. }, function($ctx6) {$ctx6.fillBlock({},$ctx5,5)})}));
  852. $ctx5.sendIdx["and:"]=1;
  853. }, function($ctx5) {$ctx5.fillBlock({},$ctx4,4)})}))._whileTrue_((function(){
  854. return smalltalk.withContext(function($ctx5) {
  855. inner=_st(inner)._allButFirst();
  856. $ctx5.sendIdx["allButFirst"]=1;
  857. inner;
  858. $6=stack;
  859. $8=_st(stack)._last();
  860. $ctx5.sendIdx["last"]=1;
  861. $7=_st($8)._add_([]);
  862. $ctx5.sendIdx["add:"]=2;
  863. return _st($6)._add_($7);
  864. $ctx5.sendIdx["add:"]=1;
  865. }, function($ctx5) {$ctx5.fillBlock({},$ctx4,6)})}));
  866. $ctx4.sendIdx["whileTrue:"]=1;
  867. _st((function(){
  868. return smalltalk.withContext(function($ctx5) {
  869. $9=_st(inner)._notEmpty();
  870. $ctx5.sendIdx["notEmpty"]=2;
  871. return _st($9)._and_((function(){
  872. return smalltalk.withContext(function($ctx6) {
  873. $10=_st(inner)._last();
  874. $ctx6.sendIdx["last"]=2;
  875. return _st($10).__eq(")");
  876. $ctx6.sendIdx["="]=2;
  877. }, function($ctx6) {$ctx6.fillBlock({},$ctx5,8)})}));
  878. $ctx5.sendIdx["and:"]=2;
  879. }, function($ctx5) {$ctx5.fillBlock({},$ctx4,7)})}))._whileTrue_((function(){
  880. return smalltalk.withContext(function($ctx5) {
  881. inner=_st(inner)._allButLast();
  882. inner;
  883. close=_st(close).__plus((1));
  884. return close;
  885. }, function($ctx5) {$ctx5.fillBlock({},$ctx4,9)})}));
  886. $11=_st(_st(inner)._notEmpty())._and_((function(){
  887. return smalltalk.withContext(function($ctx5) {
  888. return _st(_st(inner)._first()).__eq("#");
  889. $ctx5.sendIdx["="]=3;
  890. }, function($ctx5) {$ctx5.fillBlock({},$ctx4,10)})}));
  891. if(smalltalk.assert($11)){
  892. inner=[_st(inner)._allButFirst()];
  893. inner;
  894. };
  895. $12=_st(inner)._isString();
  896. if(smalltalk.assert($12)){
  897. asNum=_st(_st(inner)._ifEmpty_((function(){
  898. return smalltalk.withContext(function($ctx5) {
  899. return "NaN";
  900. }, function($ctx5) {$ctx5.fillBlock({},$ctx4,13)})})))._asNumber();
  901. } else {
  902. asNum=inner;
  903. };
  904. asNum;
  905. $13=_st(asNum).__eq(asNum);
  906. if(smalltalk.assert($13)){
  907. $14=_st(stack)._last();
  908. $ctx4.sendIdx["last"]=3;
  909. _st($14)._add_(asNum);
  910. $ctx4.sendIdx["add:"]=3;
  911. } else {
  912. _st(inner)._ifNotEmpty_((function(){
  913. return smalltalk.withContext(function($ctx5) {
  914. return _st(_st(stack)._last())._add_(inner);
  915. }, function($ctx5) {$ctx5.fillBlock({},$ctx4,17)})}));
  916. };
  917. return _st(close)._timesRepeat_((function(){
  918. return smalltalk.withContext(function($ctx5) {
  919. return _st(stack)._removeLast();
  920. }, function($ctx5) {$ctx5.fillBlock({},$ctx4,18)})}));
  921. }, function($ctx4) {$ctx4.fillBlock({each:each,asNum:asNum,inner:inner,close:close},$ctx3,3)})}));
  922. return result;
  923. }, function($ctx3) {$ctx3.fillBlock({message:message,result:result,stack:stack,anArray:anArray},$ctx2,2)})}));
  924. }, function($ctx2) {$ctx2.fillBlock({rule:rule},$ctx1,1)})}));
  925. $ctx1.sendIdx["collect:"]=1;
  926. return $1;
  927. }, function($ctx1) {$ctx1.fill(self,"parse:",{aString:aString},smalltalk.Trapped.klass)})},
  928. args: ["aString"],
  929. source: "parse: aString\x0a\x09^ (aString tokenize: '.') collect: [ :rule |\x0a\x09\x09(rule tokenize: ':') collect: [ :message |\x0a\x09\x09\x09| result stack anArray |\x0a\x09\x09\x09anArray := message tokenize: ' '.\x0a\x09\x09\x09result := #().\x0a\x09\x09\x09stack := { result }.\x0a\x09\x09\x09anArray do: [ :each |\x0a \x09\x09\x09| asNum inner close |\x0a\x09\x09\x09\x09close := 0.\x0a\x09\x09\x09\x09inner := each.\x0a\x09\x09\x09\x09[ inner notEmpty and: [ inner first = '(' ]] whileTrue: [ inner := inner allButFirst. stack add: (stack last add: #()) ].\x0a\x09\x09\x09\x09[ inner notEmpty and: [ inner last = ')' ]] whileTrue: [ inner := inner allButLast. close := close + 1 ].\x0a\x09\x09\x09\x09(inner notEmpty and: [ inner first = '#' ]) ifTrue: [ inner := { inner allButFirst } ].\x0a\x09\x09 \x09asNum := inner isString ifTrue: [ (inner ifEmpty: [ 'NaN' ]) asNumber ] ifFalse: [ inner ].\x0a \x09\x09asNum = asNum ifTrue: [ stack last add: asNum ] ifFalse: [\x0a\x09\x09\x09\x09\x09inner ifNotEmpty: [ stack last add: inner ] ].\x0a\x09\x09\x09\x09close timesRepeat: [ stack removeLast ] ].\x0a\x09\x09\x09result ] ]",
  930. messageSends: ["collect:", "tokenize:", "do:", "whileTrue:", "and:", "notEmpty", "=", "first", "allButFirst", "add:", "last", "allButLast", "+", "ifTrue:", "ifTrue:ifFalse:", "isString", "asNumber", "ifEmpty:", "ifNotEmpty:", "timesRepeat:", "removeLast"],
  931. referencedClasses: []
  932. }),
  933. smalltalk.Trapped.klass);
  934. smalltalk.addClass('TrappedPathStack', smalltalk.TrappedSingleton, ['elements'], 'Trapped-Frontend');
  935. smalltalk.addMethod(
  936. smalltalk.method({
  937. selector: "append:do:",
  938. category: 'descending',
  939. fn: function (anArray,aBlock){
  940. var self=this;
  941. return smalltalk.withContext(function($ctx1) {
  942. self._with_do_(_st(self["@elements"]).__comma(anArray),aBlock);
  943. return self}, function($ctx1) {$ctx1.fill(self,"append:do:",{anArray:anArray,aBlock:aBlock},smalltalk.TrappedPathStack)})},
  944. args: ["anArray", "aBlock"],
  945. source: "append: anArray do: aBlock\x0a self with: elements, anArray do: aBlock",
  946. messageSends: ["with:do:", ","],
  947. referencedClasses: []
  948. }),
  949. smalltalk.TrappedPathStack);
  950. smalltalk.addMethod(
  951. smalltalk.method({
  952. selector: "elements",
  953. category: 'accessing',
  954. fn: function (){
  955. var self=this;
  956. return smalltalk.withContext(function($ctx1) {
  957. var $1;
  958. $1=self["@elements"];
  959. return $1;
  960. }, function($ctx1) {$ctx1.fill(self,"elements",{},smalltalk.TrappedPathStack)})},
  961. args: [],
  962. source: "elements\x0a\x09^elements",
  963. messageSends: [],
  964. referencedClasses: []
  965. }),
  966. smalltalk.TrappedPathStack);
  967. smalltalk.addMethod(
  968. smalltalk.method({
  969. selector: "initialize",
  970. category: 'initialization',
  971. fn: function (){
  972. var self=this;
  973. return smalltalk.withContext(function($ctx1) {
  974. smalltalk.TrappedPathStack.superclass.fn.prototype._initialize.apply(_st(self), []);
  975. self["@elements"]=[];
  976. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.TrappedPathStack)})},
  977. args: [],
  978. source: "initialize\x0a super initialize.\x0a\x09elements := #().",
  979. messageSends: ["initialize"],
  980. referencedClasses: []
  981. }),
  982. smalltalk.TrappedPathStack);
  983. smalltalk.addMethod(
  984. smalltalk.method({
  985. selector: "with:do:",
  986. category: 'descending',
  987. fn: function (anArray,aBlock){
  988. var self=this;
  989. var old;
  990. return smalltalk.withContext(function($ctx1) {
  991. old=self["@elements"];
  992. _st((function(){
  993. return smalltalk.withContext(function($ctx2) {
  994. self["@elements"]=anArray;
  995. self["@elements"];
  996. return _st(aBlock)._value();
  997. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._ensure_((function(){
  998. return smalltalk.withContext(function($ctx2) {
  999. self["@elements"]=old;
  1000. return self["@elements"];
  1001. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  1002. return self}, function($ctx1) {$ctx1.fill(self,"with:do:",{anArray:anArray,aBlock:aBlock,old:old},smalltalk.TrappedPathStack)})},
  1003. args: ["anArray", "aBlock"],
  1004. source: "with: anArray do: aBlock\x0a\x09| old |\x0a old := elements.\x0a [ elements := anArray.\x0a\x09aBlock value ] ensure: [ elements := old ]",
  1005. messageSends: ["ensure:", "value"],
  1006. referencedClasses: []
  1007. }),
  1008. smalltalk.TrappedPathStack);
  1009. smalltalk.addClass('TrappedSnapshot', smalltalk.Object, ['path', 'model'], 'Trapped-Frontend');
  1010. smalltalk.addMethod(
  1011. smalltalk.method({
  1012. selector: "do:",
  1013. category: 'action',
  1014. fn: function (aBlock){
  1015. var self=this;
  1016. function $TrappedPathStack(){return smalltalk.TrappedPathStack||(typeof TrappedPathStack=="undefined"?nil:TrappedPathStack)}
  1017. return smalltalk.withContext(function($ctx1) {
  1018. _st(_st($TrappedPathStack())._current())._with_do_(self["@path"],(function(){
  1019. return smalltalk.withContext(function($ctx2) {
  1020. return _st(aBlock)._value_(self["@model"]);
  1021. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  1022. return self}, function($ctx1) {$ctx1.fill(self,"do:",{aBlock:aBlock},smalltalk.TrappedSnapshot)})},
  1023. args: ["aBlock"],
  1024. source: "do: aBlock\x0a\x09TrappedPathStack current with: path do: [ aBlock value: model ]",
  1025. messageSends: ["with:do:", "current", "value:"],
  1026. referencedClasses: ["TrappedPathStack"]
  1027. }),
  1028. smalltalk.TrappedSnapshot);
  1029. smalltalk.addMethod(
  1030. smalltalk.method({
  1031. selector: "model",
  1032. category: 'accessing',
  1033. fn: function (){
  1034. var self=this;
  1035. return smalltalk.withContext(function($ctx1) {
  1036. var $1;
  1037. $1=self["@model"];
  1038. return $1;
  1039. }, function($ctx1) {$ctx1.fill(self,"model",{},smalltalk.TrappedSnapshot)})},
  1040. args: [],
  1041. source: "model\x0a\x09^model",
  1042. messageSends: [],
  1043. referencedClasses: []
  1044. }),
  1045. smalltalk.TrappedSnapshot);
  1046. smalltalk.addMethod(
  1047. smalltalk.method({
  1048. selector: "modify:",
  1049. category: 'action',
  1050. fn: function (aBlock){
  1051. var self=this;
  1052. return smalltalk.withContext(function($ctx1) {
  1053. _st(self._model())._modify_do_(_st(self._path())._allButFirst(),aBlock);
  1054. return self}, function($ctx1) {$ctx1.fill(self,"modify:",{aBlock:aBlock},smalltalk.TrappedSnapshot)})},
  1055. args: ["aBlock"],
  1056. source: "modify: aBlock\x0a\x09self model modify: self path allButFirst do: aBlock",
  1057. messageSends: ["modify:do:", "model", "allButFirst", "path"],
  1058. referencedClasses: []
  1059. }),
  1060. smalltalk.TrappedSnapshot);
  1061. smalltalk.addMethod(
  1062. smalltalk.method({
  1063. selector: "path",
  1064. category: 'accessing',
  1065. fn: function (){
  1066. var self=this;
  1067. return smalltalk.withContext(function($ctx1) {
  1068. var $1;
  1069. $1=self["@path"];
  1070. return $1;
  1071. }, function($ctx1) {$ctx1.fill(self,"path",{},smalltalk.TrappedSnapshot)})},
  1072. args: [],
  1073. source: "path\x0a\x09^path",
  1074. messageSends: [],
  1075. referencedClasses: []
  1076. }),
  1077. smalltalk.TrappedSnapshot);
  1078. smalltalk.addMethod(
  1079. smalltalk.method({
  1080. selector: "path:model:",
  1081. category: 'accessing',
  1082. fn: function (anArray,aTrappedMW){
  1083. var self=this;
  1084. return smalltalk.withContext(function($ctx1) {
  1085. self["@path"]=anArray;
  1086. self["@model"]=aTrappedMW;
  1087. return self}, function($ctx1) {$ctx1.fill(self,"path:model:",{anArray:anArray,aTrappedMW:aTrappedMW},smalltalk.TrappedSnapshot)})},
  1088. args: ["anArray", "aTrappedMW"],
  1089. source: "path: anArray model: aTrappedMW\x0a\x09path := anArray.\x0a model := aTrappedMW",
  1090. messageSends: [],
  1091. referencedClasses: []
  1092. }),
  1093. smalltalk.TrappedSnapshot);
  1094. smalltalk.addMethod(
  1095. smalltalk.method({
  1096. selector: "watch:",
  1097. category: 'action',
  1098. fn: function (aBlock){
  1099. var self=this;
  1100. return smalltalk.withContext(function($ctx1) {
  1101. _st(self._model())._watch_do_(_st(self._path())._allButFirst(),aBlock);
  1102. return self}, function($ctx1) {$ctx1.fill(self,"watch:",{aBlock:aBlock},smalltalk.TrappedSnapshot)})},
  1103. args: ["aBlock"],
  1104. source: "watch: aBlock\x0a\x09self model watch: self path allButFirst do: aBlock",
  1105. messageSends: ["watch:do:", "model", "allButFirst", "path"],
  1106. referencedClasses: []
  1107. }),
  1108. smalltalk.TrappedSnapshot);
  1109. smalltalk.addMethod(
  1110. smalltalk.method({
  1111. selector: "trapDescend:",
  1112. category: '*Trapped-Frontend',
  1113. fn: function (aBlock){
  1114. var self=this;
  1115. function $Trapped(){return smalltalk.Trapped||(typeof Trapped=="undefined"?nil:Trapped)}
  1116. return smalltalk.withContext(function($ctx1) {
  1117. _st(_st($Trapped())._current())._descend_snapshotDo_(self,aBlock);
  1118. return self}, function($ctx1) {$ctx1.fill(self,"trapDescend:",{aBlock:aBlock},smalltalk.Array)})},
  1119. args: ["aBlock"],
  1120. source: "trapDescend: aBlock\x0a\x09Trapped current descend: self snapshotDo: aBlock",
  1121. messageSends: ["descend:snapshotDo:", "current"],
  1122. referencedClasses: ["Trapped"]
  1123. }),
  1124. smalltalk.Array);
  1125. smalltalk.addMethod(
  1126. smalltalk.method({
  1127. selector: "trapIter:do:",
  1128. category: '*Trapped-Frontend',
  1129. fn: function (path,aBlock){
  1130. var self=this;
  1131. return smalltalk.withContext(function($ctx1) {
  1132. self._with_((function(html){
  1133. return smalltalk.withContext(function($ctx2) {
  1134. return _st(_st(html)._noscript())._trapIter_after_(path,aBlock);
  1135. }, function($ctx2) {$ctx2.fillBlock({html:html},$ctx1,1)})}));
  1136. return self}, function($ctx1) {$ctx1.fill(self,"trapIter:do:",{path:path,aBlock:aBlock},smalltalk.HTMLCanvas)})},
  1137. args: ["path", "aBlock"],
  1138. source: "trapIter: path do: aBlock\x0a self with: [ :html | html noscript trapIter: path after: aBlock ]",
  1139. messageSends: ["with:", "trapIter:after:", "noscript"],
  1140. referencedClasses: []
  1141. }),
  1142. smalltalk.HTMLCanvas);
  1143. smalltalk.addMethod(
  1144. smalltalk.method({
  1145. selector: "trap:",
  1146. category: '*Trapped-Frontend',
  1147. fn: function (path){
  1148. var self=this;
  1149. return smalltalk.withContext(function($ctx1) {
  1150. self._trap_processors_(path,[]);
  1151. return self}, function($ctx1) {$ctx1.fill(self,"trap:",{path:path},smalltalk.TagBrush)})},
  1152. args: ["path"],
  1153. source: "trap: path\x0a\x09self trap: path processors: #()",
  1154. messageSends: ["trap:processors:"],
  1155. referencedClasses: []
  1156. }),
  1157. smalltalk.TagBrush);
  1158. smalltalk.addMethod(
  1159. smalltalk.method({
  1160. selector: "trap:processors:",
  1161. category: '*Trapped-Frontend',
  1162. fn: function (path,anArray){
  1163. var self=this;
  1164. function $TrappedProcessingChain(){return smalltalk.TrappedProcessingChain||(typeof TrappedProcessingChain=="undefined"?nil:TrappedProcessingChain)}
  1165. return smalltalk.withContext(function($ctx1) {
  1166. _st(path)._trapDescend_((function(snap){
  1167. return smalltalk.withContext(function($ctx2) {
  1168. return _st(_st($TrappedProcessingChain())._newFromProcessorSpecs_(anArray))._forSnapshot_andBrush_(snap,self);
  1169. }, function($ctx2) {$ctx2.fillBlock({snap:snap},$ctx1,1)})}));
  1170. return self}, function($ctx1) {$ctx1.fill(self,"trap:processors:",{path:path,anArray:anArray},smalltalk.TagBrush)})},
  1171. args: ["path", "anArray"],
  1172. source: "trap: path processors: anArray\x0a\x09path trapDescend: [ :snap |\x0a\x09\x09(TrappedProcessingChain newFromProcessorSpecs: anArray)\x0a\x09\x09\x09forSnapshot: snap andBrush: self ]",
  1173. messageSends: ["trapDescend:", "forSnapshot:andBrush:", "newFromProcessorSpecs:"],
  1174. referencedClasses: ["TrappedProcessingChain"]
  1175. }),
  1176. smalltalk.TagBrush);
  1177. smalltalk.addMethod(
  1178. smalltalk.method({
  1179. selector: "trap:read:",
  1180. category: '*Trapped-Frontend',
  1181. fn: function (path,aBlock){
  1182. var self=this;
  1183. function $KeyedPubSubUnsubscribe(){return smalltalk.KeyedPubSubUnsubscribe||(typeof KeyedPubSubUnsubscribe=="undefined"?nil:KeyedPubSubUnsubscribe)}
  1184. return smalltalk.withContext(function($ctx1) {
  1185. var $1;
  1186. _st(path)._trapDescend_((function(snap){
  1187. return smalltalk.withContext(function($ctx2) {
  1188. return _st(snap)._watch_((function(data){
  1189. return smalltalk.withContext(function($ctx3) {
  1190. $1=_st(_st(_st(self._asJQuery())._closest_("html"))._toArray())._isEmpty();
  1191. if(smalltalk.assert($1)){
  1192. _st($KeyedPubSubUnsubscribe())._signal();
  1193. };
  1194. return _st(snap)._do_((function(){
  1195. return smalltalk.withContext(function($ctx4) {
  1196. return self._with_((function(html){
  1197. return smalltalk.withContext(function($ctx5) {
  1198. return _st(aBlock)._value_value_(data,html);
  1199. }, function($ctx5) {$ctx5.fillBlock({html:html},$ctx4,5)})}));
  1200. }, function($ctx4) {$ctx4.fillBlock({},$ctx3,4)})}));
  1201. }, function($ctx3) {$ctx3.fillBlock({data:data},$ctx2,2)})}));
  1202. }, function($ctx2) {$ctx2.fillBlock({snap:snap},$ctx1,1)})}));
  1203. return self}, function($ctx1) {$ctx1.fill(self,"trap:read:",{path:path,aBlock:aBlock},smalltalk.TagBrush)})},
  1204. args: ["path", "aBlock"],
  1205. source: "trap: path read: aBlock\x0a\x09path trapDescend: [ :snap |\x0a snap watch: [ :data |\x0a (self asJQuery closest: 'html') toArray isEmpty ifTrue: [ KeyedPubSubUnsubscribe signal ].\x0a \x09snap do: [ self with: [ :html | aBlock value: data value: html ] ]\x0a \x09]\x0a ]",
  1206. messageSends: ["trapDescend:", "watch:", "ifTrue:", "isEmpty", "toArray", "closest:", "asJQuery", "signal", "do:", "with:", "value:value:"],
  1207. referencedClasses: ["KeyedPubSubUnsubscribe"]
  1208. }),
  1209. smalltalk.TagBrush);
  1210. smalltalk.addMethod(
  1211. smalltalk.method({
  1212. selector: "trapGuard:contents:",
  1213. category: '*Trapped-Frontend',
  1214. fn: function (anArray,aBlock){
  1215. var self=this;
  1216. return smalltalk.withContext(function($ctx1) {
  1217. var $1,$2,$3,$4,$5;
  1218. []._trapDescend_((function(snap){
  1219. var shown;
  1220. return smalltalk.withContext(function($ctx2) {
  1221. shown=nil;
  1222. shown;
  1223. return self._trap_read_(anArray,(function(gdata){
  1224. var sanitized;
  1225. return smalltalk.withContext(function($ctx3) {
  1226. if(($receiver = gdata) == nil || $receiver == null){
  1227. sanitized=false;
  1228. } else {
  1229. sanitized=gdata;
  1230. };
  1231. sanitized;
  1232. $1=_st(shown).__eq(sanitized);
  1233. if(! smalltalk.assert($1)){
  1234. shown=sanitized;
  1235. shown;
  1236. $2=shown;
  1237. if(smalltalk.assert($2)){
  1238. _st(snap)._do_((function(){
  1239. return smalltalk.withContext(function($ctx4) {
  1240. return self._contents_(aBlock);
  1241. }, function($ctx4) {$ctx4.fillBlock({},$ctx3,6)})}));
  1242. $3=self._asJQuery();
  1243. $ctx3.sendIdx["asJQuery"]=1;
  1244. return _st($3)._show();
  1245. } else {
  1246. $4=self._asJQuery();
  1247. _st($4)._hide();
  1248. $5=_st($4)._empty();
  1249. return $5;
  1250. };
  1251. };
  1252. }, function($ctx3) {$ctx3.fillBlock({gdata:gdata,sanitized:sanitized},$ctx2,2)})}));
  1253. }, function($ctx2) {$ctx2.fillBlock({snap:snap,shown:shown},$ctx1,1)})}));
  1254. return self}, function($ctx1) {$ctx1.fill(self,"trapGuard:contents:",{anArray:anArray,aBlock:aBlock},smalltalk.TagBrush)})},
  1255. args: ["anArray", "aBlock"],
  1256. source: "trapGuard: anArray contents: aBlock\x0a\x09#() trapDescend: [ :snap |\x0a\x09 | shown |\x0a \x09shown := nil.\x0a\x09 self trap: anArray read: [ :gdata |\x0a\x09\x09\x09| sanitized |\x0a\x09\x09\x09sanitized := gdata ifNil: [ false ].\x0a \x09 shown = sanitized ifFalse: [\x0a \x09 shown := sanitized.\x0a \x09shown\x0a\x09\x09\x09\x09\x09ifTrue: [ snap do: [ self contents: aBlock ]. self asJQuery show ]\x0a\x09\x09\x09\x09\x09ifFalse: [ self asJQuery hide; empty ] ] ] ]",
  1257. messageSends: ["trapDescend:", "trap:read:", "ifNil:", "ifFalse:", "=", "ifTrue:ifFalse:", "do:", "contents:", "show", "asJQuery", "hide", "empty"],
  1258. referencedClasses: []
  1259. }),
  1260. smalltalk.TagBrush);
  1261. smalltalk.addMethod(
  1262. smalltalk.method({
  1263. selector: "trapIter:after:",
  1264. category: '*Trapped-Frontend',
  1265. fn: function (path,aBlock){
  1266. var self=this;
  1267. var end;
  1268. function $TagBrush(){return smalltalk.TagBrush||(typeof TagBrush=="undefined"?nil:TagBrush)}
  1269. function $Trapped(){return smalltalk.Trapped||(typeof Trapped=="undefined"?nil:Trapped)}
  1270. return smalltalk.withContext(function($ctx1) {
  1271. var $2,$1;
  1272. $2="<noscript />"._asJQuery();
  1273. $ctx1.sendIdx["asJQuery"]=1;
  1274. $1=_st($2)._insertAfter_(self._asJQuery());
  1275. end=_st($TagBrush())._fromJQuery_canvas_($1,self["@canvas"]);
  1276. self._trap_read_(path,(function(model){
  1277. return smalltalk.withContext(function($ctx2) {
  1278. return _st($Trapped())._loop_between_and_do_(model,self,end,aBlock);
  1279. }, function($ctx2) {$ctx2.fillBlock({model:model},$ctx1,1)})}));
  1280. return self}, function($ctx1) {$ctx1.fill(self,"trapIter:after:",{path:path,aBlock:aBlock,end:end},smalltalk.TagBrush)})},
  1281. args: ["path", "aBlock"],
  1282. source: "trapIter: path after: aBlock\x0a\x09| end |\x0a\x09end := TagBrush fromJQuery: ('<noscript />' asJQuery insertAfter: self asJQuery) canvas: canvas.\x0a self trap: path read: [ :model |\x0a \x09Trapped loop: model between: self and: end do: aBlock.\x0a ]",
  1283. messageSends: ["fromJQuery:canvas:", "insertAfter:", "asJQuery", "trap:read:", "loop:between:and:do:"],
  1284. referencedClasses: ["TagBrush", "Trapped"]
  1285. }),
  1286. smalltalk.TagBrush);
  1287. });