Trapped-Frontend.deploy.js 25 KB

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