Trapped-Frontend.js 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859
  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. "_envelope_loop_before_tag_do_",
  428. smalltalk.method({
  429. selector: "envelope:loop:before:tag:do:",
  430. category: 'private',
  431. fn: function (envelope,model,endjq,aSymbol,aBlock){
  432. var self=this;
  433. var envjq;
  434. return smalltalk.withContext(function($ctx1) { envjq=_st(envelope)._asJQuery();
  435. _st(model)._withIndexDo_((function(item,i){
  436. return smalltalk.withContext(function($ctx2) { _st(envelope)._with_((function(html){
  437. return smalltalk.withContext(function($ctx3) { return _st(_st(html)._perform_(aSymbol))._trap_read_([i],aBlock);
  438. }, function($ctx3) {$ctx3.fillBlock({html:html},$ctx1)})}));
  439. return _st(_st(_st(envjq)._children())._detach())._insertBefore_(endjq);
  440. }, function($ctx2) {$ctx2.fillBlock({item:item,i:i},$ctx1)})}));
  441. _st(envjq)._remove();
  442. 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)})},
  443. args: ["envelope", "model", "endjq", "aSymbol", "aBlock"],
  444. source: "envelope: envelope loop: model before: endjq tag: aSymbol do: aBlock\x0a \x09| envjq |\x0a envjq := envelope asJQuery.\x0a model withIndexDo: [ :item :i |\x0a envelope with: [ :html | (html perform: aSymbol) trap: {i} read: aBlock ].\x0a envjq children detach insertBefore: endjq.\x0a ].\x0a envjq remove\x0a",
  445. messageSends: ["asJQuery", "withIndexDo:", "with:", "trap:read:", "perform:", "insertBefore:", "detach", "children", "remove"],
  446. referencedClasses: []
  447. }),
  448. smalltalk.Trapped.klass);
  449. smalltalk.addMethod(
  450. "_loop_between_and_tag_do_",
  451. smalltalk.method({
  452. selector: "loop:between:and:tag:do:",
  453. category: 'private',
  454. fn: function (model,start,end,aSymbol,aBlock){
  455. var self=this;
  456. return smalltalk.withContext(function($ctx1) { var $1;
  457. _st(_st(_st(start)._asJQuery())._nextUntil_(_st(end)._element()))._remove();
  458. _st(start)._with_((function(html){
  459. return smalltalk.withContext(function($ctx2) { $1=model;
  460. if(($receiver = $1) == nil || $receiver == undefined){
  461. return $1;
  462. } else {
  463. return _st(self)._envelope_loop_before_tag_do_(_st(html)._div(),model,_st(end)._asJQuery(),aSymbol,aBlock);
  464. };
  465. }, function($ctx2) {$ctx2.fillBlock({html:html},$ctx1)})}));
  466. 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)})},
  467. args: ["model", "start", "end", "aSymbol", "aBlock"],
  468. source: "loop: model between: start and: end tag: aSymbol do: aBlock\x0a (start asJQuery nextUntil: end element) remove.\x0a start with: [ :html | model ifNotNil: [\x0a \x09self envelope: html div loop: model before: end asJQuery tag: aSymbol do: aBlock\x0a\x09]]\x0a",
  469. messageSends: ["remove", "nextUntil:", "element", "asJQuery", "with:", "ifNotNil:", "envelope:loop:before:tag:do:", "div"],
  470. referencedClasses: []
  471. }),
  472. smalltalk.Trapped.klass);
  473. smalltalk.addMethod(
  474. "_parse_",
  475. smalltalk.method({
  476. selector: "parse:",
  477. category: 'accessing',
  478. fn: function (anArray){
  479. var self=this;
  480. return smalltalk.withContext(function($ctx1) { var $2,$4,$5,$7,$6,$3,$1;
  481. $2=anArray;
  482. $3=(function(each){
  483. var asNum;
  484. return smalltalk.withContext(function($ctx2) { _st(asNum).__eq(_st(each)._asNumber());
  485. $4=_st(asNum).__eq(asNum);
  486. $5=(function(){
  487. return smalltalk.withContext(function($ctx3) { return asNum;
  488. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})});
  489. $6=(function(){
  490. return smalltalk.withContext(function($ctx3) { $7=_st(_st(each)._first()).__eq("#");
  491. if(smalltalk.assert($7)){
  492. return _st(_st(each)._allButFirst())._asSymbol();
  493. } else {
  494. return each;
  495. };
  496. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})});
  497. return _st($4)._ifTrue_ifFalse_($5,$6);
  498. }, function($ctx2) {$ctx2.fillBlock({each:each,asNum:asNum},$ctx1)})});
  499. $1=_st($2)._collect_($3);
  500. return $1;
  501. }, function($ctx1) {$ctx1.fill(self,"parse:",{anArray:anArray}, smalltalk.Trapped.klass)})},
  502. args: ["anArray"],
  503. 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 ]]]",
  504. messageSends: ["collect:", "=", "asNumber", "ifTrue:ifFalse:", "asSymbol", "allButFirst", "first"],
  505. referencedClasses: []
  506. }),
  507. smalltalk.Trapped.klass);
  508. smalltalk.addClass('TrappedPathStack', smalltalk.TrappedSingleton, ['elements'], 'Trapped-Frontend');
  509. smalltalk.addMethod(
  510. "_append_do_",
  511. smalltalk.method({
  512. selector: "append:do:",
  513. category: 'descending',
  514. fn: function (anArray,aBlock){
  515. var self=this;
  516. return smalltalk.withContext(function($ctx1) { _st(self)._with_do_(_st(self["@elements"]).__comma(anArray),aBlock);
  517. return self}, function($ctx1) {$ctx1.fill(self,"append:do:",{anArray:anArray,aBlock:aBlock}, smalltalk.TrappedPathStack)})},
  518. args: ["anArray", "aBlock"],
  519. source: "append: anArray do: aBlock\x0a self with: elements, anArray do: aBlock",
  520. messageSends: ["with:do:", ","],
  521. referencedClasses: []
  522. }),
  523. smalltalk.TrappedPathStack);
  524. smalltalk.addMethod(
  525. "_elements",
  526. smalltalk.method({
  527. selector: "elements",
  528. category: 'accessing',
  529. fn: function (){
  530. var self=this;
  531. return smalltalk.withContext(function($ctx1) { var $1;
  532. $1=self["@elements"];
  533. return $1;
  534. }, function($ctx1) {$ctx1.fill(self,"elements",{}, smalltalk.TrappedPathStack)})},
  535. args: [],
  536. source: "elements\x0a\x09^elements",
  537. messageSends: [],
  538. referencedClasses: []
  539. }),
  540. smalltalk.TrappedPathStack);
  541. smalltalk.addMethod(
  542. "_initialize",
  543. smalltalk.method({
  544. selector: "initialize",
  545. category: 'initialization',
  546. fn: function (){
  547. var self=this;
  548. return smalltalk.withContext(function($ctx1) { smalltalk.TrappedSingleton.fn.prototype._initialize.apply(_st(self), []);
  549. self["@elements"]=[];
  550. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{}, smalltalk.TrappedPathStack)})},
  551. args: [],
  552. source: "initialize\x0a super initialize.\x0a\x09elements := #().",
  553. messageSends: ["initialize"],
  554. referencedClasses: []
  555. }),
  556. smalltalk.TrappedPathStack);
  557. smalltalk.addMethod(
  558. "_with_do_",
  559. smalltalk.method({
  560. selector: "with:do:",
  561. category: 'descending',
  562. fn: function (anArray,aBlock){
  563. var self=this;
  564. var old;
  565. return smalltalk.withContext(function($ctx1) { old=self["@elements"];
  566. _st((function(){
  567. return smalltalk.withContext(function($ctx2) { self["@elements"]=anArray;
  568. self["@elements"];
  569. return _st(aBlock)._value();
  570. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._ensure_((function(){
  571. return smalltalk.withContext(function($ctx2) { self["@elements"]=old;
  572. return self["@elements"];
  573. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  574. return self}, function($ctx1) {$ctx1.fill(self,"with:do:",{anArray:anArray,aBlock:aBlock,old:old}, smalltalk.TrappedPathStack)})},
  575. args: ["anArray", "aBlock"],
  576. source: "with: anArray do: aBlock\x0a\x09| old |\x0a old := elements.\x0a [ elements := anArray.\x0a\x09aBlock value ] ensure: [ elements := old ]",
  577. messageSends: ["ensure:", "value"],
  578. referencedClasses: []
  579. }),
  580. smalltalk.TrappedPathStack);
  581. smalltalk.addClass('TrappedSnapshot', smalltalk.Object, ['path', 'model'], 'Trapped-Frontend');
  582. smalltalk.addMethod(
  583. "_do_",
  584. smalltalk.method({
  585. selector: "do:",
  586. category: 'action',
  587. fn: function (aBlock){
  588. var self=this;
  589. return smalltalk.withContext(function($ctx1) { _st(_st((smalltalk.TrappedPathStack || TrappedPathStack))._current())._with_do_(self["@path"],(function(){
  590. return smalltalk.withContext(function($ctx2) { return _st(aBlock)._value_(self["@model"]);
  591. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  592. return self}, function($ctx1) {$ctx1.fill(self,"do:",{aBlock:aBlock}, smalltalk.TrappedSnapshot)})},
  593. args: ["aBlock"],
  594. source: "do: aBlock\x0a\x09TrappedPathStack current with: path do: [ aBlock value: model ]",
  595. messageSends: ["with:do:", "value:", "current"],
  596. referencedClasses: ["TrappedPathStack"]
  597. }),
  598. smalltalk.TrappedSnapshot);
  599. smalltalk.addMethod(
  600. "_model",
  601. smalltalk.method({
  602. selector: "model",
  603. category: 'accessing',
  604. fn: function (){
  605. var self=this;
  606. return smalltalk.withContext(function($ctx1) { var $1;
  607. $1=self["@model"];
  608. return $1;
  609. }, function($ctx1) {$ctx1.fill(self,"model",{}, smalltalk.TrappedSnapshot)})},
  610. args: [],
  611. source: "model\x0a\x09^model",
  612. messageSends: [],
  613. referencedClasses: []
  614. }),
  615. smalltalk.TrappedSnapshot);
  616. smalltalk.addMethod(
  617. "_modify_",
  618. smalltalk.method({
  619. selector: "modify:",
  620. category: 'action',
  621. fn: function (aBlock){
  622. var self=this;
  623. return smalltalk.withContext(function($ctx1) { _st(_st(self)._model())._modify_do_(_st(_st(self)._path())._allButFirst(),aBlock);
  624. return self}, function($ctx1) {$ctx1.fill(self,"modify:",{aBlock:aBlock}, smalltalk.TrappedSnapshot)})},
  625. args: ["aBlock"],
  626. source: "modify: aBlock\x0a\x09self model modify: self path allButFirst do: aBlock",
  627. messageSends: ["modify:do:", "allButFirst", "path", "model"],
  628. referencedClasses: []
  629. }),
  630. smalltalk.TrappedSnapshot);
  631. smalltalk.addMethod(
  632. "_path",
  633. smalltalk.method({
  634. selector: "path",
  635. category: 'accessing',
  636. fn: function (){
  637. var self=this;
  638. return smalltalk.withContext(function($ctx1) { var $1;
  639. $1=self["@path"];
  640. return $1;
  641. }, function($ctx1) {$ctx1.fill(self,"path",{}, smalltalk.TrappedSnapshot)})},
  642. args: [],
  643. source: "path\x0a\x09^path",
  644. messageSends: [],
  645. referencedClasses: []
  646. }),
  647. smalltalk.TrappedSnapshot);
  648. smalltalk.addMethod(
  649. "_path_model_",
  650. smalltalk.method({
  651. selector: "path:model:",
  652. category: 'accessing',
  653. fn: function (anArray,aTrappedMW){
  654. var self=this;
  655. return smalltalk.withContext(function($ctx1) { self["@path"]=anArray;
  656. self["@model"]=aTrappedMW;
  657. return self}, function($ctx1) {$ctx1.fill(self,"path:model:",{anArray:anArray,aTrappedMW:aTrappedMW}, smalltalk.TrappedSnapshot)})},
  658. args: ["anArray", "aTrappedMW"],
  659. source: "path: anArray model: aTrappedMW\x0a\x09path := anArray.\x0a model := aTrappedMW",
  660. messageSends: [],
  661. referencedClasses: []
  662. }),
  663. smalltalk.TrappedSnapshot);
  664. smalltalk.addMethod(
  665. "_trapDescend_",
  666. smalltalk.method({
  667. selector: "trapDescend:",
  668. category: '*Trapped-Frontend',
  669. fn: function (aBlock){
  670. var self=this;
  671. return smalltalk.withContext(function($ctx1) { _st(_st((smalltalk.Trapped || Trapped))._current())._descend_snapshotDo_(self,aBlock);
  672. return self}, function($ctx1) {$ctx1.fill(self,"trapDescend:",{aBlock:aBlock}, smalltalk.Array)})},
  673. args: ["aBlock"],
  674. source: "trapDescend: aBlock\x0a\x09Trapped current descend: self snapshotDo: aBlock",
  675. messageSends: ["descend:snapshotDo:", "current"],
  676. referencedClasses: ["Trapped"]
  677. }),
  678. smalltalk.Array);
  679. smalltalk.addMethod(
  680. "_trapIter_tag_do_",
  681. smalltalk.method({
  682. selector: "trapIter:tag:do:",
  683. category: '*Trapped-Frontend',
  684. fn: function (path,aSymbol,aBlock){
  685. var self=this;
  686. var start,end;
  687. return smalltalk.withContext(function($ctx1) { _st(self)._with_((function(html){
  688. return smalltalk.withContext(function($ctx2) { start=_st(html)._script();
  689. start;
  690. end=_st(html)._script();
  691. return end;
  692. }, function($ctx2) {$ctx2.fillBlock({html:html},$ctx1)})}));
  693. _st(start)._trap_read_(path,(function(model){
  694. return smalltalk.withContext(function($ctx2) { return _st((smalltalk.Trapped || Trapped))._loop_between_and_tag_do_(model,start,end,aSymbol,aBlock);
  695. }, function($ctx2) {$ctx2.fillBlock({model:model},$ctx1)})}));
  696. return self}, function($ctx1) {$ctx1.fill(self,"trapIter:tag:do:",{path:path,aSymbol:aSymbol,aBlock:aBlock,start:start,end:end}, smalltalk.HTMLCanvas)})},
  697. args: ["path", "aSymbol", "aBlock"],
  698. source: "trapIter: path tag: aSymbol do: aBlock\x0a\x09| start end |\x0a self with: [ :html | start := html script. end := html script ].\x0a start trap: path read: [ :model |\x0a \x09Trapped loop: model between: start and: end tag: aSymbol do: aBlock.\x0a ]",
  699. messageSends: ["with:", "script", "trap:read:", "loop:between:and:tag:do:"],
  700. referencedClasses: ["Trapped"]
  701. }),
  702. smalltalk.HTMLCanvas);
  703. smalltalk.addMethod(
  704. "_trap_",
  705. smalltalk.method({
  706. selector: "trap:",
  707. category: '*Trapped-Frontend',
  708. fn: function (path){
  709. var self=this;
  710. return smalltalk.withContext(function($ctx1) { _st(_st(_st((smalltalk.Trapped || Trapped))._current())._binder_(self))._installFor_(path);
  711. return self}, function($ctx1) {$ctx1.fill(self,"trap:",{path:path}, smalltalk.TagBrush)})},
  712. args: ["path"],
  713. source: "trap: path\x0a\x09(Trapped current binder: self) installFor: path",
  714. messageSends: ["installFor:", "binder:", "current"],
  715. referencedClasses: ["Trapped"]
  716. }),
  717. smalltalk.TagBrush);
  718. smalltalk.addMethod(
  719. "_trap_read_",
  720. smalltalk.method({
  721. selector: "trap:read:",
  722. category: '*Trapped-Frontend',
  723. fn: function (path,aBlock){
  724. var self=this;
  725. return smalltalk.withContext(function($ctx1) { var $1,$3,$4,$6,$5,$2;
  726. $1=path;
  727. $2=(function(snap){
  728. return smalltalk.withContext(function($ctx2) { $3=_st(snap)._model();
  729. $4=_st(_st(snap)._path())._allButFirst();
  730. $5=(function(data){
  731. return smalltalk.withContext(function($ctx3) { $6=_st(_st(_st(_st(self)._asJQuery())._closest_("html"))._toArray())._isEmpty();
  732. if(smalltalk.assert($6)){
  733. _st((smalltalk.KeyedPubSubUnsubscribe || KeyedPubSubUnsubscribe))._signal();
  734. };
  735. return _st(snap)._do_((function(){
  736. return smalltalk.withContext(function($ctx4) { return _st(self)._with_((function(html){
  737. return smalltalk.withContext(function($ctx5) { return _st(aBlock)._value_value_(data,html);
  738. }, function($ctx5) {$ctx5.fillBlock({html:html},$ctx1)})}));
  739. }, function($ctx4) {$ctx4.fillBlock({},$ctx1)})}));
  740. }, function($ctx3) {$ctx3.fillBlock({data:data},$ctx1)})});
  741. return _st($3)._watch_do_($4,$5);
  742. }, function($ctx2) {$ctx2.fillBlock({snap:snap},$ctx1)})});
  743. _st($1)._trapDescend_($2);
  744. return self}, function($ctx1) {$ctx1.fill(self,"trap:read:",{path:path,aBlock:aBlock}, smalltalk.TagBrush)})},
  745. args: ["path", "aBlock"],
  746. 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 ]",
  747. messageSends: ["trapDescend:", "watch:do:", "allButFirst", "path", "ifTrue:", "signal", "isEmpty", "toArray", "closest:", "asJQuery", "do:", "with:", "value:value:", "model"],
  748. referencedClasses: ["KeyedPubSubUnsubscribe"]
  749. }),
  750. smalltalk.TagBrush);
  751. smalltalk.addMethod(
  752. "_trap_toggle_",
  753. smalltalk.method({
  754. selector: "trap:toggle:",
  755. category: '*Trapped-Frontend',
  756. fn: function (path,aBlock){
  757. var self=this;
  758. return smalltalk.withContext(function($ctx1) { _st(self)._trap_toggle_ifNotPresent_(path,aBlock,(function(){
  759. return smalltalk.withContext(function($ctx2) { return _st(_st(self)._asJQuery())._hide();
  760. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  761. return self}, function($ctx1) {$ctx1.fill(self,"trap:toggle:",{path:path,aBlock:aBlock}, smalltalk.TagBrush)})},
  762. args: ["path", "aBlock"],
  763. source: "trap: path toggle: aBlock\x0a self trap: path toggle: aBlock ifNotPresent: [ self asJQuery hide ]",
  764. messageSends: ["trap:toggle:ifNotPresent:", "hide", "asJQuery"],
  765. referencedClasses: []
  766. }),
  767. smalltalk.TagBrush);
  768. smalltalk.addMethod(
  769. "_trap_toggle_ifNotPresent_",
  770. smalltalk.method({
  771. selector: "trap:toggle:ifNotPresent:",
  772. category: '*Trapped-Frontend',
  773. fn: function (path,aBlock,anotherBlock){
  774. var self=this;
  775. var shown;
  776. return smalltalk.withContext(function($ctx1) { var $1,$2,$4,$6,$7,$9,$8,$5,$3;
  777. shown=nil;
  778. $1=self;
  779. $2=path;
  780. $3=(function(data,html){
  781. return smalltalk.withContext(function($ctx2) { $4=_st(shown).__eq(_st(data)._notNil());
  782. $5=(function(){
  783. return smalltalk.withContext(function($ctx3) { shown=_st(data)._notNil();
  784. shown;
  785. $6=_st(self)._asJQuery();
  786. _st($6)._empty();
  787. $7=_st($6)._show();
  788. $7;
  789. $9=shown;
  790. if(smalltalk.assert($9)){
  791. $8=aBlock;
  792. } else {
  793. $8=anotherBlock;
  794. };
  795. return _st($8)._value_value_(data,html);
  796. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})});
  797. return _st($4)._ifFalse_($5);
  798. }, function($ctx2) {$ctx2.fillBlock({data:data,html:html},$ctx1)})});
  799. _st($1)._trap_read_($2,$3);
  800. return self}, function($ctx1) {$ctx1.fill(self,"trap:toggle:ifNotPresent:",{path:path,aBlock:aBlock,anotherBlock:anotherBlock,shown:shown}, smalltalk.TagBrush)})},
  801. args: ["path", "aBlock", "anotherBlock"],
  802. 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 ]",
  803. messageSends: ["trap:read:", "ifFalse:", "notNil", "empty", "asJQuery", "show", "value:value:", "ifTrue:ifFalse:", "="],
  804. referencedClasses: []
  805. }),
  806. smalltalk.TagBrush);