Trapped-Frontend.deploy.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. smalltalk.addPackage('Trapped-Frontend', {});
  2. smalltalk.addClass('TrappedBinder', smalltalk.Object, ['brush'], 'Trapped-Frontend');
  3. smalltalk.addMethod(
  4. "_brush_",
  5. smalltalk.method({
  6. selector: "brush:",
  7. fn: function (aTagBrush){
  8. var self=this;
  9. self["@brush"]=aTagBrush;
  10. return self}
  11. }),
  12. smalltalk.TrappedBinder);
  13. smalltalk.addMethod(
  14. "_installFor_",
  15. smalltalk.method({
  16. selector: "installFor:",
  17. fn: function (path){
  18. var self=this;
  19. smalltalk.send(self["@brush"],"_trap_read_",[path,smalltalk.send(self,"_showBlock",[])]);
  20. return self}
  21. }),
  22. smalltalk.TrappedBinder);
  23. smalltalk.addMethod(
  24. "_prim_",
  25. smalltalk.method({
  26. selector: "prim:",
  27. fn: function (anObject){
  28. var self=this;
  29. return anObject.valueOf();
  30. ;
  31. return self}
  32. }),
  33. smalltalk.TrappedBinder);
  34. smalltalk.addMethod(
  35. "_showBlock",
  36. smalltalk.method({
  37. selector: "showBlock",
  38. fn: function (){
  39. var self=this;
  40. var $3,$2,$1;
  41. $1=(function(model){
  42. smalltalk.send(self["@brush"],"_empty",[]);
  43. if(($receiver = model) == nil || $receiver == undefined){
  44. $3=(function(){
  45. });
  46. } else {
  47. $3=model;
  48. };
  49. $2=smalltalk.send(self["@brush"],"_with_",[$3]);
  50. return $2;
  51. });
  52. return $1;
  53. }
  54. }),
  55. smalltalk.TrappedBinder);
  56. smalltalk.addClass('TrappedCheckedBinder', smalltalk.TrappedBinder, [], 'Trapped-Frontend');
  57. smalltalk.addMethod(
  58. "_installFor_",
  59. smalltalk.method({
  60. selector: "installFor:",
  61. fn: function (path){
  62. var self=this;
  63. smalltalk.send(self,"_installFor_",[path],smalltalk.TrappedBinder);
  64. smalltalk.send(path,"_trapDescend_",[(function(snap){
  65. return smalltalk.send(self["@brush"],"_onChange_",[(function(){
  66. return smalltalk.send(snap,"_modify_",[(function(){
  67. return smalltalk.send(smalltalk.send(smalltalk.send(self["@brush"],"_asJQuery",[]),"_attr_",["checked"]),"_notNil",[]);
  68. })]);
  69. })]);
  70. })]);
  71. return self}
  72. }),
  73. smalltalk.TrappedCheckedBinder);
  74. smalltalk.addMethod(
  75. "_showBlock",
  76. smalltalk.method({
  77. selector: "showBlock",
  78. fn: function (){
  79. var self=this;
  80. var $1;
  81. $1=(function(model){
  82. return smalltalk.send(smalltalk.send(self["@brush"],"_asJQuery",[]),"_attr_put_",["checked",smalltalk.send(model,"_ifNotNil_ifNil_",[(function(){
  83. return smalltalk.send(self,"_prim_",[model]);
  84. }),(function(){
  85. return false;
  86. })])]);
  87. });
  88. return $1;
  89. }
  90. }),
  91. smalltalk.TrappedCheckedBinder);
  92. smalltalk.addClass('TrappedValBinder', smalltalk.TrappedBinder, [], 'Trapped-Frontend');
  93. smalltalk.addMethod(
  94. "_installFor_",
  95. smalltalk.method({
  96. selector: "installFor:",
  97. fn: function (path){
  98. var self=this;
  99. smalltalk.send(self,"_installFor_",[path],smalltalk.TrappedBinder);
  100. smalltalk.send(path,"_trapDescend_",[(function(snap){
  101. return smalltalk.send(self["@brush"],"_onChange_",[(function(){
  102. return smalltalk.send(snap,"_modify_",[(function(){
  103. return smalltalk.send(smalltalk.send(self["@brush"],"_asJQuery",[]),"_val",[]);
  104. })]);
  105. })]);
  106. })]);
  107. return self}
  108. }),
  109. smalltalk.TrappedValBinder);
  110. smalltalk.addMethod(
  111. "_showBlock",
  112. smalltalk.method({
  113. selector: "showBlock",
  114. fn: function (){
  115. var self=this;
  116. var $1;
  117. $1=(function(model){
  118. return smalltalk.send(smalltalk.send(self["@brush"],"_asJQuery",[]),"_val_",[smalltalk.send(model,"_ifNotNil_ifNil_",[(function(){
  119. return smalltalk.send(self,"_prim_",[model]);
  120. }),(function(){
  121. return (function(){
  122. });
  123. })])]);
  124. });
  125. return $1;
  126. }
  127. }),
  128. smalltalk.TrappedValBinder);
  129. smalltalk.addClass('TrappedDumbView', smalltalk.Widget, [], 'Trapped-Frontend');
  130. smalltalk.addMethod(
  131. "_renderOn_",
  132. smalltalk.method({
  133. selector: "renderOn:",
  134. fn: function (html){
  135. var self=this;
  136. smalltalk.send(smalltalk.send(html,"_root",[]),"_trap_",[[]]);
  137. return self}
  138. }),
  139. smalltalk.TrappedDumbView);
  140. smalltalk.addClass('TrappedSingleton', smalltalk.Object, [], 'Trapped-Frontend');
  141. smalltalk.addMethod(
  142. "_start_",
  143. smalltalk.method({
  144. selector: "start:",
  145. fn: function (args){
  146. var self=this;
  147. var $1;
  148. $1=smalltalk.send(self,"_subclassResponsibility",[]);
  149. return $1;
  150. }
  151. }),
  152. smalltalk.TrappedSingleton);
  153. smalltalk.TrappedSingleton.klass.iVarNames = ['current'];
  154. smalltalk.addMethod(
  155. "_current",
  156. smalltalk.method({
  157. selector: "current",
  158. fn: function (){
  159. var self=this;
  160. var $1;
  161. if(($receiver = self["@current"]) == nil || $receiver == undefined){
  162. self["@current"]=smalltalk.send(self,"_new",[]);
  163. $1=self["@current"];
  164. } else {
  165. $1=self["@current"];
  166. };
  167. return $1;
  168. }
  169. }),
  170. smalltalk.TrappedSingleton.klass);
  171. smalltalk.addMethod(
  172. "_start_",
  173. smalltalk.method({
  174. selector: "start:",
  175. fn: function (zzz){
  176. var self=this;
  177. smalltalk.send(smalltalk.send(self,"_current",[]),"_perform_withArguments_",[smalltalk.symbolFor("start:"),arguments]);
  178. return self}
  179. }),
  180. smalltalk.TrappedSingleton.klass);
  181. smalltalk.addClass('Trapped', smalltalk.TrappedSingleton, ['registry'], 'Trapped-Frontend');
  182. smalltalk.addMethod(
  183. "_binder_",
  184. smalltalk.method({
  185. selector: "binder:",
  186. fn: function (aTagBrush){
  187. var self=this;
  188. var $1,$2,$3,$5,$4;
  189. var binder;
  190. var tag;
  191. tag=smalltalk.send(smalltalk.send(aTagBrush,"_element",[]),"_nodeName",[]);
  192. $1=smalltalk.send(tag,"__eq",["INPUT"]);
  193. if(smalltalk.assert($1)){
  194. var type;
  195. type=smalltalk.send(smalltalk.send(aTagBrush,"_asJQuery",[]),"_attr_",["type"]);
  196. type;
  197. $2=smalltalk.send(type,"__eq",["checkbox"]);
  198. if(smalltalk.assert($2)){
  199. binder=smalltalk.send((smalltalk.TrappedCheckedBinder || TrappedCheckedBinder),"_new",[]);
  200. binder;
  201. };
  202. $3=smalltalk.send(type,"__eq",["text"]);
  203. if(smalltalk.assert($3)){
  204. binder=smalltalk.send((smalltalk.TrappedValBinder || TrappedValBinder),"_new",[]);
  205. binder;
  206. };
  207. };
  208. if(($receiver = binder) == nil || $receiver == undefined){
  209. binder=smalltalk.send((smalltalk.TrappedBinder || TrappedBinder),"_new",[]);
  210. binder;
  211. } else {
  212. binder;
  213. };
  214. smalltalk.send(binder,"_brush_",[aTagBrush]);
  215. $5=smalltalk.send(binder,"_yourself",[]);
  216. $4=$5;
  217. return $4;
  218. }
  219. }),
  220. smalltalk.Trapped);
  221. smalltalk.addMethod(
  222. "_byName_",
  223. smalltalk.method({
  224. selector: "byName:",
  225. fn: function (aString){
  226. var self=this;
  227. var $1;
  228. $1=smalltalk.send(self["@registry"],"_at_",[aString]);
  229. return $1;
  230. }
  231. }),
  232. smalltalk.Trapped);
  233. smalltalk.addMethod(
  234. "_descend_snapshotDo_",
  235. smalltalk.method({
  236. selector: "descend:snapshotDo:",
  237. fn: function (anArray,aBlock){
  238. var self=this;
  239. var tpsc;
  240. tpsc=smalltalk.send((smalltalk.TrappedPathStack || TrappedPathStack),"_current",[]);
  241. smalltalk.send(tpsc,"_append_do_",[anArray,(function(){
  242. var path;
  243. var model;
  244. path=smalltalk.send(smalltalk.send(tpsc,"_elements",[]),"_copy",[]);
  245. path;
  246. model=smalltalk.send(self,"_byName_",[smalltalk.send(path,"_first",[])]);
  247. model;
  248. return smalltalk.send(aBlock,"_value_",[smalltalk.send(smalltalk.send((smalltalk.TrappedSnapshot || TrappedSnapshot),"_new",[]),"_path_model_",[path,model])]);
  249. })]);
  250. return self}
  251. }),
  252. smalltalk.Trapped);
  253. smalltalk.addMethod(
  254. "_initialize",
  255. smalltalk.method({
  256. selector: "initialize",
  257. fn: function (){
  258. var self=this;
  259. smalltalk.send(self,"_initialize",[],smalltalk.TrappedSingleton);
  260. self["@registry"]=smalltalk.HashedCollection._fromPairs_([]);
  261. return self}
  262. }),
  263. smalltalk.Trapped);
  264. smalltalk.addMethod(
  265. "_register_",
  266. smalltalk.method({
  267. selector: "register:",
  268. fn: function (aListKeyedEntity){
  269. var self=this;
  270. smalltalk.send(self,"_register_name_",[aListKeyedEntity,smalltalk.send(smalltalk.send(aListKeyedEntity,"_class",[]),"_name",[])]);
  271. return self}
  272. }),
  273. smalltalk.Trapped);
  274. smalltalk.addMethod(
  275. "_register_name_",
  276. smalltalk.method({
  277. selector: "register:name:",
  278. fn: function (aListKeyedEntity,aString){
  279. var self=this;
  280. smalltalk.send(self["@registry"],"_at_put_",[aString,aListKeyedEntity]);
  281. return self}
  282. }),
  283. smalltalk.Trapped);
  284. smalltalk.addMethod(
  285. "_start_",
  286. smalltalk.method({
  287. selector: "start:",
  288. fn: function (zzz){
  289. var self=this;
  290. var $1;
  291. var args;
  292. args = [].slice.call(arguments);
  293. ;
  294. smalltalk.send(args,"_do_",[(function(each){
  295. return smalltalk.send(self,"_register_",[each]);
  296. })]);
  297. smalltalk.send(smalltalk.send("[data-trap]","_asJQuery",[]),"_each_",[(function(index,elem){
  298. var trap;
  299. var jq;
  300. var viewName;
  301. var modelName;
  302. var tokens;
  303. var path;
  304. jq=smalltalk.send(elem,"_asJQuery",[]);
  305. jq;
  306. trap=smalltalk.send(jq,"_attr_",["data-trap"]);
  307. trap;
  308. tokens=smalltalk.send(trap,"_tokenize_",[":"]);
  309. tokens;
  310. $1=smalltalk.send(smalltalk.send(tokens,"_size",[]),"__eq",[(1)]);
  311. if(smalltalk.assert($1)){
  312. tokens=smalltalk.send(["TrappedDumbView"],"__comma",[tokens]);
  313. tokens;
  314. };
  315. viewName=smalltalk.send(tokens,"_first",[]);
  316. viewName;
  317. tokens=smalltalk.send(smalltalk.send(smalltalk.send(tokens,"_second",[]),"_tokenize_",[" "]),"_select_",[(function(each){
  318. return smalltalk.send(each,"_notEmpty",[]);
  319. })]);
  320. tokens;
  321. modelName=smalltalk.send(tokens,"_first",[]);
  322. modelName;
  323. path=smalltalk.send((smalltalk.Trapped || Trapped),"_parse_",[smalltalk.send(tokens,"_allButFirst",[])]);
  324. path;
  325. return smalltalk.send(smalltalk.send([modelName],"__comma",[path]),"_trapDescend_",[(function(){
  326. return smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.Smalltalk || Smalltalk),"_current",[]),"_at_",[viewName]),"_new",[]),"_appendToJQuery_",[jq]);
  327. })]);
  328. })]);
  329. return self}
  330. }),
  331. smalltalk.Trapped);
  332. smalltalk.addMethod(
  333. "_parse_",
  334. smalltalk.method({
  335. selector: "parse:",
  336. fn: function (anArray){
  337. var self=this;
  338. var $2,$3,$1;
  339. $1=smalltalk.send(anArray,"_collect_",[(function(each){
  340. var asNum;
  341. asNum = parseInt(each);
  342. ;
  343. $2=smalltalk.send(asNum,"__eq",[asNum]);
  344. if(smalltalk.assert($2)){
  345. return asNum;
  346. } else {
  347. $3=smalltalk.send(smalltalk.send(each,"_first",[]),"__eq",["#"]);
  348. if(smalltalk.assert($3)){
  349. return smalltalk.send(smalltalk.send(each,"_allButFirst",[]),"_asSymbol",[]);
  350. } else {
  351. return each;
  352. };
  353. };
  354. })]);
  355. return $1;
  356. }
  357. }),
  358. smalltalk.Trapped.klass);
  359. smalltalk.addClass('TrappedPathStack', smalltalk.TrappedSingleton, ['elements'], 'Trapped-Frontend');
  360. smalltalk.addMethod(
  361. "_append_do_",
  362. smalltalk.method({
  363. selector: "append:do:",
  364. fn: function (anArray,aBlock){
  365. var self=this;
  366. smalltalk.send(self,"_with_do_",[smalltalk.send(self["@elements"],"__comma",[anArray]),aBlock]);
  367. return self}
  368. }),
  369. smalltalk.TrappedPathStack);
  370. smalltalk.addMethod(
  371. "_elements",
  372. smalltalk.method({
  373. selector: "elements",
  374. fn: function (){
  375. var self=this;
  376. return self["@elements"];
  377. }
  378. }),
  379. smalltalk.TrappedPathStack);
  380. smalltalk.addMethod(
  381. "_initialize",
  382. smalltalk.method({
  383. selector: "initialize",
  384. fn: function (){
  385. var self=this;
  386. smalltalk.send(self,"_initialize",[],smalltalk.TrappedSingleton);
  387. self["@elements"]=[];
  388. return self}
  389. }),
  390. smalltalk.TrappedPathStack);
  391. smalltalk.addMethod(
  392. "_with_do_",
  393. smalltalk.method({
  394. selector: "with:do:",
  395. fn: function (anArray,aBlock){
  396. var self=this;
  397. var old;
  398. old=self["@elements"];
  399. smalltalk.send((function(){
  400. self["@elements"]=anArray;
  401. self["@elements"];
  402. return smalltalk.send(aBlock,"_value",[]);
  403. }),"_ensure_",[(function(){
  404. self["@elements"]=old;
  405. return self["@elements"];
  406. })]);
  407. return self}
  408. }),
  409. smalltalk.TrappedPathStack);
  410. smalltalk.addClass('TrappedSnapshot', smalltalk.Object, ['path', 'model'], 'Trapped-Frontend');
  411. smalltalk.addMethod(
  412. "_do_",
  413. smalltalk.method({
  414. selector: "do:",
  415. fn: function (aBlock){
  416. var self=this;
  417. smalltalk.send(smalltalk.send((smalltalk.TrappedPathStack || TrappedPathStack),"_current",[]),"_with_do_",[self["@path"],(function(){
  418. return smalltalk.send(aBlock,"_value_",[self["@model"]]);
  419. })]);
  420. return self}
  421. }),
  422. smalltalk.TrappedSnapshot);
  423. smalltalk.addMethod(
  424. "_model",
  425. smalltalk.method({
  426. selector: "model",
  427. fn: function (){
  428. var self=this;
  429. return self["@model"];
  430. }
  431. }),
  432. smalltalk.TrappedSnapshot);
  433. smalltalk.addMethod(
  434. "_modify_",
  435. smalltalk.method({
  436. selector: "modify:",
  437. fn: function (aBlock){
  438. var self=this;
  439. smalltalk.send(smalltalk.send(self,"_model",[]),"_modify_do_",[smalltalk.send(smalltalk.send(self,"_path",[]),"_allButFirst",[]),aBlock]);
  440. return self}
  441. }),
  442. smalltalk.TrappedSnapshot);
  443. smalltalk.addMethod(
  444. "_path",
  445. smalltalk.method({
  446. selector: "path",
  447. fn: function (){
  448. var self=this;
  449. return self["@path"];
  450. }
  451. }),
  452. smalltalk.TrappedSnapshot);
  453. smalltalk.addMethod(
  454. "_path_model_",
  455. smalltalk.method({
  456. selector: "path:model:",
  457. fn: function (anArray,aTrappedMW){
  458. var self=this;
  459. self["@path"]=anArray;
  460. self["@model"]=aTrappedMW;
  461. return self}
  462. }),
  463. smalltalk.TrappedSnapshot);
  464. smalltalk.addMethod(
  465. "_trapDescend_",
  466. smalltalk.method({
  467. selector: "trapDescend:",
  468. fn: function (aBlock){
  469. var self=this;
  470. smalltalk.send(smalltalk.send((smalltalk.Trapped || Trapped),"_current",[]),"_descend_snapshotDo_",[self,aBlock]);
  471. return self}
  472. }),
  473. smalltalk.Array);
  474. smalltalk.addMethod(
  475. "_trapDescend_",
  476. smalltalk.method({
  477. selector: "trapDescend:",
  478. fn: function (aBlock){
  479. var self=this;
  480. smalltalk.send(smalltalk.send((smalltalk.Trapped || Trapped),"_current",[]),"_descend_snapshotDo_",[self,aBlock]);
  481. return self}
  482. }),
  483. smalltalk.Array);
  484. smalltalk.addMethod(
  485. "_trap_",
  486. smalltalk.method({
  487. selector: "trap:",
  488. fn: function (path){
  489. var self=this;
  490. smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.Trapped || Trapped),"_current",[]),"_binder_",[self]),"_installFor_",[path]);
  491. return self}
  492. }),
  493. smalltalk.TagBrush);
  494. smalltalk.addMethod(
  495. "_trap_read_",
  496. smalltalk.method({
  497. selector: "trap:read:",
  498. fn: function (path,aBlock){
  499. var self=this;
  500. var $1;
  501. smalltalk.send(path,"_trapDescend_",[(function(snap){
  502. return smalltalk.send(smalltalk.send(snap,"_model",[]),"_watch_do_",[smalltalk.send(smalltalk.send(snap,"_path",[]),"_allButFirst",[]),(function(data){
  503. $1=smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(self,"_asJQuery",[]),"_closest_",["html"]),"_toArray",[]),"_isEmpty",[]);
  504. if(smalltalk.assert($1)){
  505. smalltalk.send((smalltalk.KeyedPubSubUnsubscribe || KeyedPubSubUnsubscribe),"_signal",[]);
  506. };
  507. return smalltalk.send(snap,"_do_",[(function(){
  508. return smalltalk.send(self,"_with_",[(function(html){
  509. return smalltalk.send(aBlock,"_value_value_",[data,html]);
  510. })]);
  511. })]);
  512. })]);
  513. })]);
  514. return self}
  515. }),
  516. smalltalk.TagBrush);
  517. smalltalk.addMethod(
  518. "_trap_toggle_",
  519. smalltalk.method({
  520. selector: "trap:toggle:",
  521. fn: function (path,aBlock){
  522. var self=this;
  523. smalltalk.send(self,"_trap_toggle_ifNotPresent_",[path,aBlock,(function(){
  524. return smalltalk.send(smalltalk.send(self,"_asJQuery",[]),"_hide",[]);
  525. })]);
  526. return self}
  527. }),
  528. smalltalk.TagBrush);
  529. smalltalk.addMethod(
  530. "_trap_toggle_ifNotPresent_",
  531. smalltalk.method({
  532. selector: "trap:toggle:ifNotPresent:",
  533. fn: function (path,aBlock,anotherBlock){
  534. var self=this;
  535. var $1,$2,$3,$4;
  536. var shown;
  537. shown=nil;
  538. smalltalk.send(self,"_trap_read_",[path,(function(data,html){
  539. $1=smalltalk.send(shown,"__eq",[smalltalk.send(data,"_notNil",[])]);
  540. if(! smalltalk.assert($1)){
  541. shown=smalltalk.send(data,"_notNil",[]);
  542. shown;
  543. $2=smalltalk.send(self,"_asJQuery",[]);
  544. smalltalk.send($2,"_empty",[]);
  545. $3=smalltalk.send($2,"_show",[]);
  546. $3;
  547. if(smalltalk.assert(shown)){
  548. $4=aBlock;
  549. } else {
  550. $4=anotherBlock;
  551. };
  552. return smalltalk.send($4,"_value_value_",[data,html]);
  553. };
  554. })]);
  555. return self}
  556. }),
  557. smalltalk.TagBrush);
  558. smalltalk.addMethod(
  559. "_trapIter_tag_do_",
  560. smalltalk.method({
  561. selector: "trapIter:tag:do:",
  562. fn: function (path,aSymbol,aBlock){
  563. var self=this;
  564. smalltalk.send(self,"_trap_read_",[path,(function(model,html){
  565. smalltalk.send(smalltalk.send(html,"_root",[]),"_empty",[]);
  566. if(($receiver = model) == nil || $receiver == undefined){
  567. return model;
  568. } else {
  569. return smalltalk.send(model,"_withIndexDo_",[(function(item,i){
  570. return smalltalk.send(smalltalk.send(html,"_perform_",[aSymbol]),"_trap_read_",[[i],aBlock]);
  571. })]);
  572. };
  573. })]);
  574. return self}
  575. }),
  576. smalltalk.TagBrush);