Trapped-Frontend.deploy.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  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. messageSends: []}),
  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. messageSends: ["trap:read:", "showBlock"]}),
  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. messageSends: []}),
  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. messageSends: ["empty", "with:", "ifNil:"]}),
  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. messageSends: ["installFor:", "trapDescend:", "onChange:", "modify:", "notNil", "attr:", "asJQuery"]}),
  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. messageSends: ["attr:put:", "ifNotNil:ifNil:", "prim:", "asJQuery"]}),
  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. messageSends: ["installFor:", "trapDescend:", "onChange:", "modify:", "val", "asJQuery"]}),
  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. messageSends: ["val:", "ifNotNil:ifNil:", "prim:", "asJQuery"]}),
  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. messageSends: ["trap:", "root"]}),
  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. messageSends: ["subclassResponsibility"]}),
  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. messageSends: ["ifNil:", "new"]}),
  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. messageSends: ["start:", "current"]}),
  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,$2,$3,$4,$6,$7,$5;
  193. tag=_st(_st(aTagBrush)._element())._nodeName();
  194. $1=_st(tag).__eq("INPUT");
  195. if(smalltalk.assert($1)){
  196. type=_st(_st(aTagBrush)._asJQuery())._attr_("type");
  197. type;
  198. $2=_st(type).__eq("checkbox");
  199. if(smalltalk.assert($2)){
  200. binder=_st((smalltalk.TrappedCheckedBinder || TrappedCheckedBinder))._new();
  201. binder;
  202. };
  203. $3=_st(type).__eq("text");
  204. if(smalltalk.assert($3)){
  205. binder=_st((smalltalk.TrappedValBinder || TrappedValBinder))._new();
  206. binder;
  207. };
  208. };
  209. $4=binder;
  210. if(($receiver = $4) == nil || $receiver == undefined){
  211. binder=_st((smalltalk.TrappedBinder || TrappedBinder))._new();
  212. binder;
  213. } else {
  214. $4;
  215. };
  216. $6=binder;
  217. _st($6)._brush_(aTagBrush);
  218. $7=_st($6)._yourself();
  219. $5=$7;
  220. return $5;
  221. }, function($ctx1) {$ctx1.fill(self,"binder:",{aTagBrush:aTagBrush,binder:binder,tag:tag},smalltalk.Trapped)})},
  222. messageSends: ["nodeName", "element", "ifTrue:", "attr:", "asJQuery", "new", "=", "ifNil:", "brush:", "yourself"]}),
  223. smalltalk.Trapped);
  224. smalltalk.addMethod(
  225. "_byName_",
  226. smalltalk.method({
  227. selector: "byName:",
  228. fn: function (aString){
  229. var self=this;
  230. return smalltalk.withContext(function($ctx1) { var $1;
  231. $1=_st(self["@registry"])._at_(aString);
  232. return $1;
  233. }, function($ctx1) {$ctx1.fill(self,"byName:",{aString:aString},smalltalk.Trapped)})},
  234. messageSends: ["at:"]}),
  235. smalltalk.Trapped);
  236. smalltalk.addMethod(
  237. "_descend_snapshotDo_",
  238. smalltalk.method({
  239. selector: "descend:snapshotDo:",
  240. fn: function (anArray,aBlock){
  241. var self=this;
  242. var tpsc;
  243. return smalltalk.withContext(function($ctx1) { tpsc=_st((smalltalk.TrappedPathStack || TrappedPathStack))._current();
  244. _st(tpsc)._append_do_(anArray,(function(){
  245. var path,model;
  246. return smalltalk.withContext(function($ctx2) { path=_st(_st(tpsc)._elements())._copy();
  247. path;
  248. model=_st(self)._byName_(_st(path)._first());
  249. model;
  250. return _st(aBlock)._value_(_st(_st((smalltalk.TrappedSnapshot || TrappedSnapshot))._new())._path_model_(path,model));
  251. }, function($ctx2) {$ctx2.fillBlock({path:path,model:model},$ctx1)})}));
  252. return self}, function($ctx1) {$ctx1.fill(self,"descend:snapshotDo:",{anArray:anArray,aBlock:aBlock,tpsc:tpsc},smalltalk.Trapped)})},
  253. messageSends: ["current", "append:do:", "copy", "elements", "byName:", "first", "value:", "path:model:", "new"]}),
  254. smalltalk.Trapped);
  255. smalltalk.addMethod(
  256. "_initialize",
  257. smalltalk.method({
  258. selector: "initialize",
  259. fn: function (){
  260. var self=this;
  261. return smalltalk.withContext(function($ctx1) { smalltalk.TrappedSingleton.fn.prototype._initialize.apply(_st(self), []);
  262. self["@registry"]=smalltalk.HashedCollection._fromPairs_([]);
  263. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.Trapped)})},
  264. messageSends: ["initialize"]}),
  265. smalltalk.Trapped);
  266. smalltalk.addMethod(
  267. "_register_",
  268. smalltalk.method({
  269. selector: "register:",
  270. fn: function (aListKeyedEntity){
  271. var self=this;
  272. return smalltalk.withContext(function($ctx1) { _st(self)._register_name_(aListKeyedEntity,_st(_st(aListKeyedEntity)._class())._name());
  273. return self}, function($ctx1) {$ctx1.fill(self,"register:",{aListKeyedEntity:aListKeyedEntity},smalltalk.Trapped)})},
  274. messageSends: ["register:name:", "name", "class"]}),
  275. smalltalk.Trapped);
  276. smalltalk.addMethod(
  277. "_register_name_",
  278. smalltalk.method({
  279. selector: "register:name:",
  280. fn: function (aListKeyedEntity,aString){
  281. var self=this;
  282. return smalltalk.withContext(function($ctx1) { _st(self["@registry"])._at_put_(aString,aListKeyedEntity);
  283. return self}, function($ctx1) {$ctx1.fill(self,"register:name:",{aListKeyedEntity:aListKeyedEntity,aString:aString},smalltalk.Trapped)})},
  284. messageSends: ["at:put:"]}),
  285. smalltalk.Trapped);
  286. smalltalk.addMethod(
  287. "_start_",
  288. smalltalk.method({
  289. selector: "start:",
  290. fn: function (args){
  291. var self=this;
  292. return smalltalk.withContext(function($ctx1) { var $1;
  293. _st(args)._do_((function(each){
  294. return smalltalk.withContext(function($ctx2) { return _st(self)._register_(each);
  295. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  296. _st(_st("[data-trap]")._asJQuery())._each_((function(index,elem){
  297. var trap,jq,viewName,modelName,tokens,path;
  298. return smalltalk.withContext(function($ctx2) { jq=_st(elem)._asJQuery();
  299. jq;
  300. trap=_st(jq)._attr_("data-trap");
  301. trap;
  302. tokens=_st(trap)._tokenize_(":");
  303. tokens;
  304. $1=_st(_st(tokens)._size()).__eq((1));
  305. if(smalltalk.assert($1)){
  306. tokens=_st(["TrappedDumbView"]).__comma(tokens);
  307. tokens;
  308. };
  309. viewName=_st(tokens)._first();
  310. viewName;
  311. tokens=_st(_st(_st(tokens)._second())._tokenize_(" "))._select_((function(each){
  312. return smalltalk.withContext(function($ctx3) { return _st(each)._notEmpty();
  313. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx1)})}));
  314. tokens;
  315. modelName=_st(tokens)._first();
  316. modelName;
  317. path=_st((smalltalk.Trapped || Trapped))._parse_(_st(tokens)._allButFirst());
  318. path;
  319. return _st(_st([modelName]).__comma(path))._trapDescend_((function(){
  320. return smalltalk.withContext(function($ctx3) { return _st(_st(_st(_st((smalltalk.Smalltalk || Smalltalk))._current())._at_(viewName))._new())._appendToJQuery_(jq);
  321. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}));
  322. }, function($ctx2) {$ctx2.fillBlock({index:index,elem:elem,trap:trap,jq:jq,viewName:viewName,modelName:modelName,tokens:tokens,path:path},$ctx1)})}));
  323. return self}, function($ctx1) {$ctx1.fill(self,"start:",{args:args},smalltalk.Trapped)})},
  324. messageSends: ["do:", "register:", "each:", "asJQuery", "attr:", "tokenize:", "ifTrue:", ",", "=", "size", "first", "select:", "notEmpty", "second", "parse:", "allButFirst", "trapDescend:", "appendToJQuery:", "new", "at:", "current"]}),
  325. smalltalk.Trapped);
  326. smalltalk.addMethod(
  327. "_envelope_loop_before_tag_do_",
  328. smalltalk.method({
  329. selector: "envelope:loop:before:tag:do:",
  330. fn: function (envelope,model,endjq,aSymbol,aBlock){
  331. var self=this;
  332. var envjq;
  333. return smalltalk.withContext(function($ctx1) { envjq=_st(envelope)._asJQuery();
  334. _st(model)._withIndexDo_((function(item,i){
  335. return smalltalk.withContext(function($ctx2) { _st(envelope)._with_((function(html){
  336. return smalltalk.withContext(function($ctx3) { return _st(_st(html)._perform_(aSymbol))._trap_read_([i],aBlock);
  337. }, function($ctx3) {$ctx3.fillBlock({html:html},$ctx1)})}));
  338. return _st(_st(_st(envjq)._children())._detach())._insertBefore_(endjq);
  339. }, function($ctx2) {$ctx2.fillBlock({item:item,i:i},$ctx1)})}));
  340. _st(envjq)._remove();
  341. 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)})},
  342. messageSends: ["asJQuery", "withIndexDo:", "with:", "trap:read:", "perform:", "insertBefore:", "detach", "children", "remove"]}),
  343. smalltalk.Trapped.klass);
  344. smalltalk.addMethod(
  345. "_loop_between_and_tag_do_",
  346. smalltalk.method({
  347. selector: "loop:between:and:tag:do:",
  348. fn: function (model,start,end,aSymbol,aBlock){
  349. var self=this;
  350. return smalltalk.withContext(function($ctx1) { var $1;
  351. _st(_st(_st(start)._asJQuery())._nextUntil_(_st(end)._element()))._remove();
  352. _st(start)._with_((function(html){
  353. return smalltalk.withContext(function($ctx2) { $1=model;
  354. if(($receiver = $1) == nil || $receiver == undefined){
  355. return $1;
  356. } else {
  357. return _st(self)._envelope_loop_before_tag_do_(_st(html)._div(),model,_st(end)._asJQuery(),aSymbol,aBlock);
  358. };
  359. }, function($ctx2) {$ctx2.fillBlock({html:html},$ctx1)})}));
  360. 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)})},
  361. messageSends: ["remove", "nextUntil:", "element", "asJQuery", "with:", "ifNotNil:", "envelope:loop:before:tag:do:", "div"]}),
  362. smalltalk.Trapped.klass);
  363. smalltalk.addMethod(
  364. "_parse_",
  365. smalltalk.method({
  366. selector: "parse:",
  367. fn: function (anArray){
  368. var self=this;
  369. return smalltalk.withContext(function($ctx1) {
  370. var $2,$3,$1;
  371. $1=_st(anArray)._collect_((function(each){
  372. var asNum;
  373. return smalltalk.withContext(function($ctx2) {
  374. asNum=_st(each)._asNumber();
  375. asNum;
  376. $2=_st(asNum).__eq(asNum);
  377. if(smalltalk.assert($2)){
  378. return asNum;
  379. } else {
  380. $3=_st(_st(each)._first()).__eq("#");
  381. if(smalltalk.assert($3)){
  382. return [_st(each)._allButFirst()];
  383. } else {
  384. return each;
  385. };
  386. };
  387. }, function($ctx2) {$ctx2.fillBlock({each:each,asNum:asNum},$ctx1)})}));
  388. return $1;
  389. }, function($ctx1) {$ctx1.fill(self,"parse:",{anArray:anArray},smalltalk.Trapped.klass)})},
  390. messageSends: ["collect:", "asNumber", "ifTrue:ifFalse:", "allButFirst", "=", "first"]}),
  391. smalltalk.Trapped.klass);
  392. smalltalk.addClass('TrappedPathStack', smalltalk.TrappedSingleton, ['elements'], 'Trapped-Frontend');
  393. smalltalk.addMethod(
  394. "_append_do_",
  395. smalltalk.method({
  396. selector: "append:do:",
  397. fn: function (anArray,aBlock){
  398. var self=this;
  399. return smalltalk.withContext(function($ctx1) { _st(self)._with_do_(_st(self["@elements"]).__comma(anArray),aBlock);
  400. return self}, function($ctx1) {$ctx1.fill(self,"append:do:",{anArray:anArray,aBlock:aBlock},smalltalk.TrappedPathStack)})},
  401. messageSends: ["with:do:", ","]}),
  402. smalltalk.TrappedPathStack);
  403. smalltalk.addMethod(
  404. "_elements",
  405. smalltalk.method({
  406. selector: "elements",
  407. fn: function (){
  408. var self=this;
  409. return smalltalk.withContext(function($ctx1) { var $1;
  410. $1=self["@elements"];
  411. return $1;
  412. }, function($ctx1) {$ctx1.fill(self,"elements",{},smalltalk.TrappedPathStack)})},
  413. messageSends: []}),
  414. smalltalk.TrappedPathStack);
  415. smalltalk.addMethod(
  416. "_initialize",
  417. smalltalk.method({
  418. selector: "initialize",
  419. fn: function (){
  420. var self=this;
  421. return smalltalk.withContext(function($ctx1) { smalltalk.TrappedSingleton.fn.prototype._initialize.apply(_st(self), []);
  422. self["@elements"]=[];
  423. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.TrappedPathStack)})},
  424. messageSends: ["initialize"]}),
  425. smalltalk.TrappedPathStack);
  426. smalltalk.addMethod(
  427. "_with_do_",
  428. smalltalk.method({
  429. selector: "with:do:",
  430. fn: function (anArray,aBlock){
  431. var self=this;
  432. var old;
  433. return smalltalk.withContext(function($ctx1) { old=self["@elements"];
  434. _st((function(){
  435. return smalltalk.withContext(function($ctx2) { self["@elements"]=anArray;
  436. self["@elements"];
  437. return _st(aBlock)._value();
  438. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._ensure_((function(){
  439. return smalltalk.withContext(function($ctx2) { self["@elements"]=old;
  440. return self["@elements"];
  441. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  442. return self}, function($ctx1) {$ctx1.fill(self,"with:do:",{anArray:anArray,aBlock:aBlock,old:old},smalltalk.TrappedPathStack)})},
  443. messageSends: ["ensure:", "value"]}),
  444. smalltalk.TrappedPathStack);
  445. smalltalk.addClass('TrappedSnapshot', smalltalk.Object, ['path', 'model'], 'Trapped-Frontend');
  446. smalltalk.addMethod(
  447. "_do_",
  448. smalltalk.method({
  449. selector: "do:",
  450. fn: function (aBlock){
  451. var self=this;
  452. return smalltalk.withContext(function($ctx1) { _st(_st((smalltalk.TrappedPathStack || TrappedPathStack))._current())._with_do_(self["@path"],(function(){
  453. return smalltalk.withContext(function($ctx2) { return _st(aBlock)._value_(self["@model"]);
  454. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  455. return self}, function($ctx1) {$ctx1.fill(self,"do:",{aBlock:aBlock},smalltalk.TrappedSnapshot)})},
  456. messageSends: ["with:do:", "value:", "current"]}),
  457. smalltalk.TrappedSnapshot);
  458. smalltalk.addMethod(
  459. "_model",
  460. smalltalk.method({
  461. selector: "model",
  462. fn: function (){
  463. var self=this;
  464. return smalltalk.withContext(function($ctx1) { var $1;
  465. $1=self["@model"];
  466. return $1;
  467. }, function($ctx1) {$ctx1.fill(self,"model",{},smalltalk.TrappedSnapshot)})},
  468. messageSends: []}),
  469. smalltalk.TrappedSnapshot);
  470. smalltalk.addMethod(
  471. "_modify_",
  472. smalltalk.method({
  473. selector: "modify:",
  474. fn: function (aBlock){
  475. var self=this;
  476. return smalltalk.withContext(function($ctx1) { _st(_st(self)._model())._modify_do_(_st(_st(self)._path())._allButFirst(),aBlock);
  477. return self}, function($ctx1) {$ctx1.fill(self,"modify:",{aBlock:aBlock},smalltalk.TrappedSnapshot)})},
  478. messageSends: ["modify:do:", "allButFirst", "path", "model"]}),
  479. smalltalk.TrappedSnapshot);
  480. smalltalk.addMethod(
  481. "_path",
  482. smalltalk.method({
  483. selector: "path",
  484. fn: function (){
  485. var self=this;
  486. return smalltalk.withContext(function($ctx1) { var $1;
  487. $1=self["@path"];
  488. return $1;
  489. }, function($ctx1) {$ctx1.fill(self,"path",{},smalltalk.TrappedSnapshot)})},
  490. messageSends: []}),
  491. smalltalk.TrappedSnapshot);
  492. smalltalk.addMethod(
  493. "_path_model_",
  494. smalltalk.method({
  495. selector: "path:model:",
  496. fn: function (anArray,aTrappedMW){
  497. var self=this;
  498. return smalltalk.withContext(function($ctx1) { self["@path"]=anArray;
  499. self["@model"]=aTrappedMW;
  500. return self}, function($ctx1) {$ctx1.fill(self,"path:model:",{anArray:anArray,aTrappedMW:aTrappedMW},smalltalk.TrappedSnapshot)})},
  501. messageSends: []}),
  502. smalltalk.TrappedSnapshot);
  503. smalltalk.addMethod(
  504. "_trapDescend_",
  505. smalltalk.method({
  506. selector: "trapDescend:",
  507. fn: function (aBlock){
  508. var self=this;
  509. return smalltalk.withContext(function($ctx1) { _st(_st((smalltalk.Trapped || Trapped))._current())._descend_snapshotDo_(self,aBlock);
  510. return self}, function($ctx1) {$ctx1.fill(self,"trapDescend:",{aBlock:aBlock}, smalltalk.Array)})},
  511. messageSends: ["descend:snapshotDo:", "current"]}),
  512. smalltalk.Array);
  513. smalltalk.addMethod(
  514. "_trapIter_tag_do_",
  515. smalltalk.method({
  516. selector: "trapIter:tag:do:",
  517. fn: function (path,aSymbol,aBlock){
  518. var self=this;
  519. var start,end;
  520. return smalltalk.withContext(function($ctx1) { _st(self)._with_((function(html){
  521. return smalltalk.withContext(function($ctx2) { start=_st(html)._script();
  522. start;
  523. end=_st(html)._script();
  524. return end;
  525. }, function($ctx2) {$ctx2.fillBlock({html:html},$ctx1)})}));
  526. _st(start)._trap_read_(path,(function(model){
  527. return smalltalk.withContext(function($ctx2) { return _st((smalltalk.Trapped || Trapped))._loop_between_and_tag_do_(model,start,end,aSymbol,aBlock);
  528. }, function($ctx2) {$ctx2.fillBlock({model:model},$ctx1)})}));
  529. return self}, function($ctx1) {$ctx1.fill(self,"trapIter:tag:do:",{path:path,aSymbol:aSymbol,aBlock:aBlock,start:start,end:end}, smalltalk.HTMLCanvas)})},
  530. messageSends: ["with:", "script", "trap:read:", "loop:between:and:tag:do:"]}),
  531. smalltalk.HTMLCanvas);
  532. smalltalk.addMethod(
  533. "_trap_",
  534. smalltalk.method({
  535. selector: "trap:",
  536. fn: function (path){
  537. var self=this;
  538. return smalltalk.withContext(function($ctx1) { _st(_st(_st((smalltalk.Trapped || Trapped))._current())._binder_(self))._installFor_(path);
  539. return self}, function($ctx1) {$ctx1.fill(self,"trap:",{path:path}, smalltalk.TagBrush)})},
  540. messageSends: ["installFor:", "binder:", "current"]}),
  541. smalltalk.TagBrush);
  542. smalltalk.addMethod(
  543. "_trap_read_",
  544. smalltalk.method({
  545. selector: "trap:read:",
  546. fn: function (path,aBlock){
  547. var self=this;
  548. return smalltalk.withContext(function($ctx1) { var $1,$3,$4,$6,$5,$2;
  549. $1=path;
  550. $2=(function(snap){
  551. return smalltalk.withContext(function($ctx2) { $3=_st(snap)._model();
  552. $4=_st(_st(snap)._path())._allButFirst();
  553. $5=(function(data){
  554. return smalltalk.withContext(function($ctx3) { $6=_st(_st(_st(_st(self)._asJQuery())._closest_("html"))._toArray())._isEmpty();
  555. if(smalltalk.assert($6)){
  556. _st((smalltalk.KeyedPubSubUnsubscribe || KeyedPubSubUnsubscribe))._signal();
  557. };
  558. return _st(snap)._do_((function(){
  559. return smalltalk.withContext(function($ctx4) { return _st(self)._with_((function(html){
  560. return smalltalk.withContext(function($ctx5) { return _st(aBlock)._value_value_(data,html);
  561. }, function($ctx5) {$ctx5.fillBlock({html:html},$ctx1)})}));
  562. }, function($ctx4) {$ctx4.fillBlock({},$ctx1)})}));
  563. }, function($ctx3) {$ctx3.fillBlock({data:data},$ctx1)})});
  564. return _st($3)._watch_do_($4,$5);
  565. }, function($ctx2) {$ctx2.fillBlock({snap:snap},$ctx1)})});
  566. _st($1)._trapDescend_($2);
  567. return self}, function($ctx1) {$ctx1.fill(self,"trap:read:",{path:path,aBlock:aBlock}, smalltalk.TagBrush)})},
  568. messageSends: ["trapDescend:", "watch:do:", "allButFirst", "path", "ifTrue:", "signal", "isEmpty", "toArray", "closest:", "asJQuery", "do:", "with:", "value:value:", "model"]}),
  569. smalltalk.TagBrush);
  570. smalltalk.addMethod(
  571. "_trap_toggle_",
  572. smalltalk.method({
  573. selector: "trap:toggle:",
  574. fn: function (path,aBlock){
  575. var self=this;
  576. return smalltalk.withContext(function($ctx1) { _st(self)._trap_toggle_ifNotPresent_(path,aBlock,(function(){
  577. return smalltalk.withContext(function($ctx2) { return _st(_st(self)._asJQuery())._hide();
  578. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  579. return self}, function($ctx1) {$ctx1.fill(self,"trap:toggle:",{path:path,aBlock:aBlock}, smalltalk.TagBrush)})},
  580. messageSends: ["trap:toggle:ifNotPresent:", "hide", "asJQuery"]}),
  581. smalltalk.TagBrush);
  582. smalltalk.addMethod(
  583. "_trap_toggle_ifNotPresent_",
  584. smalltalk.method({
  585. selector: "trap:toggle:ifNotPresent:",
  586. fn: function (path,aBlock,anotherBlock){
  587. var self=this;
  588. var shown;
  589. return smalltalk.withContext(function($ctx1) { var $1,$2,$4,$6,$7,$9,$8,$5,$3;
  590. shown=nil;
  591. $1=self;
  592. $2=path;
  593. $3=(function(data,html){
  594. return smalltalk.withContext(function($ctx2) { $4=_st(shown).__eq(_st(data)._notNil());
  595. $5=(function(){
  596. return smalltalk.withContext(function($ctx3) { shown=_st(data)._notNil();
  597. shown;
  598. $6=_st(self)._asJQuery();
  599. _st($6)._empty();
  600. $7=_st($6)._show();
  601. $7;
  602. $9=shown;
  603. if(smalltalk.assert($9)){
  604. $8=aBlock;
  605. } else {
  606. $8=anotherBlock;
  607. };
  608. return _st($8)._value_value_(data,html);
  609. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})});
  610. return _st($4)._ifFalse_($5);
  611. }, function($ctx2) {$ctx2.fillBlock({data:data,html:html},$ctx1)})});
  612. _st($1)._trap_read_($2,$3);
  613. return self}, function($ctx1) {$ctx1.fill(self,"trap:toggle:ifNotPresent:",{path:path,aBlock:aBlock,anotherBlock:anotherBlock,shown:shown}, smalltalk.TagBrush)})},
  614. messageSends: ["trap:read:", "ifFalse:", "notNil", "empty", "asJQuery", "show", "value:value:", "ifTrue:ifFalse:", "="]}),
  615. smalltalk.TagBrush);