Trapped-Frontend.deploy.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  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) { var $2,$3,$1;
  370. $1=_st(anArray)._collect_((function(each){
  371. var asNum;
  372. return smalltalk.withContext(function($ctx2) { _st(asNum).__eq(_st(each)._asNumber());
  373. $2=_st(asNum).__eq(asNum);
  374. if(smalltalk.assert($2)){
  375. return asNum;
  376. } else {
  377. $3=_st(_st(each)._first()).__eq("#");
  378. if(smalltalk.assert($3)){
  379. return _st(_st(each)._allButFirst())._asSymbol();
  380. } else {
  381. return each;
  382. };
  383. };
  384. }, function($ctx2) {$ctx2.fillBlock({each:each,asNum:asNum},$ctx1)})}));
  385. return $1;
  386. }, function($ctx1) {$ctx1.fill(self,"parse:",{anArray:anArray},smalltalk.Trapped.klass)})},
  387. messageSends: ["collect:", "=", "asNumber", "ifTrue:ifFalse:", "asSymbol", "allButFirst", "first"]}),
  388. smalltalk.Trapped.klass);
  389. smalltalk.addClass('TrappedPathStack', smalltalk.TrappedSingleton, ['elements'], 'Trapped-Frontend');
  390. smalltalk.addMethod(
  391. "_append_do_",
  392. smalltalk.method({
  393. selector: "append:do:",
  394. fn: function (anArray,aBlock){
  395. var self=this;
  396. return smalltalk.withContext(function($ctx1) { _st(self)._with_do_(_st(self["@elements"]).__comma(anArray),aBlock);
  397. return self}, function($ctx1) {$ctx1.fill(self,"append:do:",{anArray:anArray,aBlock:aBlock},smalltalk.TrappedPathStack)})},
  398. messageSends: ["with:do:", ","]}),
  399. smalltalk.TrappedPathStack);
  400. smalltalk.addMethod(
  401. "_elements",
  402. smalltalk.method({
  403. selector: "elements",
  404. fn: function (){
  405. var self=this;
  406. return smalltalk.withContext(function($ctx1) { var $1;
  407. $1=self["@elements"];
  408. return $1;
  409. }, function($ctx1) {$ctx1.fill(self,"elements",{},smalltalk.TrappedPathStack)})},
  410. messageSends: []}),
  411. smalltalk.TrappedPathStack);
  412. smalltalk.addMethod(
  413. "_initialize",
  414. smalltalk.method({
  415. selector: "initialize",
  416. fn: function (){
  417. var self=this;
  418. return smalltalk.withContext(function($ctx1) { smalltalk.TrappedSingleton.fn.prototype._initialize.apply(_st(self), []);
  419. self["@elements"]=[];
  420. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.TrappedPathStack)})},
  421. messageSends: ["initialize"]}),
  422. smalltalk.TrappedPathStack);
  423. smalltalk.addMethod(
  424. "_with_do_",
  425. smalltalk.method({
  426. selector: "with:do:",
  427. fn: function (anArray,aBlock){
  428. var self=this;
  429. var old;
  430. return smalltalk.withContext(function($ctx1) { old=self["@elements"];
  431. _st((function(){
  432. return smalltalk.withContext(function($ctx2) { self["@elements"]=anArray;
  433. self["@elements"];
  434. return _st(aBlock)._value();
  435. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._ensure_((function(){
  436. return smalltalk.withContext(function($ctx2) { self["@elements"]=old;
  437. return self["@elements"];
  438. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  439. return self}, function($ctx1) {$ctx1.fill(self,"with:do:",{anArray:anArray,aBlock:aBlock,old:old},smalltalk.TrappedPathStack)})},
  440. messageSends: ["ensure:", "value"]}),
  441. smalltalk.TrappedPathStack);
  442. smalltalk.addClass('TrappedSnapshot', smalltalk.Object, ['path', 'model'], 'Trapped-Frontend');
  443. smalltalk.addMethod(
  444. "_do_",
  445. smalltalk.method({
  446. selector: "do:",
  447. fn: function (aBlock){
  448. var self=this;
  449. return smalltalk.withContext(function($ctx1) { _st(_st((smalltalk.TrappedPathStack || TrappedPathStack))._current())._with_do_(self["@path"],(function(){
  450. return smalltalk.withContext(function($ctx2) { return _st(aBlock)._value_(self["@model"]);
  451. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  452. return self}, function($ctx1) {$ctx1.fill(self,"do:",{aBlock:aBlock},smalltalk.TrappedSnapshot)})},
  453. messageSends: ["with:do:", "value:", "current"]}),
  454. smalltalk.TrappedSnapshot);
  455. smalltalk.addMethod(
  456. "_model",
  457. smalltalk.method({
  458. selector: "model",
  459. fn: function (){
  460. var self=this;
  461. return smalltalk.withContext(function($ctx1) { var $1;
  462. $1=self["@model"];
  463. return $1;
  464. }, function($ctx1) {$ctx1.fill(self,"model",{},smalltalk.TrappedSnapshot)})},
  465. messageSends: []}),
  466. smalltalk.TrappedSnapshot);
  467. smalltalk.addMethod(
  468. "_modify_",
  469. smalltalk.method({
  470. selector: "modify:",
  471. fn: function (aBlock){
  472. var self=this;
  473. return smalltalk.withContext(function($ctx1) { _st(_st(self)._model())._modify_do_(_st(_st(self)._path())._allButFirst(),aBlock);
  474. return self}, function($ctx1) {$ctx1.fill(self,"modify:",{aBlock:aBlock},smalltalk.TrappedSnapshot)})},
  475. messageSends: ["modify:do:", "allButFirst", "path", "model"]}),
  476. smalltalk.TrappedSnapshot);
  477. smalltalk.addMethod(
  478. "_path",
  479. smalltalk.method({
  480. selector: "path",
  481. fn: function (){
  482. var self=this;
  483. return smalltalk.withContext(function($ctx1) { var $1;
  484. $1=self["@path"];
  485. return $1;
  486. }, function($ctx1) {$ctx1.fill(self,"path",{},smalltalk.TrappedSnapshot)})},
  487. messageSends: []}),
  488. smalltalk.TrappedSnapshot);
  489. smalltalk.addMethod(
  490. "_path_model_",
  491. smalltalk.method({
  492. selector: "path:model:",
  493. fn: function (anArray,aTrappedMW){
  494. var self=this;
  495. return smalltalk.withContext(function($ctx1) { self["@path"]=anArray;
  496. self["@model"]=aTrappedMW;
  497. return self}, function($ctx1) {$ctx1.fill(self,"path:model:",{anArray:anArray,aTrappedMW:aTrappedMW},smalltalk.TrappedSnapshot)})},
  498. messageSends: []}),
  499. smalltalk.TrappedSnapshot);
  500. smalltalk.addMethod(
  501. "_trapDescend_",
  502. smalltalk.method({
  503. selector: "trapDescend:",
  504. fn: function (aBlock){
  505. var self=this;
  506. return smalltalk.withContext(function($ctx1) { _st(_st((smalltalk.Trapped || Trapped))._current())._descend_snapshotDo_(self,aBlock);
  507. return self}, function($ctx1) {$ctx1.fill(self,"trapDescend:",{aBlock:aBlock}, smalltalk.Array)})},
  508. messageSends: ["descend:snapshotDo:", "current"]}),
  509. smalltalk.Array);
  510. smalltalk.addMethod(
  511. "_trapIter_tag_do_",
  512. smalltalk.method({
  513. selector: "trapIter:tag:do:",
  514. fn: function (path,aSymbol,aBlock){
  515. var self=this;
  516. var start,end;
  517. return smalltalk.withContext(function($ctx1) { _st(self)._with_((function(html){
  518. return smalltalk.withContext(function($ctx2) { start=_st(html)._script();
  519. start;
  520. end=_st(html)._script();
  521. return end;
  522. }, function($ctx2) {$ctx2.fillBlock({html:html},$ctx1)})}));
  523. _st(start)._trap_read_(path,(function(model){
  524. return smalltalk.withContext(function($ctx2) { return _st((smalltalk.Trapped || Trapped))._loop_between_and_tag_do_(model,start,end,aSymbol,aBlock);
  525. }, function($ctx2) {$ctx2.fillBlock({model:model},$ctx1)})}));
  526. return self}, function($ctx1) {$ctx1.fill(self,"trapIter:tag:do:",{path:path,aSymbol:aSymbol,aBlock:aBlock,start:start,end:end}, smalltalk.HTMLCanvas)})},
  527. messageSends: ["with:", "script", "trap:read:", "loop:between:and:tag:do:"]}),
  528. smalltalk.HTMLCanvas);
  529. smalltalk.addMethod(
  530. "_trap_",
  531. smalltalk.method({
  532. selector: "trap:",
  533. fn: function (path){
  534. var self=this;
  535. return smalltalk.withContext(function($ctx1) { _st(_st(_st((smalltalk.Trapped || Trapped))._current())._binder_(self))._installFor_(path);
  536. return self}, function($ctx1) {$ctx1.fill(self,"trap:",{path:path}, smalltalk.TagBrush)})},
  537. messageSends: ["installFor:", "binder:", "current"]}),
  538. smalltalk.TagBrush);
  539. smalltalk.addMethod(
  540. "_trap_read_",
  541. smalltalk.method({
  542. selector: "trap:read:",
  543. fn: function (path,aBlock){
  544. var self=this;
  545. return smalltalk.withContext(function($ctx1) { var $1,$3,$4,$6,$5,$2;
  546. $1=path;
  547. $2=(function(snap){
  548. return smalltalk.withContext(function($ctx2) { $3=_st(snap)._model();
  549. $4=_st(_st(snap)._path())._allButFirst();
  550. $5=(function(data){
  551. return smalltalk.withContext(function($ctx3) { $6=_st(_st(_st(_st(self)._asJQuery())._closest_("html"))._toArray())._isEmpty();
  552. if(smalltalk.assert($6)){
  553. _st((smalltalk.KeyedPubSubUnsubscribe || KeyedPubSubUnsubscribe))._signal();
  554. };
  555. return _st(snap)._do_((function(){
  556. return smalltalk.withContext(function($ctx4) { return _st(self)._with_((function(html){
  557. return smalltalk.withContext(function($ctx5) { return _st(aBlock)._value_value_(data,html);
  558. }, function($ctx5) {$ctx5.fillBlock({html:html},$ctx1)})}));
  559. }, function($ctx4) {$ctx4.fillBlock({},$ctx1)})}));
  560. }, function($ctx3) {$ctx3.fillBlock({data:data},$ctx1)})});
  561. return _st($3)._watch_do_($4,$5);
  562. }, function($ctx2) {$ctx2.fillBlock({snap:snap},$ctx1)})});
  563. _st($1)._trapDescend_($2);
  564. return self}, function($ctx1) {$ctx1.fill(self,"trap:read:",{path:path,aBlock:aBlock}, smalltalk.TagBrush)})},
  565. messageSends: ["trapDescend:", "watch:do:", "allButFirst", "path", "ifTrue:", "signal", "isEmpty", "toArray", "closest:", "asJQuery", "do:", "with:", "value:value:", "model"]}),
  566. smalltalk.TagBrush);
  567. smalltalk.addMethod(
  568. "_trap_toggle_",
  569. smalltalk.method({
  570. selector: "trap:toggle:",
  571. fn: function (path,aBlock){
  572. var self=this;
  573. return smalltalk.withContext(function($ctx1) { _st(self)._trap_toggle_ifNotPresent_(path,aBlock,(function(){
  574. return smalltalk.withContext(function($ctx2) { return _st(_st(self)._asJQuery())._hide();
  575. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  576. return self}, function($ctx1) {$ctx1.fill(self,"trap:toggle:",{path:path,aBlock:aBlock}, smalltalk.TagBrush)})},
  577. messageSends: ["trap:toggle:ifNotPresent:", "hide", "asJQuery"]}),
  578. smalltalk.TagBrush);
  579. smalltalk.addMethod(
  580. "_trap_toggle_ifNotPresent_",
  581. smalltalk.method({
  582. selector: "trap:toggle:ifNotPresent:",
  583. fn: function (path,aBlock,anotherBlock){
  584. var self=this;
  585. var shown;
  586. return smalltalk.withContext(function($ctx1) { var $1,$2,$4,$6,$7,$9,$8,$5,$3;
  587. shown=nil;
  588. $1=self;
  589. $2=path;
  590. $3=(function(data,html){
  591. return smalltalk.withContext(function($ctx2) { $4=_st(shown).__eq(_st(data)._notNil());
  592. $5=(function(){
  593. return smalltalk.withContext(function($ctx3) { shown=_st(data)._notNil();
  594. shown;
  595. $6=_st(self)._asJQuery();
  596. _st($6)._empty();
  597. $7=_st($6)._show();
  598. $7;
  599. $9=shown;
  600. if(smalltalk.assert($9)){
  601. $8=aBlock;
  602. } else {
  603. $8=anotherBlock;
  604. };
  605. return _st($8)._value_value_(data,html);
  606. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})});
  607. return _st($4)._ifFalse_($5);
  608. }, function($ctx2) {$ctx2.fillBlock({data:data,html:html},$ctx1)})});
  609. _st($1)._trap_read_($2,$3);
  610. return self}, function($ctx1) {$ctx1.fill(self,"trap:toggle:ifNotPresent:",{path:path,aBlock:aBlock,anotherBlock:anotherBlock,shown:shown}, smalltalk.TagBrush)})},
  611. messageSends: ["trap:read:", "ifFalse:", "notNil", "empty", "asJQuery", "show", "value:value:", "ifTrue:ifFalse:", "="]}),
  612. smalltalk.TagBrush);