Moka-Core.deploy.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. (function(smalltalk,nil,_st){
  2. smalltalk.addPackage('Moka-Core');
  3. smalltalk.addClass('MKController', smalltalk.Object, ['view', 'model'], 'Moka-Core');
  4. smalltalk.addMethod(
  5. smalltalk.method({
  6. selector: "model",
  7. fn: function (){
  8. var self=this;
  9. return smalltalk.withContext(function($ctx1) {
  10. var $1;
  11. $1=self["@model"];
  12. return $1;
  13. }, function($ctx1) {$ctx1.fill(self,"model",{},smalltalk.MKController)})},
  14. messageSends: []}),
  15. smalltalk.MKController);
  16. smalltalk.addMethod(
  17. smalltalk.method({
  18. selector: "model:",
  19. fn: function (aModel){
  20. var self=this;
  21. return smalltalk.withContext(function($ctx1) {
  22. self["@model"]=aModel;
  23. return self}, function($ctx1) {$ctx1.fill(self,"model:",{aModel:aModel},smalltalk.MKController)})},
  24. messageSends: []}),
  25. smalltalk.MKController);
  26. smalltalk.addMethod(
  27. smalltalk.method({
  28. selector: "view",
  29. fn: function (){
  30. var self=this;
  31. return smalltalk.withContext(function($ctx1) {
  32. var $1;
  33. $1=self["@view"];
  34. return $1;
  35. }, function($ctx1) {$ctx1.fill(self,"view",{},smalltalk.MKController)})},
  36. messageSends: []}),
  37. smalltalk.MKController);
  38. smalltalk.addMethod(
  39. smalltalk.method({
  40. selector: "view:",
  41. fn: function (aView){
  42. var self=this;
  43. return smalltalk.withContext(function($ctx1) {
  44. self["@view"]=aView;
  45. return self}, function($ctx1) {$ctx1.fill(self,"view:",{aView:aView},smalltalk.MKController)})},
  46. messageSends: []}),
  47. smalltalk.MKController);
  48. smalltalk.addClass('MKAspectController', smalltalk.MKController, ['aspect'], 'Moka-Core');
  49. smalltalk.addMethod(
  50. smalltalk.method({
  51. selector: "aspect",
  52. fn: function (){
  53. var self=this;
  54. return smalltalk.withContext(function($ctx1) {
  55. var $1;
  56. $1=self["@aspect"];
  57. return $1;
  58. }, function($ctx1) {$ctx1.fill(self,"aspect",{},smalltalk.MKAspectController)})},
  59. messageSends: []}),
  60. smalltalk.MKAspectController);
  61. smalltalk.addMethod(
  62. smalltalk.method({
  63. selector: "aspect:",
  64. fn: function (aSelector){
  65. var self=this;
  66. return smalltalk.withContext(function($ctx1) {
  67. self["@aspect"]=aSelector;
  68. return self}, function($ctx1) {$ctx1.fill(self,"aspect:",{aSelector:aSelector},smalltalk.MKAspectController)})},
  69. messageSends: []}),
  70. smalltalk.MKAspectController);
  71. smalltalk.addMethod(
  72. smalltalk.method({
  73. selector: "performAction",
  74. fn: function (){
  75. var self=this;
  76. return smalltalk.withContext(function($ctx1) {
  77. var $1;
  78. $1=self._aspect();
  79. if(($receiver = $1) == nil || $receiver == undefined){
  80. $1;
  81. } else {
  82. _st(self._model())._perform_(self._aspect());
  83. };
  84. return self}, function($ctx1) {$ctx1.fill(self,"performAction",{},smalltalk.MKAspectController)})},
  85. messageSends: ["ifNotNil:", "perform:", "aspect", "model"]}),
  86. smalltalk.MKAspectController);
  87. smalltalk.addMethod(
  88. smalltalk.method({
  89. selector: "performActionWith:",
  90. fn: function (anObject){
  91. var self=this;
  92. return smalltalk.withContext(function($ctx1) {
  93. var $1;
  94. $1=self._aspect();
  95. if(($receiver = $1) == nil || $receiver == undefined){
  96. $1;
  97. } else {
  98. _st(self._model())._perform_withArguments_(_st(self._aspect())._asMutator(),[anObject]);
  99. };
  100. return self}, function($ctx1) {$ctx1.fill(self,"performActionWith:",{anObject:anObject},smalltalk.MKAspectController)})},
  101. messageSends: ["ifNotNil:", "perform:withArguments:", "asMutator", "aspect", "model"]}),
  102. smalltalk.MKAspectController);
  103. smalltalk.addClass('MKModel', smalltalk.Object, ['announcer'], 'Moka-Core');
  104. smalltalk.addMethod(
  105. smalltalk.method({
  106. selector: "announce:",
  107. fn: function (anAnnouncement){
  108. var self=this;
  109. return smalltalk.withContext(function($ctx1) {
  110. _st(self["@announcer"])._announce_(anAnnouncement);
  111. return self}, function($ctx1) {$ctx1.fill(self,"announce:",{anAnnouncement:anAnnouncement},smalltalk.MKModel)})},
  112. messageSends: ["announce:"]}),
  113. smalltalk.MKModel);
  114. smalltalk.addMethod(
  115. smalltalk.method({
  116. selector: "changed:",
  117. fn: function (aSelector){
  118. var self=this;
  119. function $MKModelChanged(){return smalltalk.MKModelChanged||(typeof MKModelChanged=="undefined"?nil:MKModelChanged)}
  120. return smalltalk.withContext(function($ctx1) {
  121. self._announce_(_st($MKModelChanged())._aspect_(aSelector));
  122. return self}, function($ctx1) {$ctx1.fill(self,"changed:",{aSelector:aSelector},smalltalk.MKModel)})},
  123. messageSends: ["announce:", "aspect:"]}),
  124. smalltalk.MKModel);
  125. smalltalk.addMethod(
  126. smalltalk.method({
  127. selector: "initialize",
  128. fn: function (){
  129. var self=this;
  130. function $Announcer(){return smalltalk.Announcer||(typeof Announcer=="undefined"?nil:Announcer)}
  131. return smalltalk.withContext(function($ctx1) {
  132. smalltalk.MKModel.superclass.fn.prototype._initialize.apply(_st(self), []);
  133. self["@announcer"]=_st($Announcer())._new();
  134. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.MKModel)})},
  135. messageSends: ["initialize", "new"]}),
  136. smalltalk.MKModel);
  137. smalltalk.addMethod(
  138. smalltalk.method({
  139. selector: "on:do:",
  140. fn: function (anAnnouncement,aBlock){
  141. var self=this;
  142. return smalltalk.withContext(function($ctx1) {
  143. _st(self["@announcer"])._on_do_(anAnnouncement,aBlock);
  144. return self}, function($ctx1) {$ctx1.fill(self,"on:do:",{anAnnouncement:anAnnouncement,aBlock:aBlock},smalltalk.MKModel)})},
  145. messageSends: ["on:do:"]}),
  146. smalltalk.MKModel);
  147. smalltalk.addMethod(
  148. smalltalk.method({
  149. selector: "on:send:to:",
  150. fn: function (anAnnouncement,aSelector,anObject){
  151. var self=this;
  152. return smalltalk.withContext(function($ctx1) {
  153. _st(self["@announcer"])._on_send_to_(anAnnouncement,aSelector,anObject);
  154. return self}, function($ctx1) {$ctx1.fill(self,"on:send:to:",{anAnnouncement:anAnnouncement,aSelector:aSelector,anObject:anObject},smalltalk.MKModel)})},
  155. messageSends: ["on:send:to:"]}),
  156. smalltalk.MKModel);
  157. smalltalk.addClass('MKModelChanged', smalltalk.Object, ['aspect'], 'Moka-Core');
  158. smalltalk.addMethod(
  159. smalltalk.method({
  160. selector: "aspect",
  161. fn: function (){
  162. var self=this;
  163. return smalltalk.withContext(function($ctx1) {
  164. var $1;
  165. $1=self["@aspect"];
  166. return $1;
  167. }, function($ctx1) {$ctx1.fill(self,"aspect",{},smalltalk.MKModelChanged)})},
  168. messageSends: []}),
  169. smalltalk.MKModelChanged);
  170. smalltalk.addMethod(
  171. smalltalk.method({
  172. selector: "aspect:",
  173. fn: function (aSelector){
  174. var self=this;
  175. return smalltalk.withContext(function($ctx1) {
  176. self["@aspect"]=aSelector;
  177. return self}, function($ctx1) {$ctx1.fill(self,"aspect:",{aSelector:aSelector},smalltalk.MKModelChanged)})},
  178. messageSends: []}),
  179. smalltalk.MKModelChanged);
  180. smalltalk.addMethod(
  181. smalltalk.method({
  182. selector: "aspect:",
  183. fn: function (aSelector){
  184. var self=this;
  185. return smalltalk.withContext(function($ctx1) {
  186. var $2,$3,$1;
  187. $2=self._new();
  188. _st($2)._aspect_(aSelector);
  189. $3=_st($2)._yourself();
  190. $1=$3;
  191. return $1;
  192. }, function($ctx1) {$ctx1.fill(self,"aspect:",{aSelector:aSelector},smalltalk.MKModelChanged.klass)})},
  193. messageSends: ["aspect:", "new", "yourself"]}),
  194. smalltalk.MKModelChanged.klass);
  195. smalltalk.addClass('MKView', smalltalk.Widget, ['controller', 'model', 'wrapper'], 'Moka-Core');
  196. smalltalk.addMethod(
  197. smalltalk.method({
  198. selector: "controller",
  199. fn: function (){
  200. var self=this;
  201. return smalltalk.withContext(function($ctx1) {
  202. var $1,$2;
  203. $1=self["@controller"];
  204. if(($receiver = $1) == nil || $receiver == undefined){
  205. self._controller_(self._defaultController());
  206. } else {
  207. $1;
  208. };
  209. $2=self["@controller"];
  210. return $2;
  211. }, function($ctx1) {$ctx1.fill(self,"controller",{},smalltalk.MKView)})},
  212. messageSends: ["ifNil:", "controller:", "defaultController"]}),
  213. smalltalk.MKView);
  214. smalltalk.addMethod(
  215. smalltalk.method({
  216. selector: "controller:",
  217. fn: function (aController){
  218. var self=this;
  219. return smalltalk.withContext(function($ctx1) {
  220. var $1,$2;
  221. self["@controller"]=aController;
  222. $1=aController;
  223. _st($1)._view_(self);
  224. $2=_st($1)._model_(self._model());
  225. return self}, function($ctx1) {$ctx1.fill(self,"controller:",{aController:aController},smalltalk.MKView)})},
  226. messageSends: ["view:", "model:", "model"]}),
  227. smalltalk.MKView);
  228. smalltalk.addMethod(
  229. smalltalk.method({
  230. selector: "defaultController",
  231. fn: function (){
  232. var self=this;
  233. return smalltalk.withContext(function($ctx1) {
  234. var $1;
  235. $1=_st(self._defaultControllerClass())._new();
  236. return $1;
  237. }, function($ctx1) {$ctx1.fill(self,"defaultController",{},smalltalk.MKView)})},
  238. messageSends: ["new", "defaultControllerClass"]}),
  239. smalltalk.MKView);
  240. smalltalk.addMethod(
  241. smalltalk.method({
  242. selector: "defaultControllerClass",
  243. fn: function (){
  244. var self=this;
  245. function $MKController(){return smalltalk.MKController||(typeof MKController=="undefined"?nil:MKController)}
  246. return smalltalk.withContext(function($ctx1) {
  247. var $1;
  248. $1=$MKController();
  249. return $1;
  250. }, function($ctx1) {$ctx1.fill(self,"defaultControllerClass",{},smalltalk.MKView)})},
  251. messageSends: []}),
  252. smalltalk.MKView);
  253. smalltalk.addMethod(
  254. smalltalk.method({
  255. selector: "model",
  256. fn: function (){
  257. var self=this;
  258. return smalltalk.withContext(function($ctx1) {
  259. var $1;
  260. $1=self["@model"];
  261. return $1;
  262. }, function($ctx1) {$ctx1.fill(self,"model",{},smalltalk.MKView)})},
  263. messageSends: []}),
  264. smalltalk.MKView);
  265. smalltalk.addMethod(
  266. smalltalk.method({
  267. selector: "model:",
  268. fn: function (aModel){
  269. var self=this;
  270. return smalltalk.withContext(function($ctx1) {
  271. self["@model"]=aModel;
  272. self._observeModel();
  273. return self}, function($ctx1) {$ctx1.fill(self,"model:",{aModel:aModel},smalltalk.MKView)})},
  274. messageSends: ["observeModel"]}),
  275. smalltalk.MKView);
  276. smalltalk.addMethod(
  277. smalltalk.method({
  278. selector: "observeModel",
  279. fn: function (){
  280. var self=this;
  281. return smalltalk.withContext(function($ctx1) {
  282. return self}, function($ctx1) {$ctx1.fill(self,"observeModel",{},smalltalk.MKView)})},
  283. messageSends: []}),
  284. smalltalk.MKView);
  285. smalltalk.addMethod(
  286. smalltalk.method({
  287. selector: "render",
  288. fn: function (){
  289. var self=this;
  290. return smalltalk.withContext(function($ctx1) {
  291. self._appendToJQuery_("body"._asJQuery());
  292. return self}, function($ctx1) {$ctx1.fill(self,"render",{},smalltalk.MKView)})},
  293. messageSends: ["appendToJQuery:", "asJQuery"]}),
  294. smalltalk.MKView);
  295. smalltalk.addMethod(
  296. smalltalk.method({
  297. selector: "renderContentOn:",
  298. fn: function (html){
  299. var self=this;
  300. return smalltalk.withContext(function($ctx1) {
  301. return self}, function($ctx1) {$ctx1.fill(self,"renderContentOn:",{html:html},smalltalk.MKView)})},
  302. messageSends: []}),
  303. smalltalk.MKView);
  304. smalltalk.addMethod(
  305. smalltalk.method({
  306. selector: "renderOn:",
  307. fn: function (html){
  308. var self=this;
  309. return smalltalk.withContext(function($ctx1) {
  310. var $1,$2;
  311. $1=_st(html)._div();
  312. _st($1)._class_("moka_view");
  313. $2=_st($1)._yourself();
  314. self["@wrapper"]=$2;
  315. _st(self["@wrapper"])._with_((function(){
  316. return smalltalk.withContext(function($ctx2) {
  317. return self._renderContentOn_(html);
  318. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  319. return self}, function($ctx1) {$ctx1.fill(self,"renderOn:",{html:html},smalltalk.MKView)})},
  320. messageSends: ["class:", "div", "yourself", "with:", "renderContentOn:"]}),
  321. smalltalk.MKView);
  322. smalltalk.addMethod(
  323. smalltalk.method({
  324. selector: "update",
  325. fn: function (){
  326. var self=this;
  327. return smalltalk.withContext(function($ctx1) {
  328. var $1;
  329. $1=self["@wrapper"];
  330. if(($receiver = $1) == nil || $receiver == undefined){
  331. self._error_("The view has not been rendered yet");
  332. } else {
  333. $1;
  334. };
  335. _st(_st(self["@wrapper"])._asJQuery())._empty();
  336. _st((function(html){
  337. return smalltalk.withContext(function($ctx2) {
  338. return self._renderContentOn_(html);
  339. }, function($ctx2) {$ctx2.fillBlock({html:html},$ctx1)})}))._appendToJQuery_(_st(self["@wrapper"])._asJQuery());
  340. return self}, function($ctx1) {$ctx1.fill(self,"update",{},smalltalk.MKView)})},
  341. messageSends: ["ifNil:", "error:", "empty", "asJQuery", "appendToJQuery:", "renderContentOn:"]}),
  342. smalltalk.MKView);
  343. smalltalk.addMethod(
  344. smalltalk.method({
  345. selector: "model:",
  346. fn: function (aModel){
  347. var self=this;
  348. return smalltalk.withContext(function($ctx1) {
  349. var $2,$3,$1;
  350. $2=self._new();
  351. _st($2)._model_(aModel);
  352. $3=_st($2)._yourself();
  353. $1=$3;
  354. return $1;
  355. }, function($ctx1) {$ctx1.fill(self,"model:",{aModel:aModel},smalltalk.MKView.klass)})},
  356. messageSends: ["model:", "new", "yourself"]}),
  357. smalltalk.MKView.klass);
  358. smalltalk.addMethod(
  359. smalltalk.method({
  360. selector: "model:controller:",
  361. fn: function (aModel,aController){
  362. var self=this;
  363. return smalltalk.withContext(function($ctx1) {
  364. var $2,$3,$1;
  365. $2=self._model_(aModel);
  366. _st($2)._controller_(aController);
  367. $3=_st($2)._yourself();
  368. $1=$3;
  369. return $1;
  370. }, function($ctx1) {$ctx1.fill(self,"model:controller:",{aModel:aModel,aController:aController},smalltalk.MKView.klass)})},
  371. messageSends: ["controller:", "model:", "yourself"]}),
  372. smalltalk.MKView.klass);
  373. smalltalk.addClass('MKAspectView', smalltalk.MKView, ['aspect', 'label'], 'Moka-Core');
  374. smalltalk.addMethod(
  375. smalltalk.method({
  376. selector: "aspect",
  377. fn: function (){
  378. var self=this;
  379. return smalltalk.withContext(function($ctx1) {
  380. var $1;
  381. $1=self["@aspect"];
  382. return $1;
  383. }, function($ctx1) {$ctx1.fill(self,"aspect",{},smalltalk.MKAspectView)})},
  384. messageSends: []}),
  385. smalltalk.MKAspectView);
  386. smalltalk.addMethod(
  387. smalltalk.method({
  388. selector: "aspect:",
  389. fn: function (aSelector){
  390. var self=this;
  391. return smalltalk.withContext(function($ctx1) {
  392. self["@aspect"]=aSelector;
  393. _st(self._controller())._aspect_(aSelector);
  394. return self}, function($ctx1) {$ctx1.fill(self,"aspect:",{aSelector:aSelector},smalltalk.MKAspectView)})},
  395. messageSends: ["aspect:", "controller"]}),
  396. smalltalk.MKAspectView);
  397. smalltalk.addMethod(
  398. smalltalk.method({
  399. selector: "aspectValue",
  400. fn: function (){
  401. var self=this;
  402. return smalltalk.withContext(function($ctx1) {
  403. var $1;
  404. $1=_st(self._model())._perform_(self._aspect());
  405. return $1;
  406. }, function($ctx1) {$ctx1.fill(self,"aspectValue",{},smalltalk.MKAspectView)})},
  407. messageSends: ["perform:", "aspect", "model"]}),
  408. smalltalk.MKAspectView);
  409. smalltalk.addMethod(
  410. smalltalk.method({
  411. selector: "observeModel",
  412. fn: function (){
  413. var self=this;
  414. function $MKModelChanged(){return smalltalk.MKModelChanged||(typeof MKModelChanged=="undefined"?nil:MKModelChanged)}
  415. return smalltalk.withContext(function($ctx1) {
  416. smalltalk.MKAspectView.superclass.fn.prototype._observeModel.apply(_st(self), []);
  417. _st(self._model())._on_send_to_($MKModelChanged(),"update:",self);
  418. return self}, function($ctx1) {$ctx1.fill(self,"observeModel",{},smalltalk.MKAspectView)})},
  419. messageSends: ["observeModel", "on:send:to:", "model"]}),
  420. smalltalk.MKAspectView);
  421. smalltalk.addMethod(
  422. smalltalk.method({
  423. selector: "update:",
  424. fn: function (anAnnouncement){
  425. var self=this;
  426. return smalltalk.withContext(function($ctx1) {
  427. var $1;
  428. $1=_st(_st(anAnnouncement)._aspect()).__eq(self._aspect());
  429. if(smalltalk.assert($1)){
  430. self._update();
  431. };
  432. return self}, function($ctx1) {$ctx1.fill(self,"update:",{anAnnouncement:anAnnouncement},smalltalk.MKAspectView)})},
  433. messageSends: ["ifTrue:", "update", "=", "aspect"]}),
  434. smalltalk.MKAspectView);
  435. smalltalk.addMethod(
  436. smalltalk.method({
  437. selector: "model:aspect:",
  438. fn: function (aModel,aSelector){
  439. var self=this;
  440. return smalltalk.withContext(function($ctx1) {
  441. var $2,$3,$1;
  442. $2=self._model_(aModel);
  443. _st($2)._aspect_(aSelector);
  444. $3=_st($2)._yourself();
  445. $1=$3;
  446. return $1;
  447. }, function($ctx1) {$ctx1.fill(self,"model:aspect:",{aModel:aModel,aSelector:aSelector},smalltalk.MKAspectView.klass)})},
  448. messageSends: ["aspect:", "model:", "yourself"]}),
  449. smalltalk.MKAspectView.klass);
  450. })(global_smalltalk,global_nil,global__st);