Trapped-Frontend.js 25 KB

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