Trapped-Frontend.js 31 KB

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