2
0

Moka-Core.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. (function(smalltalk,nil,_st){
  2. smalltalk.addPackage('Moka-Core');
  3. smalltalk.addClass('MKController', smalltalk.Object, ['view', 'model'], 'Moka-Core');
  4. smalltalk.MKController.comment="I implement the Controller part of the MVC pattern in Moka.\x0a\x0aI hold onto my `model` and `view`, set with `MKView >> controller:`.";
  5. smalltalk.addMethod(
  6. smalltalk.method({
  7. selector: "model",
  8. category: 'accessing',
  9. fn: function (){
  10. var self=this;
  11. return smalltalk.withContext(function($ctx1) {
  12. var $1;
  13. $1=self["@model"];
  14. return $1;
  15. }, function($ctx1) {$ctx1.fill(self,"model",{},smalltalk.MKController)})},
  16. args: [],
  17. source: "model\x0a\x09^ model",
  18. messageSends: [],
  19. referencedClasses: []
  20. }),
  21. smalltalk.MKController);
  22. smalltalk.addMethod(
  23. smalltalk.method({
  24. selector: "model:",
  25. category: 'accessing',
  26. fn: function (aModel){
  27. var self=this;
  28. return smalltalk.withContext(function($ctx1) {
  29. self["@model"]=aModel;
  30. return self}, function($ctx1) {$ctx1.fill(self,"model:",{aModel:aModel},smalltalk.MKController)})},
  31. args: ["aModel"],
  32. source: "model: aModel\x0a\x09model := aModel",
  33. messageSends: [],
  34. referencedClasses: []
  35. }),
  36. smalltalk.MKController);
  37. smalltalk.addMethod(
  38. smalltalk.method({
  39. selector: "view",
  40. category: 'accessing',
  41. fn: function (){
  42. var self=this;
  43. return smalltalk.withContext(function($ctx1) {
  44. var $1;
  45. $1=self["@view"];
  46. return $1;
  47. }, function($ctx1) {$ctx1.fill(self,"view",{},smalltalk.MKController)})},
  48. args: [],
  49. source: "view\x0a\x09^ view",
  50. messageSends: [],
  51. referencedClasses: []
  52. }),
  53. smalltalk.MKController);
  54. smalltalk.addMethod(
  55. smalltalk.method({
  56. selector: "view:",
  57. category: 'accessing',
  58. fn: function (aView){
  59. var self=this;
  60. return smalltalk.withContext(function($ctx1) {
  61. self["@view"]=aView;
  62. return self}, function($ctx1) {$ctx1.fill(self,"view:",{aView:aView},smalltalk.MKController)})},
  63. args: ["aView"],
  64. source: "view: aView\x0a\x09view := aView",
  65. messageSends: [],
  66. referencedClasses: []
  67. }),
  68. smalltalk.MKController);
  69. smalltalk.addClass('MKAspectController', smalltalk.MKController, ['aspect'], 'Moka-Core');
  70. smalltalk.MKAspectController.comment="I am an abstract controller for performing one action using an `aspect` on a model.\x0a\x0a## API\x0a\x0a- Use `#aspect:` to plug a selector to be performed on the model\x0a- Subclasses can either use `#performActionWith:` or `#performAction` to evaluate the `aspect` selector on the model with one or no argument.";
  71. smalltalk.addMethod(
  72. smalltalk.method({
  73. selector: "aspect",
  74. category: 'accessing',
  75. fn: function (){
  76. var self=this;
  77. return smalltalk.withContext(function($ctx1) {
  78. var $1;
  79. $1=self["@aspect"];
  80. return $1;
  81. }, function($ctx1) {$ctx1.fill(self,"aspect",{},smalltalk.MKAspectController)})},
  82. args: [],
  83. source: "aspect\x0a\x09^ aspect",
  84. messageSends: [],
  85. referencedClasses: []
  86. }),
  87. smalltalk.MKAspectController);
  88. smalltalk.addMethod(
  89. smalltalk.method({
  90. selector: "aspect:",
  91. category: 'accessing',
  92. fn: function (aSelector){
  93. var self=this;
  94. return smalltalk.withContext(function($ctx1) {
  95. self["@aspect"]=aSelector;
  96. return self}, function($ctx1) {$ctx1.fill(self,"aspect:",{aSelector:aSelector},smalltalk.MKAspectController)})},
  97. args: ["aSelector"],
  98. source: "aspect: aSelector\x0a\x09aspect := aSelector",
  99. messageSends: [],
  100. referencedClasses: []
  101. }),
  102. smalltalk.MKAspectController);
  103. smalltalk.addMethod(
  104. smalltalk.method({
  105. selector: "performAction",
  106. category: 'actions',
  107. fn: function (){
  108. var self=this;
  109. return smalltalk.withContext(function($ctx1) {
  110. var $1;
  111. $1=self._aspect();
  112. if(($receiver = $1) == nil || $receiver == undefined){
  113. $1;
  114. } else {
  115. _st(self._model())._perform_(self._aspect());
  116. };
  117. return self}, function($ctx1) {$ctx1.fill(self,"performAction",{},smalltalk.MKAspectController)})},
  118. args: [],
  119. source: "performAction\x0a\x09self aspect ifNotNil: [\x0a\x09\x09self model \x0a\x09\x09\x09perform: self aspect ]",
  120. messageSends: ["ifNotNil:", "perform:", "aspect", "model"],
  121. referencedClasses: []
  122. }),
  123. smalltalk.MKAspectController);
  124. smalltalk.addMethod(
  125. smalltalk.method({
  126. selector: "performActionWith:",
  127. category: 'actions',
  128. fn: function (anObject){
  129. var self=this;
  130. return smalltalk.withContext(function($ctx1) {
  131. var $1;
  132. $1=self._aspect();
  133. if(($receiver = $1) == nil || $receiver == undefined){
  134. $1;
  135. } else {
  136. _st(self._model())._perform_withArguments_(_st(self._aspect())._asMutator(),[anObject]);
  137. };
  138. return self}, function($ctx1) {$ctx1.fill(self,"performActionWith:",{anObject:anObject},smalltalk.MKAspectController)})},
  139. args: ["anObject"],
  140. source: "performActionWith: anObject\x0a\x09self aspect ifNotNil: [\x0a\x09\x09self model \x0a\x09\x09\x09perform: self aspect asMutator\x0a\x09\x09\x09withArguments: { anObject } ]",
  141. messageSends: ["ifNotNil:", "perform:withArguments:", "asMutator", "aspect", "model"],
  142. referencedClasses: []
  143. }),
  144. smalltalk.MKAspectController);
  145. smalltalk.addClass('MKModel', smalltalk.Object, ['announcer'], 'Moka-Core');
  146. smalltalk.MKModel.comment="I implement the Model part of the MVC pattern in Moka.\x0a\x0aI am the abstract superclass of all Moka model. The observer pattern is implemented through an `announcer` object.\x0a\x0a## API\x0a\x0a- Listening\x0a\x0a Use `#on:do:` or `#on:send:to:` to listen to model changes\x0a\x0a- Triggering\x0a\x0a `#changed:` is the builtin method used to trigger `#update:` in views.\x0a Use `#announce:` in subclasses to trigger announcements to listeners.";
  147. smalltalk.addMethod(
  148. smalltalk.method({
  149. selector: "announce:",
  150. category: 'announcements',
  151. fn: function (anAnnouncement){
  152. var self=this;
  153. return smalltalk.withContext(function($ctx1) {
  154. _st(self["@announcer"])._announce_(anAnnouncement);
  155. return self}, function($ctx1) {$ctx1.fill(self,"announce:",{anAnnouncement:anAnnouncement},smalltalk.MKModel)})},
  156. args: ["anAnnouncement"],
  157. source: "announce: anAnnouncement\x0a\x09announcer announce: anAnnouncement",
  158. messageSends: ["announce:"],
  159. referencedClasses: []
  160. }),
  161. smalltalk.MKModel);
  162. smalltalk.addMethod(
  163. smalltalk.method({
  164. selector: "changed:",
  165. category: 'announcements',
  166. fn: function (aSelector){
  167. var self=this;
  168. function $MKModelChanged(){return smalltalk.MKModelChanged||(typeof MKModelChanged=="undefined"?nil:MKModelChanged)}
  169. return smalltalk.withContext(function($ctx1) {
  170. self._announce_(_st($MKModelChanged())._aspect_(aSelector));
  171. return self}, function($ctx1) {$ctx1.fill(self,"changed:",{aSelector:aSelector},smalltalk.MKModel)})},
  172. args: ["aSelector"],
  173. source: "changed: aSelector\x0a\x09\x22Trigger `#update:` to all listening aspect views\x22\x0a\x09\x0a\x09self announce: (MKModelChanged aspect: aSelector)",
  174. messageSends: ["announce:", "aspect:"],
  175. referencedClasses: ["MKModelChanged"]
  176. }),
  177. smalltalk.MKModel);
  178. smalltalk.addMethod(
  179. smalltalk.method({
  180. selector: "initialize",
  181. category: 'initialization',
  182. fn: function (){
  183. var self=this;
  184. function $Announcer(){return smalltalk.Announcer||(typeof Announcer=="undefined"?nil:Announcer)}
  185. return smalltalk.withContext(function($ctx1) {
  186. smalltalk.MKModel.superclass.fn.prototype._initialize.apply(_st(self), []);
  187. self["@announcer"]=_st($Announcer())._new();
  188. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.MKModel)})},
  189. args: [],
  190. source: "initialize\x0a\x09super initialize.\x0a\x09announcer := Announcer new",
  191. messageSends: ["initialize", "new"],
  192. referencedClasses: ["Announcer"]
  193. }),
  194. smalltalk.MKModel);
  195. smalltalk.addMethod(
  196. smalltalk.method({
  197. selector: "on:do:",
  198. category: 'announcements',
  199. fn: function (anAnnouncement,aBlock){
  200. var self=this;
  201. return smalltalk.withContext(function($ctx1) {
  202. _st(self["@announcer"])._on_do_(anAnnouncement,aBlock);
  203. return self}, function($ctx1) {$ctx1.fill(self,"on:do:",{anAnnouncement:anAnnouncement,aBlock:aBlock},smalltalk.MKModel)})},
  204. args: ["anAnnouncement", "aBlock"],
  205. source: "on: anAnnouncement do: aBlock\x0a\x09announcer on: anAnnouncement do: aBlock",
  206. messageSends: ["on:do:"],
  207. referencedClasses: []
  208. }),
  209. smalltalk.MKModel);
  210. smalltalk.addMethod(
  211. smalltalk.method({
  212. selector: "on:send:to:",
  213. category: 'announcements',
  214. fn: function (anAnnouncement,aSelector,anObject){
  215. var self=this;
  216. return smalltalk.withContext(function($ctx1) {
  217. _st(self["@announcer"])._on_send_to_(anAnnouncement,aSelector,anObject);
  218. return self}, function($ctx1) {$ctx1.fill(self,"on:send:to:",{anAnnouncement:anAnnouncement,aSelector:aSelector,anObject:anObject},smalltalk.MKModel)})},
  219. args: ["anAnnouncement", "aSelector", "anObject"],
  220. source: "on: anAnnouncement send: aSelector to: anObject\x0a\x09announcer on: anAnnouncement send: aSelector to: anObject",
  221. messageSends: ["on:send:to:"],
  222. referencedClasses: []
  223. }),
  224. smalltalk.MKModel);
  225. smalltalk.addClass('MKModelChanged', smalltalk.Object, ['aspect'], 'Moka-Core');
  226. smalltalk.MKModelChanged.comment="I am an announcement announced when a model is changed.";
  227. smalltalk.addMethod(
  228. smalltalk.method({
  229. selector: "aspect",
  230. category: 'accessing',
  231. fn: function (){
  232. var self=this;
  233. return smalltalk.withContext(function($ctx1) {
  234. var $1;
  235. $1=self["@aspect"];
  236. return $1;
  237. }, function($ctx1) {$ctx1.fill(self,"aspect",{},smalltalk.MKModelChanged)})},
  238. args: [],
  239. source: "aspect\x0a\x09^ aspect",
  240. messageSends: [],
  241. referencedClasses: []
  242. }),
  243. smalltalk.MKModelChanged);
  244. smalltalk.addMethod(
  245. smalltalk.method({
  246. selector: "aspect:",
  247. category: 'accessing',
  248. fn: function (aSelector){
  249. var self=this;
  250. return smalltalk.withContext(function($ctx1) {
  251. self["@aspect"]=aSelector;
  252. return self}, function($ctx1) {$ctx1.fill(self,"aspect:",{aSelector:aSelector},smalltalk.MKModelChanged)})},
  253. args: ["aSelector"],
  254. source: "aspect: aSelector\x0a\x09aspect := aSelector",
  255. messageSends: [],
  256. referencedClasses: []
  257. }),
  258. smalltalk.MKModelChanged);
  259. smalltalk.addMethod(
  260. smalltalk.method({
  261. selector: "aspect:",
  262. category: 'instance creation',
  263. fn: function (aSelector){
  264. var self=this;
  265. return smalltalk.withContext(function($ctx1) {
  266. var $2,$3,$1;
  267. $2=self._new();
  268. _st($2)._aspect_(aSelector);
  269. $3=_st($2)._yourself();
  270. $1=$3;
  271. return $1;
  272. }, function($ctx1) {$ctx1.fill(self,"aspect:",{aSelector:aSelector},smalltalk.MKModelChanged.klass)})},
  273. args: ["aSelector"],
  274. source: "aspect: aSelector\x0a\x09^ self new\x0a\x09\x09aspect: aSelector;\x0a\x09\x09yourself",
  275. messageSends: ["aspect:", "new", "yourself"],
  276. referencedClasses: []
  277. }),
  278. smalltalk.MKModelChanged.klass);
  279. smalltalk.addClass('MKView', smalltalk.Widget, ['controller', 'model', 'wrapper'], 'Moka-Core');
  280. smalltalk.MKView.comment="I implement the View part of the MVC pattern in Moka.\x0a\x0a## API\x0a- Instance can be created with the `MKView class >> model:*` convenience methods\x0a- rendering is done through `#renderContentOn:`, to be overridden in concrete view classes\x0a- `#update` provide updating facility, refreshing the entire view\x0a- subclasses can override `#defaultControllerClass` to provide a default controller specific to a view\x0a- subclasses can override `#observeModel`.";
  281. smalltalk.addMethod(
  282. smalltalk.method({
  283. selector: "controller",
  284. category: 'accessing',
  285. fn: function (){
  286. var self=this;
  287. return smalltalk.withContext(function($ctx1) {
  288. var $1,$2;
  289. $1=self["@controller"];
  290. if(($receiver = $1) == nil || $receiver == undefined){
  291. self._controller_(self._defaultController());
  292. } else {
  293. $1;
  294. };
  295. $2=self["@controller"];
  296. return $2;
  297. }, function($ctx1) {$ctx1.fill(self,"controller",{},smalltalk.MKView)})},
  298. args: [],
  299. source: "controller\x0a\x09\x22Answer the current receiver's controller.\x0a\x09If no controller is installed yet, install the `defaultController`\x0a\x09of the receiver and answer it.\x22\x0a\x09\x0a\x09controller ifNil: [ \x0a\x09\x09self controller: self defaultController ].\x0a\x09^ controller",
  300. messageSends: ["ifNil:", "controller:", "defaultController"],
  301. referencedClasses: []
  302. }),
  303. smalltalk.MKView);
  304. smalltalk.addMethod(
  305. smalltalk.method({
  306. selector: "controller:",
  307. category: 'accessing',
  308. fn: function (aController){
  309. var self=this;
  310. return smalltalk.withContext(function($ctx1) {
  311. var $1,$2;
  312. self["@controller"]=aController;
  313. $1=aController;
  314. _st($1)._view_(self);
  315. $2=_st($1)._model_(self._model());
  316. return self}, function($ctx1) {$ctx1.fill(self,"controller:",{aController:aController},smalltalk.MKView)})},
  317. args: ["aController"],
  318. source: "controller: aController\x0a\x09\x22Install `aController` to be the receiver's controller\x22\x0a\x09\x0a\x09controller := aController.\x0a\x09aController \x0a\x09\x09view: self;\x0a\x09\x09model: self model",
  319. messageSends: ["view:", "model:", "model"],
  320. referencedClasses: []
  321. }),
  322. smalltalk.MKView);
  323. smalltalk.addMethod(
  324. smalltalk.method({
  325. selector: "defaultController",
  326. category: 'factory',
  327. fn: function (){
  328. var self=this;
  329. return smalltalk.withContext(function($ctx1) {
  330. var $1;
  331. $1=_st(self._defaultControllerClass())._new();
  332. return $1;
  333. }, function($ctx1) {$ctx1.fill(self,"defaultController",{},smalltalk.MKView)})},
  334. args: [],
  335. source: "defaultController\x0a\x09^ self defaultControllerClass new",
  336. messageSends: ["new", "defaultControllerClass"],
  337. referencedClasses: []
  338. }),
  339. smalltalk.MKView);
  340. smalltalk.addMethod(
  341. smalltalk.method({
  342. selector: "defaultControllerClass",
  343. category: 'defaults',
  344. fn: function (){
  345. var self=this;
  346. function $MKController(){return smalltalk.MKController||(typeof MKController=="undefined"?nil:MKController)}
  347. return smalltalk.withContext(function($ctx1) {
  348. var $1;
  349. $1=$MKController();
  350. return $1;
  351. }, function($ctx1) {$ctx1.fill(self,"defaultControllerClass",{},smalltalk.MKView)})},
  352. args: [],
  353. source: "defaultControllerClass\x0a\x09^ MKController",
  354. messageSends: [],
  355. referencedClasses: ["MKController"]
  356. }),
  357. smalltalk.MKView);
  358. smalltalk.addMethod(
  359. smalltalk.method({
  360. selector: "model",
  361. category: 'accessing',
  362. fn: function (){
  363. var self=this;
  364. return smalltalk.withContext(function($ctx1) {
  365. var $1;
  366. $1=self["@model"];
  367. return $1;
  368. }, function($ctx1) {$ctx1.fill(self,"model",{},smalltalk.MKView)})},
  369. args: [],
  370. source: "model\x0a\x09^ model",
  371. messageSends: [],
  372. referencedClasses: []
  373. }),
  374. smalltalk.MKView);
  375. smalltalk.addMethod(
  376. smalltalk.method({
  377. selector: "model:",
  378. category: 'accessing',
  379. fn: function (aModel){
  380. var self=this;
  381. return smalltalk.withContext(function($ctx1) {
  382. self["@model"]=aModel;
  383. self._observeModel();
  384. return self}, function($ctx1) {$ctx1.fill(self,"model:",{aModel:aModel},smalltalk.MKView)})},
  385. args: ["aModel"],
  386. source: "model: aModel\x0a\x09model := aModel.\x0a\x09self observeModel",
  387. messageSends: ["observeModel"],
  388. referencedClasses: []
  389. }),
  390. smalltalk.MKView);
  391. smalltalk.addMethod(
  392. smalltalk.method({
  393. selector: "observeModel",
  394. category: 'observing',
  395. fn: function (){
  396. var self=this;
  397. return smalltalk.withContext(function($ctx1) {
  398. return self}, function($ctx1) {$ctx1.fill(self,"observeModel",{},smalltalk.MKView)})},
  399. args: [],
  400. source: "observeModel\x0a\x09\x22No op. Override in subclasses\x22",
  401. messageSends: [],
  402. referencedClasses: []
  403. }),
  404. smalltalk.MKView);
  405. smalltalk.addMethod(
  406. smalltalk.method({
  407. selector: "render",
  408. category: 'rendering',
  409. fn: function (){
  410. var self=this;
  411. return smalltalk.withContext(function($ctx1) {
  412. self._appendToJQuery_("body"._asJQuery());
  413. return self}, function($ctx1) {$ctx1.fill(self,"render",{},smalltalk.MKView)})},
  414. args: [],
  415. source: "render\x0a\x09\x22Append the receiver to the BODY element\x22\x0a\x09\x0a\x09self appendToJQuery: 'body' asJQuery",
  416. messageSends: ["appendToJQuery:", "asJQuery"],
  417. referencedClasses: []
  418. }),
  419. smalltalk.MKView);
  420. smalltalk.addMethod(
  421. smalltalk.method({
  422. selector: "renderContentOn:",
  423. category: 'rendering',
  424. fn: function (html){
  425. var self=this;
  426. return smalltalk.withContext(function($ctx1) {
  427. return self}, function($ctx1) {$ctx1.fill(self,"renderContentOn:",{html:html},smalltalk.MKView)})},
  428. args: ["html"],
  429. source: "renderContentOn: html\x0a\x09\x22Main rendering method, override in subclasses.\x22",
  430. messageSends: [],
  431. referencedClasses: []
  432. }),
  433. smalltalk.MKView);
  434. smalltalk.addMethod(
  435. smalltalk.method({
  436. selector: "renderOn:",
  437. category: 'rendering',
  438. fn: function (html){
  439. var self=this;
  440. return smalltalk.withContext(function($ctx1) {
  441. var $1,$2;
  442. $1=_st(html)._div();
  443. _st($1)._class_("moka_view");
  444. $2=_st($1)._yourself();
  445. self["@wrapper"]=$2;
  446. _st(self["@wrapper"])._with_((function(){
  447. return smalltalk.withContext(function($ctx2) {
  448. return self._renderContentOn_(html);
  449. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  450. return self}, function($ctx1) {$ctx1.fill(self,"renderOn:",{html:html},smalltalk.MKView)})},
  451. args: ["html"],
  452. source: "renderOn: html\x0a\x09\x22Basic rendering method.\x0a\x09Wraps the content with a `wrapper` div for updating the receiver.\x0a\x09\x0a\x09Do not override this method, but `#renderContentOn:`\x22\x0a\x09\x0a\x09wrapper := html div\x0a\x09\x09class: 'moka_view';\x0a\x09\x09yourself.\x0a\x09wrapper with: [ self renderContentOn: html ]",
  453. messageSends: ["class:", "div", "yourself", "with:", "renderContentOn:"],
  454. referencedClasses: []
  455. }),
  456. smalltalk.MKView);
  457. smalltalk.addMethod(
  458. smalltalk.method({
  459. selector: "update",
  460. category: 'updating',
  461. fn: function (){
  462. var self=this;
  463. return smalltalk.withContext(function($ctx1) {
  464. var $1;
  465. $1=self["@wrapper"];
  466. if(($receiver = $1) == nil || $receiver == undefined){
  467. self._error_("The view has not been rendered yet");
  468. } else {
  469. $1;
  470. };
  471. _st(_st(self["@wrapper"])._asJQuery())._empty();
  472. _st((function(html){
  473. return smalltalk.withContext(function($ctx2) {
  474. return self._renderContentOn_(html);
  475. }, function($ctx2) {$ctx2.fillBlock({html:html},$ctx1)})}))._appendToJQuery_(_st(self["@wrapper"])._asJQuery());
  476. return self}, function($ctx1) {$ctx1.fill(self,"update",{},smalltalk.MKView)})},
  477. args: [],
  478. source: "update\x0a\x09\x22Update the view's content.\x22\x0a\x09\x0a\x09wrapper ifNil: [ self error: 'The view has not been rendered yet' ].\x0a\x09\x0a\x09wrapper asJQuery empty.\x0a\x09[ :html | self renderContentOn: html ] \x0a\x09\x09appendToJQuery: wrapper asJQuery",
  479. messageSends: ["ifNil:", "error:", "empty", "asJQuery", "appendToJQuery:", "renderContentOn:"],
  480. referencedClasses: []
  481. }),
  482. smalltalk.MKView);
  483. smalltalk.addMethod(
  484. smalltalk.method({
  485. selector: "model:",
  486. category: 'instance creation',
  487. fn: function (aModel){
  488. var self=this;
  489. return smalltalk.withContext(function($ctx1) {
  490. var $2,$3,$1;
  491. $2=self._new();
  492. _st($2)._model_(aModel);
  493. $3=_st($2)._yourself();
  494. $1=$3;
  495. return $1;
  496. }, function($ctx1) {$ctx1.fill(self,"model:",{aModel:aModel},smalltalk.MKView.klass)})},
  497. args: ["aModel"],
  498. source: "model: aModel\x0a\x09^ self new\x0a\x09\x09model: aModel;\x0a\x09\x09yourself",
  499. messageSends: ["model:", "new", "yourself"],
  500. referencedClasses: []
  501. }),
  502. smalltalk.MKView.klass);
  503. smalltalk.addMethod(
  504. smalltalk.method({
  505. selector: "model:controller:",
  506. category: 'instance creation',
  507. fn: function (aModel,aController){
  508. var self=this;
  509. return smalltalk.withContext(function($ctx1) {
  510. var $2,$3,$1;
  511. $2=self._model_(aModel);
  512. _st($2)._controller_(aController);
  513. $3=_st($2)._yourself();
  514. $1=$3;
  515. return $1;
  516. }, function($ctx1) {$ctx1.fill(self,"model:controller:",{aModel:aModel,aController:aController},smalltalk.MKView.klass)})},
  517. args: ["aModel", "aController"],
  518. source: "model: aModel controller: aController\x0a\x09^ (self model: aModel)\x0a\x09\x09controller: aController;\x0a\x09\x09yourself",
  519. messageSends: ["controller:", "model:", "yourself"],
  520. referencedClasses: []
  521. }),
  522. smalltalk.MKView.klass);
  523. smalltalk.addClass('MKAspectView', smalltalk.MKView, ['aspect', 'label'], 'Moka-Core');
  524. smalltalk.MKAspectView.comment="I am an abstract view which state depend on an `aspect` of a model. \x0a\x0a##API\x0a\x0a- Use the `#aspect:` to listen to a specific aspect of a model. Changes will then trigger `#update`.";
  525. smalltalk.addMethod(
  526. smalltalk.method({
  527. selector: "aspect",
  528. category: 'accessing',
  529. fn: function (){
  530. var self=this;
  531. return smalltalk.withContext(function($ctx1) {
  532. var $1;
  533. $1=self["@aspect"];
  534. return $1;
  535. }, function($ctx1) {$ctx1.fill(self,"aspect",{},smalltalk.MKAspectView)})},
  536. args: [],
  537. source: "aspect\x0a\x09^ aspect",
  538. messageSends: [],
  539. referencedClasses: []
  540. }),
  541. smalltalk.MKAspectView);
  542. smalltalk.addMethod(
  543. smalltalk.method({
  544. selector: "aspect:",
  545. category: 'accessing',
  546. fn: function (aSelector){
  547. var self=this;
  548. return smalltalk.withContext(function($ctx1) {
  549. self["@aspect"]=aSelector;
  550. _st(self._controller())._aspect_(aSelector);
  551. return self}, function($ctx1) {$ctx1.fill(self,"aspect:",{aSelector:aSelector},smalltalk.MKAspectView)})},
  552. args: ["aSelector"],
  553. source: "aspect: aSelector\x0a\x09aspect := aSelector.\x0a\x09self controller aspect: aSelector",
  554. messageSends: ["aspect:", "controller"],
  555. referencedClasses: []
  556. }),
  557. smalltalk.MKAspectView);
  558. smalltalk.addMethod(
  559. smalltalk.method({
  560. selector: "aspectValue",
  561. category: 'accessing',
  562. fn: function (){
  563. var self=this;
  564. return smalltalk.withContext(function($ctx1) {
  565. var $1;
  566. $1=_st(self._model())._perform_(self._aspect());
  567. return $1;
  568. }, function($ctx1) {$ctx1.fill(self,"aspectValue",{},smalltalk.MKAspectView)})},
  569. args: [],
  570. source: "aspectValue\x0a\x09^ self model perform: self aspect",
  571. messageSends: ["perform:", "aspect", "model"],
  572. referencedClasses: []
  573. }),
  574. smalltalk.MKAspectView);
  575. smalltalk.addMethod(
  576. smalltalk.method({
  577. selector: "observeModel",
  578. category: 'observing',
  579. fn: function (){
  580. var self=this;
  581. function $MKModelChanged(){return smalltalk.MKModelChanged||(typeof MKModelChanged=="undefined"?nil:MKModelChanged)}
  582. return smalltalk.withContext(function($ctx1) {
  583. smalltalk.MKAspectView.superclass.fn.prototype._observeModel.apply(_st(self), []);
  584. _st(self._model())._on_send_to_($MKModelChanged(),"update:",self);
  585. return self}, function($ctx1) {$ctx1.fill(self,"observeModel",{},smalltalk.MKAspectView)})},
  586. args: [],
  587. source: "observeModel\x0a\x09super observeModel.\x0a\x09\x0a\x09self model\x0a\x09\x09on: MKModelChanged\x0a\x09\x09send: 'update:'\x0a\x09\x09to: self",
  588. messageSends: ["observeModel", "on:send:to:", "model"],
  589. referencedClasses: ["MKModelChanged"]
  590. }),
  591. smalltalk.MKAspectView);
  592. smalltalk.addMethod(
  593. smalltalk.method({
  594. selector: "update:",
  595. category: 'updating',
  596. fn: function (anAnnouncement){
  597. var self=this;
  598. return smalltalk.withContext(function($ctx1) {
  599. var $1;
  600. $1=_st(_st(anAnnouncement)._aspect()).__eq(self._aspect());
  601. if(smalltalk.assert($1)){
  602. self._update();
  603. };
  604. return self}, function($ctx1) {$ctx1.fill(self,"update:",{anAnnouncement:anAnnouncement},smalltalk.MKAspectView)})},
  605. args: ["anAnnouncement"],
  606. source: "update: anAnnouncement\x0a\x09anAnnouncement aspect = self aspect\x0a\x09\x09ifTrue: [ self update ]",
  607. messageSends: ["ifTrue:", "update", "=", "aspect"],
  608. referencedClasses: []
  609. }),
  610. smalltalk.MKAspectView);
  611. smalltalk.addMethod(
  612. smalltalk.method({
  613. selector: "model:aspect:",
  614. category: 'instance creation',
  615. fn: function (aModel,aSelector){
  616. var self=this;
  617. return smalltalk.withContext(function($ctx1) {
  618. var $2,$3,$1;
  619. $2=self._model_(aModel);
  620. _st($2)._aspect_(aSelector);
  621. $3=_st($2)._yourself();
  622. $1=$3;
  623. return $1;
  624. }, function($ctx1) {$ctx1.fill(self,"model:aspect:",{aModel:aModel,aSelector:aSelector},smalltalk.MKAspectView.klass)})},
  625. args: ["aModel", "aSelector"],
  626. source: "model: aModel aspect: aSelector\x0a\x09^ (self model: aModel)\x0a\x09\x09aspect: aSelector;\x0a\x09\x09yourself",
  627. messageSends: ["aspect:", "model:", "yourself"],
  628. referencedClasses: []
  629. }),
  630. smalltalk.MKAspectView.klass);
  631. })(global_smalltalk,global_nil,global__st);