Trapped-Frontend.deploy.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. smalltalk.addPackage('Trapped-Frontend', {});
  2. smalltalk.addClass('TrappedBinder', smalltalk.Object, ['brush'], 'Trapped-Frontend');
  3. smalltalk.addMethod(
  4. "_brush_",
  5. smalltalk.method({
  6. selector: "brush:",
  7. fn: function (aTagBrush){
  8. var self=this;
  9. return smalltalk.withContext(function($ctx1) { self["@brush"]=aTagBrush;
  10. return self}, function($ctx1) {$ctx1.fill(self,"brush:",{aTagBrush:aTagBrush}, smalltalk.TrappedBinder)})}
  11. }),
  12. smalltalk.TrappedBinder);
  13. smalltalk.addMethod(
  14. "_installFor_",
  15. smalltalk.method({
  16. selector: "installFor:",
  17. fn: function (path){
  18. var self=this;
  19. return smalltalk.withContext(function($ctx1) { _st(self["@brush"])._trap_read_(path,_st(self)._showBlock());
  20. return self}, function($ctx1) {$ctx1.fill(self,"installFor:",{path:path}, smalltalk.TrappedBinder)})}
  21. }),
  22. smalltalk.TrappedBinder);
  23. smalltalk.addMethod(
  24. "_prim_",
  25. smalltalk.method({
  26. selector: "prim:",
  27. fn: function (anObject){
  28. var self=this;
  29. return smalltalk.withContext(function($ctx1) { return anObject.valueOf();
  30. return self}, function($ctx1) {$ctx1.fill(self,"prim:",{anObject:anObject}, smalltalk.TrappedBinder)})}
  31. }),
  32. smalltalk.TrappedBinder);
  33. smalltalk.addMethod(
  34. "_showBlock",
  35. smalltalk.method({
  36. selector: "showBlock",
  37. fn: function (){
  38. var self=this;
  39. return smalltalk.withContext(function($ctx1) { var $2,$4,$6,$5,$3,$1;
  40. $1=(function(model){
  41. return smalltalk.withContext(function($ctx2) { $2=self["@brush"];
  42. _st($2)._empty();
  43. $4=$2;
  44. $6=model;
  45. if(($receiver = $6) == nil || $receiver == undefined){
  46. $5=(function(){
  47. return smalltalk.withContext(function($ctx3) { }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})});
  48. } else {
  49. $5=$6;
  50. };
  51. $3=_st($4)._with_($5);
  52. return $3;
  53. }, function($ctx2) {$ctx2.fillBlock({model:model},$ctx1)})});
  54. return $1;
  55. }, function($ctx1) {$ctx1.fill(self,"showBlock",{}, smalltalk.TrappedBinder)})}
  56. }),
  57. smalltalk.TrappedBinder);
  58. smalltalk.addClass('TrappedCheckedBinder', smalltalk.TrappedBinder, [], 'Trapped-Frontend');
  59. smalltalk.addMethod(
  60. "_installFor_",
  61. smalltalk.method({
  62. selector: "installFor:",
  63. fn: function (path){
  64. var self=this;
  65. return smalltalk.withContext(function($ctx1) { smalltalk.TrappedBinder.fn.prototype._installFor_.apply(_st(self), [path]);
  66. _st(path)._trapDescend_((function(snap){
  67. return smalltalk.withContext(function($ctx2) { return _st(self["@brush"])._onChange_((function(){
  68. return smalltalk.withContext(function($ctx3) { return _st(snap)._modify_((function(){
  69. return smalltalk.withContext(function($ctx4) { return _st(_st(_st(self["@brush"])._asJQuery())._attr_("checked"))._notNil();
  70. }, function($ctx4) {$ctx4.fillBlock({},$ctx1)})}));
  71. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}));
  72. }, function($ctx2) {$ctx2.fillBlock({snap:snap},$ctx1)})}));
  73. return self}, function($ctx1) {$ctx1.fill(self,"installFor:",{path:path}, smalltalk.TrappedCheckedBinder)})}
  74. }),
  75. smalltalk.TrappedCheckedBinder);
  76. smalltalk.addMethod(
  77. "_showBlock",
  78. smalltalk.method({
  79. selector: "showBlock",
  80. fn: function (){
  81. var self=this;
  82. return smalltalk.withContext(function($ctx1) { var $1;
  83. $1=(function(model){
  84. return smalltalk.withContext(function($ctx2) { return _st(_st(self["@brush"])._asJQuery())._attr_put_("checked",_st(model)._ifNotNil_ifNil_((function(){
  85. return smalltalk.withContext(function($ctx3) { return _st(self)._prim_(model);
  86. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}),(function(){
  87. return smalltalk.withContext(function($ctx3) { return false;
  88. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})})));
  89. }, function($ctx2) {$ctx2.fillBlock({model:model},$ctx1)})});
  90. return $1;
  91. }, function($ctx1) {$ctx1.fill(self,"showBlock",{}, smalltalk.TrappedCheckedBinder)})}
  92. }),
  93. smalltalk.TrappedCheckedBinder);
  94. smalltalk.addClass('TrappedValBinder', smalltalk.TrappedBinder, [], 'Trapped-Frontend');
  95. smalltalk.addMethod(
  96. "_installFor_",
  97. smalltalk.method({
  98. selector: "installFor:",
  99. fn: function (path){
  100. var self=this;
  101. return smalltalk.withContext(function($ctx1) { smalltalk.TrappedBinder.fn.prototype._installFor_.apply(_st(self), [path]);
  102. _st(path)._trapDescend_((function(snap){
  103. return smalltalk.withContext(function($ctx2) { return _st(self["@brush"])._onChange_((function(){
  104. return smalltalk.withContext(function($ctx3) { return _st(snap)._modify_((function(){
  105. return smalltalk.withContext(function($ctx4) { return _st(_st(self["@brush"])._asJQuery())._val();
  106. }, function($ctx4) {$ctx4.fillBlock({},$ctx1)})}));
  107. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}));
  108. }, function($ctx2) {$ctx2.fillBlock({snap:snap},$ctx1)})}));
  109. return self}, function($ctx1) {$ctx1.fill(self,"installFor:",{path:path}, smalltalk.TrappedValBinder)})}
  110. }),
  111. smalltalk.TrappedValBinder);
  112. smalltalk.addMethod(
  113. "_showBlock",
  114. smalltalk.method({
  115. selector: "showBlock",
  116. fn: function (){
  117. var self=this;
  118. return smalltalk.withContext(function($ctx1) { var $1;
  119. $1=(function(model){
  120. return smalltalk.withContext(function($ctx2) { return _st(_st(self["@brush"])._asJQuery())._val_(_st(model)._ifNotNil_ifNil_((function(){
  121. return smalltalk.withContext(function($ctx3) { return _st(self)._prim_(model);
  122. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}),(function(){
  123. return smalltalk.withContext(function($ctx3) { return (function(){
  124. return smalltalk.withContext(function($ctx4) { }, function($ctx4) {$ctx4.fillBlock({},$ctx1)})});
  125. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})})));
  126. }, function($ctx2) {$ctx2.fillBlock({model:model},$ctx1)})});
  127. return $1;
  128. }, function($ctx1) {$ctx1.fill(self,"showBlock",{}, smalltalk.TrappedValBinder)})}
  129. }),
  130. smalltalk.TrappedValBinder);
  131. smalltalk.addClass('TrappedDumbView', smalltalk.Widget, [], 'Trapped-Frontend');
  132. smalltalk.addMethod(
  133. "_renderOn_",
  134. smalltalk.method({
  135. selector: "renderOn:",
  136. fn: function (html){
  137. var self=this;
  138. return smalltalk.withContext(function($ctx1) { _st(_st(html)._root())._trap_([]);
  139. return self}, function($ctx1) {$ctx1.fill(self,"renderOn:",{html:html}, smalltalk.TrappedDumbView)})}
  140. }),
  141. smalltalk.TrappedDumbView);
  142. smalltalk.addClass('TrappedSingleton', smalltalk.Object, [], 'Trapped-Frontend');
  143. smalltalk.addMethod(
  144. "_start_",
  145. smalltalk.method({
  146. selector: "start:",
  147. fn: function (args){
  148. var self=this;
  149. return smalltalk.withContext(function($ctx1) { var $1;
  150. $1=_st(self)._subclassResponsibility();
  151. return $1;
  152. }, function($ctx1) {$ctx1.fill(self,"start:",{args:args}, smalltalk.TrappedSingleton)})}
  153. }),
  154. smalltalk.TrappedSingleton);
  155. smalltalk.TrappedSingleton.klass.iVarNames = ['current'];
  156. smalltalk.addMethod(
  157. "_current",
  158. smalltalk.method({
  159. selector: "current",
  160. fn: function (){
  161. var self=this;
  162. return smalltalk.withContext(function($ctx1) { var $2,$1;
  163. $2=self["@current"];
  164. if(($receiver = $2) == nil || $receiver == undefined){
  165. self["@current"]=_st(self)._new();
  166. $1=self["@current"];
  167. } else {
  168. $1=$2;
  169. };
  170. return $1;
  171. }, function($ctx1) {$ctx1.fill(self,"current",{}, smalltalk.TrappedSingleton.klass)})}
  172. }),
  173. smalltalk.TrappedSingleton.klass);
  174. smalltalk.addMethod(
  175. "_start_",
  176. smalltalk.method({
  177. selector: "start:",
  178. fn: function (args){
  179. var self=this;
  180. return smalltalk.withContext(function($ctx1) { _st(_st(self)._current())._start_(args);
  181. return self}, function($ctx1) {$ctx1.fill(self,"start:",{args:args}, smalltalk.TrappedSingleton.klass)})}
  182. }),
  183. smalltalk.TrappedSingleton.klass);
  184. smalltalk.addClass('Trapped', smalltalk.TrappedSingleton, ['registry'], 'Trapped-Frontend');
  185. smalltalk.addMethod(
  186. "_binder_",
  187. smalltalk.method({
  188. selector: "binder:",
  189. fn: function (aTagBrush){
  190. var self=this;
  191. var binder,tag;
  192. return smalltalk.withContext(function($ctx1) { var $1,$3,$4,$2,$5,$7,$8,$6;
  193. tag=_st(_st(aTagBrush)._element())._nodeName();
  194. $1=_st(tag).__eq("INPUT");
  195. $2=(function(){
  196. var type;
  197. return smalltalk.withContext(function($ctx2) { type=_st(_st(aTagBrush)._asJQuery())._attr_("type");
  198. type;
  199. $3=_st(type).__eq("checkbox");
  200. if(smalltalk.assert($3)){
  201. binder=_st((smalltalk.TrappedCheckedBinder || TrappedCheckedBinder))._new();
  202. binder;
  203. };
  204. $4=_st(type).__eq("text");
  205. if(smalltalk.assert($4)){
  206. binder=_st((smalltalk.TrappedValBinder || TrappedValBinder))._new();
  207. return binder;
  208. };
  209. }, function($ctx2) {$ctx2.fillBlock({type:type},$ctx1)})});
  210. _st($1)._ifTrue_($2);
  211. $5=binder;
  212. if(($receiver = $5) == nil || $receiver == undefined){
  213. binder=_st((smalltalk.TrappedBinder || TrappedBinder))._new();
  214. binder;
  215. } else {
  216. $5;
  217. };
  218. $7=binder;
  219. _st($7)._brush_(aTagBrush);
  220. $8=_st($7)._yourself();
  221. $6=$8;
  222. return $6;
  223. }, function($ctx1) {$ctx1.fill(self,"binder:",{aTagBrush:aTagBrush,binder:binder,tag:tag}, smalltalk.Trapped)})}
  224. }),
  225. smalltalk.Trapped);
  226. smalltalk.addMethod(
  227. "_byName_",
  228. smalltalk.method({
  229. selector: "byName:",
  230. fn: function (aString){
  231. var self=this;
  232. return smalltalk.withContext(function($ctx1) { var $1;
  233. $1=_st(self["@registry"])._at_(aString);
  234. return $1;
  235. }, function($ctx1) {$ctx1.fill(self,"byName:",{aString:aString}, smalltalk.Trapped)})}
  236. }),
  237. smalltalk.Trapped);
  238. smalltalk.addMethod(
  239. "_descend_snapshotDo_",
  240. smalltalk.method({
  241. selector: "descend:snapshotDo:",
  242. fn: function (anArray,aBlock){
  243. var self=this;
  244. var tpsc;
  245. return smalltalk.withContext(function($ctx1) { tpsc=_st((smalltalk.TrappedPathStack || TrappedPathStack))._current();
  246. _st(tpsc)._append_do_(anArray,(function(){
  247. var path,model;
  248. return smalltalk.withContext(function($ctx2) { path=_st(_st(tpsc)._elements())._copy();
  249. path;
  250. model=_st(self)._byName_(_st(path)._first());
  251. model;
  252. return _st(aBlock)._value_(_st(_st((smalltalk.TrappedSnapshot || TrappedSnapshot))._new())._path_model_(path,model));
  253. }, function($ctx2) {$ctx2.fillBlock({path:path,model:model},$ctx1)})}));
  254. return self}, function($ctx1) {$ctx1.fill(self,"descend:snapshotDo:",{anArray:anArray,aBlock:aBlock,tpsc:tpsc}, smalltalk.Trapped)})}
  255. }),
  256. smalltalk.Trapped);
  257. smalltalk.addMethod(
  258. "_initialize",
  259. smalltalk.method({
  260. selector: "initialize",
  261. fn: function (){
  262. var self=this;
  263. return smalltalk.withContext(function($ctx1) { smalltalk.TrappedSingleton.fn.prototype._initialize.apply(_st(self), []);
  264. self["@registry"]=smalltalk.HashedCollection._fromPairs_([]);
  265. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{}, smalltalk.Trapped)})}
  266. }),
  267. smalltalk.Trapped);
  268. smalltalk.addMethod(
  269. "_register_",
  270. smalltalk.method({
  271. selector: "register:",
  272. fn: function (aListKeyedEntity){
  273. var self=this;
  274. return smalltalk.withContext(function($ctx1) { _st(self)._register_name_(aListKeyedEntity,_st(_st(aListKeyedEntity)._class())._name());
  275. return self}, function($ctx1) {$ctx1.fill(self,"register:",{aListKeyedEntity:aListKeyedEntity}, smalltalk.Trapped)})}
  276. }),
  277. smalltalk.Trapped);
  278. smalltalk.addMethod(
  279. "_register_name_",
  280. smalltalk.method({
  281. selector: "register:name:",
  282. fn: function (aListKeyedEntity,aString){
  283. var self=this;
  284. return smalltalk.withContext(function($ctx1) { _st(self["@registry"])._at_put_(aString,aListKeyedEntity);
  285. return self}, function($ctx1) {$ctx1.fill(self,"register:name:",{aListKeyedEntity:aListKeyedEntity,aString:aString}, smalltalk.Trapped)})}
  286. }),
  287. smalltalk.Trapped);
  288. smalltalk.addMethod(
  289. "_start_",
  290. smalltalk.method({
  291. selector: "start:",
  292. fn: function (args){
  293. var self=this;
  294. return smalltalk.withContext(function($ctx1) { var $1,$3,$2;
  295. _st(args)._do_((function(each){
  296. return smalltalk.withContext(function($ctx2) { return _st(self)._register_(each);
  297. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  298. $1=_st("[data-trap]")._asJQuery();
  299. $2=(function(index,elem){
  300. var trap,jq,viewName,modelName,tokens,path;
  301. return smalltalk.withContext(function($ctx2) { jq=_st(elem)._asJQuery();
  302. jq;
  303. trap=_st(jq)._attr_("data-trap");
  304. trap;
  305. tokens=_st(trap)._tokenize_(":");
  306. tokens;
  307. $3=_st(_st(tokens)._size()).__eq((1));
  308. if(smalltalk.assert($3)){
  309. tokens=_st(["TrappedDumbView"]).__comma(tokens);
  310. tokens;
  311. };
  312. viewName=_st(tokens)._first();
  313. viewName;
  314. tokens=_st(_st(_st(tokens)._second())._tokenize_(" "))._select_((function(each){
  315. return smalltalk.withContext(function($ctx3) { return _st(each)._notEmpty();
  316. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx1)})}));
  317. tokens;
  318. modelName=_st(tokens)._first();
  319. modelName;
  320. path=_st((smalltalk.Trapped || Trapped))._parse_(_st(tokens)._allButFirst());
  321. path;
  322. return _st(_st([modelName]).__comma(path))._trapDescend_((function(){
  323. return smalltalk.withContext(function($ctx3) { return _st(_st(_st(_st((smalltalk.Smalltalk || Smalltalk))._current())._at_(viewName))._new())._appendToJQuery_(jq);
  324. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}));
  325. }, function($ctx2) {$ctx2.fillBlock({index:index,elem:elem,trap:trap,jq:jq,viewName:viewName,modelName:modelName,tokens:tokens,path:path},$ctx1)})});
  326. _st($1)._each_($2);
  327. return self}, function($ctx1) {$ctx1.fill(self,"start:",{args:args}, smalltalk.Trapped)})}
  328. }),
  329. smalltalk.Trapped);
  330. smalltalk.addMethod(
  331. "_envelope_loop_before_tag_do_",
  332. smalltalk.method({
  333. selector: "envelope:loop:before:tag:do:",
  334. fn: function (envelope,model,endjq,aSymbol,aBlock){
  335. var self=this;
  336. var envjq;
  337. return smalltalk.withContext(function($ctx1) { envjq=_st(envelope)._asJQuery();
  338. _st(model)._withIndexDo_((function(item,i){
  339. return smalltalk.withContext(function($ctx2) { _st(envelope)._with_((function(html){
  340. return smalltalk.withContext(function($ctx3) { return _st(_st(html)._perform_(aSymbol))._trap_read_([i],aBlock);
  341. }, function($ctx3) {$ctx3.fillBlock({html:html},$ctx1)})}));
  342. return _st(_st(_st(envjq)._children())._detach())._insertBefore_(endjq);
  343. }, function($ctx2) {$ctx2.fillBlock({item:item,i:i},$ctx1)})}));
  344. _st(envjq)._remove();
  345. return self}, function($ctx1) {$ctx1.fill(self,"envelope:loop:before:tag:do:",{envelope:envelope,model:model,endjq:endjq,aSymbol:aSymbol,aBlock:aBlock,envjq:envjq}, smalltalk.Trapped.klass)})}
  346. }),
  347. smalltalk.Trapped.klass);
  348. smalltalk.addMethod(
  349. "_loop_between_and_tag_do_",
  350. smalltalk.method({
  351. selector: "loop:between:and:tag:do:",
  352. fn: function (model,start,end,aSymbol,aBlock){
  353. var self=this;
  354. return smalltalk.withContext(function($ctx1) { var $1;
  355. _st(_st(_st(start)._asJQuery())._nextUntil_(_st(end)._element()))._remove();
  356. _st(start)._with_((function(html){
  357. return smalltalk.withContext(function($ctx2) { $1=model;
  358. if(($receiver = $1) == nil || $receiver == undefined){
  359. return $1;
  360. } else {
  361. return _st(self)._envelope_loop_before_tag_do_(_st(html)._div(),model,_st(end)._asJQuery(),aSymbol,aBlock);
  362. };
  363. }, function($ctx2) {$ctx2.fillBlock({html:html},$ctx1)})}));
  364. return self}, function($ctx1) {$ctx1.fill(self,"loop:between:and:tag:do:",{model:model,start:start,end:end,aSymbol:aSymbol,aBlock:aBlock}, smalltalk.Trapped.klass)})}
  365. }),
  366. smalltalk.Trapped.klass);
  367. smalltalk.addMethod(
  368. "_parse_",
  369. smalltalk.method({
  370. selector: "parse:",
  371. fn: function (anArray){
  372. var self=this;
  373. return smalltalk.withContext(function($ctx1) { var $2,$4,$5,$7,$6,$3,$1;
  374. $2=anArray;
  375. $3=(function(each){
  376. var asNum;
  377. return smalltalk.withContext(function($ctx2) { _st(asNum).__eq(_st(each)._asNumber());
  378. $4=_st(asNum).__eq(asNum);
  379. $5=(function(){
  380. return smalltalk.withContext(function($ctx3) { return asNum;
  381. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})});
  382. $6=(function(){
  383. return smalltalk.withContext(function($ctx3) { $7=_st(_st(each)._first()).__eq("#");
  384. if(smalltalk.assert($7)){
  385. return _st(_st(each)._allButFirst())._asSymbol();
  386. } else {
  387. return each;
  388. };
  389. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})});
  390. return _st($4)._ifTrue_ifFalse_($5,$6);
  391. }, function($ctx2) {$ctx2.fillBlock({each:each,asNum:asNum},$ctx1)})});
  392. $1=_st($2)._collect_($3);
  393. return $1;
  394. }, function($ctx1) {$ctx1.fill(self,"parse:",{anArray:anArray}, smalltalk.Trapped.klass)})}
  395. }),
  396. smalltalk.Trapped.klass);
  397. smalltalk.addClass('TrappedPathStack', smalltalk.TrappedSingleton, ['elements'], 'Trapped-Frontend');
  398. smalltalk.addMethod(
  399. "_append_do_",
  400. smalltalk.method({
  401. selector: "append:do:",
  402. fn: function (anArray,aBlock){
  403. var self=this;
  404. return smalltalk.withContext(function($ctx1) { _st(self)._with_do_(_st(self["@elements"]).__comma(anArray),aBlock);
  405. return self}, function($ctx1) {$ctx1.fill(self,"append:do:",{anArray:anArray,aBlock:aBlock}, smalltalk.TrappedPathStack)})}
  406. }),
  407. smalltalk.TrappedPathStack);
  408. smalltalk.addMethod(
  409. "_elements",
  410. smalltalk.method({
  411. selector: "elements",
  412. fn: function (){
  413. var self=this;
  414. return smalltalk.withContext(function($ctx1) { var $1;
  415. $1=self["@elements"];
  416. return $1;
  417. }, function($ctx1) {$ctx1.fill(self,"elements",{}, smalltalk.TrappedPathStack)})}
  418. }),
  419. smalltalk.TrappedPathStack);
  420. smalltalk.addMethod(
  421. "_initialize",
  422. smalltalk.method({
  423. selector: "initialize",
  424. fn: function (){
  425. var self=this;
  426. return smalltalk.withContext(function($ctx1) { smalltalk.TrappedSingleton.fn.prototype._initialize.apply(_st(self), []);
  427. self["@elements"]=[];
  428. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{}, smalltalk.TrappedPathStack)})}
  429. }),
  430. smalltalk.TrappedPathStack);
  431. smalltalk.addMethod(
  432. "_with_do_",
  433. smalltalk.method({
  434. selector: "with:do:",
  435. fn: function (anArray,aBlock){
  436. var self=this;
  437. var old;
  438. return smalltalk.withContext(function($ctx1) { old=self["@elements"];
  439. _st((function(){
  440. return smalltalk.withContext(function($ctx2) { self["@elements"]=anArray;
  441. self["@elements"];
  442. return _st(aBlock)._value();
  443. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._ensure_((function(){
  444. return smalltalk.withContext(function($ctx2) { self["@elements"]=old;
  445. return self["@elements"];
  446. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  447. return self}, function($ctx1) {$ctx1.fill(self,"with:do:",{anArray:anArray,aBlock:aBlock,old:old}, smalltalk.TrappedPathStack)})}
  448. }),
  449. smalltalk.TrappedPathStack);
  450. smalltalk.addClass('TrappedSnapshot', smalltalk.Object, ['path', 'model'], 'Trapped-Frontend');
  451. smalltalk.addMethod(
  452. "_do_",
  453. smalltalk.method({
  454. selector: "do:",
  455. fn: function (aBlock){
  456. var self=this;
  457. return smalltalk.withContext(function($ctx1) { _st(_st((smalltalk.TrappedPathStack || TrappedPathStack))._current())._with_do_(self["@path"],(function(){
  458. return smalltalk.withContext(function($ctx2) { return _st(aBlock)._value_(self["@model"]);
  459. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  460. return self}, function($ctx1) {$ctx1.fill(self,"do:",{aBlock:aBlock}, smalltalk.TrappedSnapshot)})}
  461. }),
  462. smalltalk.TrappedSnapshot);
  463. smalltalk.addMethod(
  464. "_model",
  465. smalltalk.method({
  466. selector: "model",
  467. fn: function (){
  468. var self=this;
  469. return smalltalk.withContext(function($ctx1) { var $1;
  470. $1=self["@model"];
  471. return $1;
  472. }, function($ctx1) {$ctx1.fill(self,"model",{}, smalltalk.TrappedSnapshot)})}
  473. }),
  474. smalltalk.TrappedSnapshot);
  475. smalltalk.addMethod(
  476. "_modify_",
  477. smalltalk.method({
  478. selector: "modify:",
  479. fn: function (aBlock){
  480. var self=this;
  481. return smalltalk.withContext(function($ctx1) { _st(_st(self)._model())._modify_do_(_st(_st(self)._path())._allButFirst(),aBlock);
  482. return self}, function($ctx1) {$ctx1.fill(self,"modify:",{aBlock:aBlock}, smalltalk.TrappedSnapshot)})}
  483. }),
  484. smalltalk.TrappedSnapshot);
  485. smalltalk.addMethod(
  486. "_path",
  487. smalltalk.method({
  488. selector: "path",
  489. fn: function (){
  490. var self=this;
  491. return smalltalk.withContext(function($ctx1) { var $1;
  492. $1=self["@path"];
  493. return $1;
  494. }, function($ctx1) {$ctx1.fill(self,"path",{}, smalltalk.TrappedSnapshot)})}
  495. }),
  496. smalltalk.TrappedSnapshot);
  497. smalltalk.addMethod(
  498. "_path_model_",
  499. smalltalk.method({
  500. selector: "path:model:",
  501. fn: function (anArray,aTrappedMW){
  502. var self=this;
  503. return smalltalk.withContext(function($ctx1) { self["@path"]=anArray;
  504. self["@model"]=aTrappedMW;
  505. return self}, function($ctx1) {$ctx1.fill(self,"path:model:",{anArray:anArray,aTrappedMW:aTrappedMW}, smalltalk.TrappedSnapshot)})}
  506. }),
  507. smalltalk.TrappedSnapshot);
  508. smalltalk.addMethod(
  509. "_trapDescend_",
  510. smalltalk.method({
  511. selector: "trapDescend:",
  512. fn: function (aBlock){
  513. var self=this;
  514. return smalltalk.withContext(function($ctx1) { _st(_st((smalltalk.Trapped || Trapped))._current())._descend_snapshotDo_(self,aBlock);
  515. return self}, function($ctx1) {$ctx1.fill(self,"trapDescend:",{aBlock:aBlock}, smalltalk.Array)})}
  516. }),
  517. smalltalk.Array);
  518. smalltalk.addMethod(
  519. "_trapIter_tag_do_",
  520. smalltalk.method({
  521. selector: "trapIter:tag:do:",
  522. fn: function (path,aSymbol,aBlock){
  523. var self=this;
  524. var start,end;
  525. return smalltalk.withContext(function($ctx1) { _st(self)._with_((function(html){
  526. return smalltalk.withContext(function($ctx2) { start=_st(html)._script();
  527. start;
  528. end=_st(html)._script();
  529. return end;
  530. }, function($ctx2) {$ctx2.fillBlock({html:html},$ctx1)})}));
  531. _st(start)._trap_read_(path,(function(model){
  532. return smalltalk.withContext(function($ctx2) { return _st((smalltalk.Trapped || Trapped))._loop_between_and_tag_do_(model,start,end,aSymbol,aBlock);
  533. }, function($ctx2) {$ctx2.fillBlock({model:model},$ctx1)})}));
  534. return self}, function($ctx1) {$ctx1.fill(self,"trapIter:tag:do:",{path:path,aSymbol:aSymbol,aBlock:aBlock,start:start,end:end}, smalltalk.HTMLCanvas)})}
  535. }),
  536. smalltalk.HTMLCanvas);
  537. smalltalk.addMethod(
  538. "_trap_",
  539. smalltalk.method({
  540. selector: "trap:",
  541. fn: function (path){
  542. var self=this;
  543. return smalltalk.withContext(function($ctx1) { _st(_st(_st((smalltalk.Trapped || Trapped))._current())._binder_(self))._installFor_(path);
  544. return self}, function($ctx1) {$ctx1.fill(self,"trap:",{path:path}, smalltalk.TagBrush)})}
  545. }),
  546. smalltalk.TagBrush);
  547. smalltalk.addMethod(
  548. "_trap_read_",
  549. smalltalk.method({
  550. selector: "trap:read:",
  551. fn: function (path,aBlock){
  552. var self=this;
  553. return smalltalk.withContext(function($ctx1) { var $1,$3,$4,$6,$5,$2;
  554. $1=path;
  555. $2=(function(snap){
  556. return smalltalk.withContext(function($ctx2) { $3=_st(snap)._model();
  557. $4=_st(_st(snap)._path())._allButFirst();
  558. $5=(function(data){
  559. return smalltalk.withContext(function($ctx3) { $6=_st(_st(_st(_st(self)._asJQuery())._closest_("html"))._toArray())._isEmpty();
  560. if(smalltalk.assert($6)){
  561. _st((smalltalk.KeyedPubSubUnsubscribe || KeyedPubSubUnsubscribe))._signal();
  562. };
  563. return _st(snap)._do_((function(){
  564. return smalltalk.withContext(function($ctx4) { return _st(self)._with_((function(html){
  565. return smalltalk.withContext(function($ctx5) { return _st(aBlock)._value_value_(data,html);
  566. }, function($ctx5) {$ctx5.fillBlock({html:html},$ctx1)})}));
  567. }, function($ctx4) {$ctx4.fillBlock({},$ctx1)})}));
  568. }, function($ctx3) {$ctx3.fillBlock({data:data},$ctx1)})});
  569. return _st($3)._watch_do_($4,$5);
  570. }, function($ctx2) {$ctx2.fillBlock({snap:snap},$ctx1)})});
  571. _st($1)._trapDescend_($2);
  572. return self}, function($ctx1) {$ctx1.fill(self,"trap:read:",{path:path,aBlock:aBlock}, smalltalk.TagBrush)})}
  573. }),
  574. smalltalk.TagBrush);
  575. smalltalk.addMethod(
  576. "_trap_toggle_",
  577. smalltalk.method({
  578. selector: "trap:toggle:",
  579. fn: function (path,aBlock){
  580. var self=this;
  581. return smalltalk.withContext(function($ctx1) { _st(self)._trap_toggle_ifNotPresent_(path,aBlock,(function(){
  582. return smalltalk.withContext(function($ctx2) { return _st(_st(self)._asJQuery())._hide();
  583. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  584. return self}, function($ctx1) {$ctx1.fill(self,"trap:toggle:",{path:path,aBlock:aBlock}, smalltalk.TagBrush)})}
  585. }),
  586. smalltalk.TagBrush);
  587. smalltalk.addMethod(
  588. "_trap_toggle_ifNotPresent_",
  589. smalltalk.method({
  590. selector: "trap:toggle:ifNotPresent:",
  591. fn: function (path,aBlock,anotherBlock){
  592. var self=this;
  593. var shown;
  594. return smalltalk.withContext(function($ctx1) { var $1,$2,$4,$6,$7,$9,$8,$5,$3;
  595. shown=nil;
  596. $1=self;
  597. $2=path;
  598. $3=(function(data,html){
  599. return smalltalk.withContext(function($ctx2) { $4=_st(shown).__eq(_st(data)._notNil());
  600. $5=(function(){
  601. return smalltalk.withContext(function($ctx3) { shown=_st(data)._notNil();
  602. shown;
  603. $6=_st(self)._asJQuery();
  604. _st($6)._empty();
  605. $7=_st($6)._show();
  606. $7;
  607. $9=shown;
  608. if(smalltalk.assert($9)){
  609. $8=aBlock;
  610. } else {
  611. $8=anotherBlock;
  612. };
  613. return _st($8)._value_value_(data,html);
  614. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})});
  615. return _st($4)._ifFalse_($5);
  616. }, function($ctx2) {$ctx2.fillBlock({data:data,html:html},$ctx1)})});
  617. _st($1)._trap_read_($2,$3);
  618. return self}, function($ctx1) {$ctx1.fill(self,"trap:toggle:ifNotPresent:",{path:path,aBlock:aBlock,anotherBlock:anotherBlock,shown:shown}, smalltalk.TagBrush)})}
  619. }),
  620. smalltalk.TagBrush);