Moka-Decorators.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860
  1. define("amber_core/Moka-Decorators", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_vm/globals", "amber_core/Moka-Core"], function(smalltalk,nil,_st, globals){
  2. smalltalk.addPackage('Moka-Decorators');
  3. smalltalk.packages["Moka-Decorators"].transport = {"type":"amd","amdNamespace":"amber_core"};
  4. smalltalk.addClass('MKDraggableDecorator', globals.MKDecorator, [], 'Moka-Decorators');
  5. smalltalk.addClass('MKDroppableDecorator', globals.MKDecorator, ['droppableOptions'], 'Moka-Decorators');
  6. smalltalk.addMethod(
  7. smalltalk.method({
  8. selector: "defaultDroppableOptions",
  9. protocol: 'defaults',
  10. fn: function (){
  11. var self=this;
  12. return smalltalk.withContext(function($ctx1) {
  13. var $1;
  14. $1=["helper".__minus_gt("clone")];
  15. return $1;
  16. }, function($ctx1) {$ctx1.fill(self,"defaultDroppableOptions",{},globals.MKDroppableDecorator)})},
  17. args: [],
  18. source: "defaultDroppableOptions\x0a\x09^ { 'helper' -> 'clone' }",
  19. messageSends: ["->"],
  20. referencedClasses: []
  21. }),
  22. globals.MKDroppableDecorator);
  23. smalltalk.addMethod(
  24. smalltalk.method({
  25. selector: "droppableOptions",
  26. protocol: 'accessing',
  27. fn: function (){
  28. var self=this;
  29. return smalltalk.withContext(function($ctx1) {
  30. var $2,$1;
  31. $2=self["@droppableOptions"];
  32. if(($receiver = $2) == nil || $receiver == null){
  33. $1=self._defaultDroppableOptions();
  34. } else {
  35. $1=$2;
  36. };
  37. return $1;
  38. }, function($ctx1) {$ctx1.fill(self,"droppableOptions",{},globals.MKDroppableDecorator)})},
  39. args: [],
  40. source: "droppableOptions\x0a\x09^ droppableOptions ifNil: [ self defaultDroppableOptions ]",
  41. messageSends: ["ifNil:", "defaultDroppableOptions"],
  42. referencedClasses: []
  43. }),
  44. globals.MKDroppableDecorator);
  45. smalltalk.addMethod(
  46. smalltalk.method({
  47. selector: "droppableOptions:",
  48. protocol: 'accessing',
  49. fn: function (aHashedCollection){
  50. var self=this;
  51. self["@droppableOptions"]=aHashedCollection;
  52. return self},
  53. args: ["aHashedCollection"],
  54. source: "droppableOptions: aHashedCollection\x0a\x09droppableOptions := aHashedCollection",
  55. messageSends: [],
  56. referencedClasses: []
  57. }),
  58. globals.MKDroppableDecorator);
  59. smalltalk.addMethod(
  60. smalltalk.method({
  61. selector: "renderContentOn:",
  62. protocol: 'rendering',
  63. fn: function (html){
  64. var self=this;
  65. return smalltalk.withContext(function($ctx1) {
  66. globals.MKDroppableDecorator.superclass.fn.prototype._renderContentOn_.apply(_st(self), [html]);
  67. _st(_st(self._decorated())._asJQuery())._droppable_(self._droppableOptions());
  68. return self}, function($ctx1) {$ctx1.fill(self,"renderContentOn:",{html:html},globals.MKDroppableDecorator)})},
  69. args: ["html"],
  70. source: "renderContentOn: html\x0a\x09super renderContentOn: html.\x0a\x09self decorated asJQuery droppable: self droppableOptions",
  71. messageSends: ["renderContentOn:", "droppable:", "asJQuery", "decorated", "droppableOptions"],
  72. referencedClasses: []
  73. }),
  74. globals.MKDroppableDecorator);
  75. smalltalk.addClass('MKModalDecorator', globals.MKDecorator, ['overlay', 'closeOnEnter', 'closeOnClick'], 'Moka-Decorators');
  76. globals.MKModalDecorator.comment="I render my `decorated` view as a modal pane.";
  77. smalltalk.addMethod(
  78. smalltalk.method({
  79. selector: "closeOnClick",
  80. protocol: 'accessing',
  81. fn: function (){
  82. var self=this;
  83. return smalltalk.withContext(function($ctx1) {
  84. var $2,$1;
  85. $2=self["@closeOnClick"];
  86. if(($receiver = $2) == nil || $receiver == null){
  87. $1=false;
  88. } else {
  89. $1=$2;
  90. };
  91. return $1;
  92. }, function($ctx1) {$ctx1.fill(self,"closeOnClick",{},globals.MKModalDecorator)})},
  93. args: [],
  94. source: "closeOnClick\x0a\x09^ closeOnClick ifNil: [ false ]",
  95. messageSends: ["ifNil:"],
  96. referencedClasses: []
  97. }),
  98. globals.MKModalDecorator);
  99. smalltalk.addMethod(
  100. smalltalk.method({
  101. selector: "closeOnClick:",
  102. protocol: 'accessing',
  103. fn: function (aBoolean){
  104. var self=this;
  105. self["@closeOnClick"]=aBoolean;
  106. return self},
  107. args: ["aBoolean"],
  108. source: "closeOnClick: aBoolean\x0a\x09closeOnClick := aBoolean",
  109. messageSends: [],
  110. referencedClasses: []
  111. }),
  112. globals.MKModalDecorator);
  113. smalltalk.addMethod(
  114. smalltalk.method({
  115. selector: "closeOnEnter",
  116. protocol: 'accessing',
  117. fn: function (){
  118. var self=this;
  119. return smalltalk.withContext(function($ctx1) {
  120. var $2,$1;
  121. $2=self["@closeOnEnter"];
  122. if(($receiver = $2) == nil || $receiver == null){
  123. $1=false;
  124. } else {
  125. $1=$2;
  126. };
  127. return $1;
  128. }, function($ctx1) {$ctx1.fill(self,"closeOnEnter",{},globals.MKModalDecorator)})},
  129. args: [],
  130. source: "closeOnEnter\x0a\x09^ closeOnEnter ifNil: [ false ]",
  131. messageSends: ["ifNil:"],
  132. referencedClasses: []
  133. }),
  134. globals.MKModalDecorator);
  135. smalltalk.addMethod(
  136. smalltalk.method({
  137. selector: "closeOnEnter:",
  138. protocol: 'accessing',
  139. fn: function (aBoolean){
  140. var self=this;
  141. self["@closeOnEnter"]=aBoolean;
  142. return self},
  143. args: ["aBoolean"],
  144. source: "closeOnEnter: aBoolean\x0a\x09closeOnEnter := aBoolean",
  145. messageSends: [],
  146. referencedClasses: []
  147. }),
  148. globals.MKModalDecorator);
  149. smalltalk.addMethod(
  150. smalltalk.method({
  151. selector: "cssClass",
  152. protocol: 'accessing',
  153. fn: function (){
  154. var self=this;
  155. return smalltalk.withContext(function($ctx1) {
  156. var $1;
  157. $1=_st(globals.MKModalDecorator.superclass.fn.prototype._cssClass.apply(_st(self), [])).__comma(" mk_modal");
  158. return $1;
  159. }, function($ctx1) {$ctx1.fill(self,"cssClass",{},globals.MKModalDecorator)})},
  160. args: [],
  161. source: "cssClass\x0a\x09^ super cssClass, ' mk_modal'",
  162. messageSends: [",", "cssClass"],
  163. referencedClasses: []
  164. }),
  165. globals.MKModalDecorator);
  166. smalltalk.addMethod(
  167. smalltalk.method({
  168. selector: "defaultControllerClass",
  169. protocol: 'defaults',
  170. fn: function (){
  171. var self=this;
  172. function $MKModalController(){return globals.MKModalController||(typeof MKModalController=="undefined"?nil:MKModalController)}
  173. return $MKModalController();
  174. },
  175. args: [],
  176. source: "defaultControllerClass\x0a\x09^ MKModalController",
  177. messageSends: [],
  178. referencedClasses: ["MKModalController"]
  179. }),
  180. globals.MKModalDecorator);
  181. smalltalk.addMethod(
  182. smalltalk.method({
  183. selector: "defaultLayout",
  184. protocol: 'defaults',
  185. fn: function (){
  186. var self=this;
  187. return smalltalk.withContext(function($ctx1) {
  188. var $2,$3,$1;
  189. $2=globals.MKModalDecorator.superclass.fn.prototype._defaultLayout.apply(_st(self), []);
  190. _st($2)._centerY_((0));
  191. _st($2)._centerX_((0));
  192. $3=_st($2)._yourself();
  193. $1=$3;
  194. return $1;
  195. }, function($ctx1) {$ctx1.fill(self,"defaultLayout",{},globals.MKModalDecorator)})},
  196. args: [],
  197. source: "defaultLayout\x0a\x09^ super defaultLayout\x0a\x09\x09centerY: 0;\x0a\x09\x09centerX: 0;\x22\x0a\x09\x09width: 300;\x0a\x09\x09height: 200;\x22\x0a\x09\x09yourself",
  198. messageSends: ["centerY:", "defaultLayout", "centerX:", "yourself"],
  199. referencedClasses: []
  200. }),
  201. globals.MKModalDecorator);
  202. smalltalk.addMethod(
  203. smalltalk.method({
  204. selector: "overlay",
  205. protocol: 'accessing',
  206. fn: function (){
  207. var self=this;
  208. function $MKOverlayView(){return globals.MKOverlayView||(typeof MKOverlayView=="undefined"?nil:MKOverlayView)}
  209. return smalltalk.withContext(function($ctx1) {
  210. var $2,$1;
  211. $2=self["@overlay"];
  212. if(($receiver = $2) == nil || $receiver == null){
  213. self["@overlay"]=_st($MKOverlayView())._childView_(self);
  214. $1=self["@overlay"];
  215. } else {
  216. $1=$2;
  217. };
  218. return $1;
  219. }, function($ctx1) {$ctx1.fill(self,"overlay",{},globals.MKModalDecorator)})},
  220. args: [],
  221. source: "overlay\x0a\x09^ overlay ifNil: [ overlay := MKOverlayView childView: self ]",
  222. messageSends: ["ifNil:", "childView:"],
  223. referencedClasses: ["MKOverlayView"]
  224. }),
  225. globals.MKModalDecorator);
  226. smalltalk.addMethod(
  227. smalltalk.method({
  228. selector: "renderOn:",
  229. protocol: 'rendering',
  230. fn: function (html){
  231. var self=this;
  232. return smalltalk.withContext(function($ctx1) {
  233. globals.MKModalDecorator.superclass.fn.prototype._renderOn_.apply(_st(self), [html]);
  234. _st(self["@root"])._at_put_("tabindex","0");
  235. _st(_st(self["@root"])._asJQuery())._focus();
  236. _st(html)._with_(self._overlay());
  237. return self}, function($ctx1) {$ctx1.fill(self,"renderOn:",{html:html},globals.MKModalDecorator)})},
  238. args: ["html"],
  239. source: "renderOn: html\x0a\x09super renderOn: html.\x0a\x09root at: 'tabindex' put: '0'.\x0a\x09root asJQuery focus.\x0a\x09html with: self overlay",
  240. messageSends: ["renderOn:", "at:put:", "focus", "asJQuery", "with:", "overlay"],
  241. referencedClasses: []
  242. }),
  243. globals.MKModalDecorator);
  244. smalltalk.addMethod(
  245. smalltalk.method({
  246. selector: "zindex",
  247. protocol: 'accessing',
  248. fn: function (){
  249. var self=this;
  250. return (1001);
  251. },
  252. args: [],
  253. source: "zindex\x0a\x09^ 1001",
  254. messageSends: [],
  255. referencedClasses: []
  256. }),
  257. globals.MKModalDecorator);
  258. smalltalk.addClass('MKScrollDecorator', globals.MKDecorator, ['verticalScrollbar', 'horizontalScrollbar'], 'Moka-Decorators');
  259. globals.MKScrollDecorator.comment="I decorate a view adding scrollbars around it.\x0a\x0aThe `decorated` view can send `MKViewScrolled` announcement to update the scrollbars position.";
  260. smalltalk.addMethod(
  261. smalltalk.method({
  262. selector: "cssClass",
  263. protocol: 'accessing',
  264. fn: function (){
  265. var self=this;
  266. return smalltalk.withContext(function($ctx1) {
  267. var $1;
  268. $1=_st(globals.MKScrollDecorator.superclass.fn.prototype._cssClass.apply(_st(self), [])).__comma(" mk_scroll");
  269. return $1;
  270. }, function($ctx1) {$ctx1.fill(self,"cssClass",{},globals.MKScrollDecorator)})},
  271. args: [],
  272. source: "cssClass\x0a\x09^ super cssClass, ' mk_scroll'",
  273. messageSends: [",", "cssClass"],
  274. referencedClasses: []
  275. }),
  276. globals.MKScrollDecorator);
  277. smalltalk.addMethod(
  278. smalltalk.method({
  279. selector: "defaultControllerClass",
  280. protocol: 'defaults',
  281. fn: function (){
  282. var self=this;
  283. function $MKScrollController(){return globals.MKScrollController||(typeof MKScrollController=="undefined"?nil:MKScrollController)}
  284. return $MKScrollController();
  285. },
  286. args: [],
  287. source: "defaultControllerClass\x0a\x09^ MKScrollController",
  288. messageSends: [],
  289. referencedClasses: ["MKScrollController"]
  290. }),
  291. globals.MKScrollDecorator);
  292. smalltalk.addMethod(
  293. smalltalk.method({
  294. selector: "domDecoratedSize",
  295. protocol: 'dom',
  296. fn: function (){
  297. var self=this;
  298. var element;
  299. return smalltalk.withContext(function($ctx1) {
  300. var $1;
  301. element=_st(_st(self._decorated())._asJQuery())._get_((0));
  302. $1=_st(_st(element)._scrollWidth()).__at(_st(element)._scrollHeight());
  303. return $1;
  304. }, function($ctx1) {$ctx1.fill(self,"domDecoratedSize",{element:element},globals.MKScrollDecorator)})},
  305. args: [],
  306. source: "domDecoratedSize\x0a\x09| element |\x0a\x09element := self decorated asJQuery get: 0.\x0a\x09^ element scrollWidth @ element scrollHeight",
  307. messageSends: ["get:", "asJQuery", "decorated", "@", "scrollWidth", "scrollHeight"],
  308. referencedClasses: []
  309. }),
  310. globals.MKScrollDecorator);
  311. smalltalk.addMethod(
  312. smalltalk.method({
  313. selector: "domOverflow",
  314. protocol: 'dom',
  315. fn: function (){
  316. var self=this;
  317. var element;
  318. return smalltalk.withContext(function($ctx1) {
  319. var $2,$1;
  320. element=_st(_st(self._decorated())._asJQuery())._get_((0));
  321. $2=_st(_st(element)._scrollWidth()).__minus(_st(element)._clientWidth());
  322. $ctx1.sendIdx["-"]=1;
  323. $1=_st($2).__at(_st(_st(element)._scrollHeight()).__minus(_st(element)._clientHeight()));
  324. return $1;
  325. }, function($ctx1) {$ctx1.fill(self,"domOverflow",{element:element},globals.MKScrollDecorator)})},
  326. args: [],
  327. source: "domOverflow\x0a\x09| element |\x0a\x09element := self decorated asJQuery get: 0.\x0a\x09^ (element scrollWidth - element clientWidth) @ (element scrollHeight - element clientHeight)",
  328. messageSends: ["get:", "asJQuery", "decorated", "@", "-", "scrollWidth", "clientWidth", "scrollHeight", "clientHeight"],
  329. referencedClasses: []
  330. }),
  331. globals.MKScrollDecorator);
  332. smalltalk.addMethod(
  333. smalltalk.method({
  334. selector: "domScrollPercent",
  335. protocol: 'dom',
  336. fn: function (){
  337. var self=this;
  338. return smalltalk.withContext(function($ctx1) {
  339. var $1;
  340. $1=_st(self._domScrollbarPosition()).__slash(_st(self._domSize()).__minus(self._domScrollbarSize()));
  341. return $1;
  342. }, function($ctx1) {$ctx1.fill(self,"domScrollPercent",{},globals.MKScrollDecorator)})},
  343. args: [],
  344. source: "domScrollPercent\x0a\x09^ self domScrollbarPosition / (self domSize - self domScrollbarSize)",
  345. messageSends: ["/", "domScrollbarPosition", "-", "domSize", "domScrollbarSize"],
  346. referencedClasses: []
  347. }),
  348. globals.MKScrollDecorator);
  349. smalltalk.addMethod(
  350. smalltalk.method({
  351. selector: "domScrollPosition",
  352. protocol: 'dom',
  353. fn: function (){
  354. var self=this;
  355. return smalltalk.withContext(function($ctx1) {
  356. var $1;
  357. $1=_st(_st(self._domDecoratedSize()).__minus(self._domSize())).__star(self._domScrollPercent());
  358. return $1;
  359. }, function($ctx1) {$ctx1.fill(self,"domScrollPosition",{},globals.MKScrollDecorator)})},
  360. args: [],
  361. source: "domScrollPosition\x0a\x09^ (self domDecoratedSize - self domSize) * self domScrollPercent",
  362. messageSends: ["*", "-", "domDecoratedSize", "domSize", "domScrollPercent"],
  363. referencedClasses: []
  364. }),
  365. globals.MKScrollDecorator);
  366. smalltalk.addMethod(
  367. smalltalk.method({
  368. selector: "domScrollbarPosition",
  369. protocol: 'dom',
  370. fn: function (){
  371. var self=this;
  372. return smalltalk.withContext(function($ctx1) {
  373. var $4,$3,$2,$1;
  374. $4=_st(self["@horizontalScrollbar"])._asJQuery();
  375. $ctx1.sendIdx["asJQuery"]=1;
  376. $3=_st($4)._position();
  377. $ctx1.sendIdx["position"]=1;
  378. $2=_st($3)._left();
  379. $1=_st($2).__at(_st(_st(_st(self["@verticalScrollbar"])._asJQuery())._position())._top());
  380. return $1;
  381. }, function($ctx1) {$ctx1.fill(self,"domScrollbarPosition",{},globals.MKScrollDecorator)})},
  382. args: [],
  383. source: "domScrollbarPosition\x0a\x09^ horizontalScrollbar asJQuery position left @ verticalScrollbar asJQuery position top",
  384. messageSends: ["@", "left", "position", "asJQuery", "top"],
  385. referencedClasses: []
  386. }),
  387. globals.MKScrollDecorator);
  388. smalltalk.addMethod(
  389. smalltalk.method({
  390. selector: "domScrollbarSize",
  391. protocol: 'dom',
  392. fn: function (){
  393. var self=this;
  394. return smalltalk.withContext(function($ctx1) {
  395. var $3,$2,$1;
  396. $3=_st(self["@horizontalScrollbar"])._asJQuery();
  397. $ctx1.sendIdx["asJQuery"]=1;
  398. $2=_st($3)._width();
  399. $1=_st($2).__at(_st(_st(self["@verticalScrollbar"])._asJQuery())._height());
  400. return $1;
  401. }, function($ctx1) {$ctx1.fill(self,"domScrollbarSize",{},globals.MKScrollDecorator)})},
  402. args: [],
  403. source: "domScrollbarSize\x0a\x09^ horizontalScrollbar asJQuery width @ verticalScrollbar asJQuery height",
  404. messageSends: ["@", "width", "asJQuery", "height"],
  405. referencedClasses: []
  406. }),
  407. globals.MKScrollDecorator);
  408. smalltalk.addMethod(
  409. smalltalk.method({
  410. selector: "hasHorizontalOverflow",
  411. protocol: 'testing',
  412. fn: function (){
  413. var self=this;
  414. return smalltalk.withContext(function($ctx1) {
  415. var $1;
  416. $1=_st(_st(self._domOverflow())._x()).__gt((0));
  417. return $1;
  418. }, function($ctx1) {$ctx1.fill(self,"hasHorizontalOverflow",{},globals.MKScrollDecorator)})},
  419. args: [],
  420. source: "hasHorizontalOverflow\x0a\x09^ self domOverflow x > 0",
  421. messageSends: [">", "x", "domOverflow"],
  422. referencedClasses: []
  423. }),
  424. globals.MKScrollDecorator);
  425. smalltalk.addMethod(
  426. smalltalk.method({
  427. selector: "hasVerticalOverflow",
  428. protocol: 'testing',
  429. fn: function (){
  430. var self=this;
  431. return smalltalk.withContext(function($ctx1) {
  432. var $1;
  433. $1=_st(_st(self._domOverflow())._y()).__gt((0));
  434. return $1;
  435. }, function($ctx1) {$ctx1.fill(self,"hasVerticalOverflow",{},globals.MKScrollDecorator)})},
  436. args: [],
  437. source: "hasVerticalOverflow\x0a\x09^ self domOverflow y > 0",
  438. messageSends: [">", "y", "domOverflow"],
  439. referencedClasses: []
  440. }),
  441. globals.MKScrollDecorator);
  442. smalltalk.addMethod(
  443. smalltalk.method({
  444. selector: "horizontalScrollbar",
  445. protocol: 'accessing',
  446. fn: function (){
  447. var self=this;
  448. var $1;
  449. $1=self["@horizontalScrollbar"];
  450. return $1;
  451. },
  452. args: [],
  453. source: "horizontalScrollbar\x0a\x09^ horizontalScrollbar",
  454. messageSends: [],
  455. referencedClasses: []
  456. }),
  457. globals.MKScrollDecorator);
  458. smalltalk.addMethod(
  459. smalltalk.method({
  460. selector: "observeDecorated",
  461. protocol: 'observing',
  462. fn: function (){
  463. var self=this;
  464. function $MKViewScroll(){return globals.MKViewScroll||(typeof MKViewScroll=="undefined"?nil:MKViewScroll)}
  465. return smalltalk.withContext(function($ctx1) {
  466. _st(self._decorated())._on_send_to_($MKViewScroll(),"onDecoratedScroll",self._controller());
  467. return self}, function($ctx1) {$ctx1.fill(self,"observeDecorated",{},globals.MKScrollDecorator)})},
  468. args: [],
  469. source: "observeDecorated\x0a\x09self decorated \x0a\x09\x09on: MKViewScroll \x0a\x09\x09send: #onDecoratedScroll\x0a\x09\x09to: self controller",
  470. messageSends: ["on:send:to:", "decorated", "controller"],
  471. referencedClasses: ["MKViewScroll"]
  472. }),
  473. globals.MKScrollDecorator);
  474. smalltalk.addMethod(
  475. smalltalk.method({
  476. selector: "renderContentOn:",
  477. protocol: 'rendering',
  478. fn: function (html){
  479. var self=this;
  480. return smalltalk.withContext(function($ctx1) {
  481. var $1,$2,$3,$5,$6,$4,$7,$9,$10,$8;
  482. $1=_st(html)._div();
  483. $ctx1.sendIdx["div"]=1;
  484. _st($1)._class_("mk_scroll_container");
  485. $ctx1.sendIdx["class:"]=1;
  486. $2=_st($1)._with_((function(){
  487. return smalltalk.withContext(function($ctx2) {
  488. return globals.MKScrollDecorator.superclass.fn.prototype._renderContentOn_.apply(_st(self), [html]);
  489. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  490. $ctx1.sendIdx["with:"]=1;
  491. $3=_st(html)._div();
  492. $ctx1.sendIdx["div"]=2;
  493. _st($3)._class_("mk_scroll_rail vertical");
  494. $ctx1.sendIdx["class:"]=2;
  495. $4=_st($3)._with_((function(){
  496. return smalltalk.withContext(function($ctx2) {
  497. $5=_st(html)._div();
  498. $ctx2.sendIdx["div"]=3;
  499. _st($5)._class_("mk_scrollbar");
  500. $ctx2.sendIdx["class:"]=3;
  501. $6=_st($5)._yourself();
  502. $ctx2.sendIdx["yourself"]=1;
  503. self["@verticalScrollbar"]=$6;
  504. return self["@verticalScrollbar"];
  505. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  506. $ctx1.sendIdx["with:"]=2;
  507. $7=_st(html)._div();
  508. $ctx1.sendIdx["div"]=4;
  509. _st($7)._class_("mk_scroll_rail horizontal");
  510. $ctx1.sendIdx["class:"]=4;
  511. $8=_st($7)._with_((function(){
  512. return smalltalk.withContext(function($ctx2) {
  513. $9=_st(html)._div();
  514. _st($9)._class_("mk_scrollbar");
  515. $10=_st($9)._yourself();
  516. self["@horizontalScrollbar"]=$10;
  517. return self["@horizontalScrollbar"];
  518. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}));
  519. self._setupScrollbars();
  520. return self}, function($ctx1) {$ctx1.fill(self,"renderContentOn:",{html:html},globals.MKScrollDecorator)})},
  521. args: ["html"],
  522. source: "renderContentOn: html\x0a\x09html div \x0a\x09\x09class: 'mk_scroll_container';\x0a\x09\x09with: [ super renderContentOn: html ].\x0a\x09\x0a\x09html div \x0a\x09\x09class: 'mk_scroll_rail vertical';\x0a\x09\x09with: [\x0a\x09\x09\x09verticalScrollbar := html div\x0a\x09\x09\x09\x09class: 'mk_scrollbar';\x0a\x09\x09\x09\x09yourself ].\x0a\x09html div \x0a\x09\x09class: 'mk_scroll_rail horizontal';\x0a\x09\x09with: [\x0a\x09\x09\x09horizontalScrollbar := html div\x0a\x09\x09\x09\x09class: 'mk_scrollbar';\x0a\x09\x09\x09\x09yourself ].\x0a\x09\x0a\x09self setupScrollbars",
  523. messageSends: ["class:", "div", "with:", "renderContentOn:", "yourself", "setupScrollbars"],
  524. referencedClasses: []
  525. }),
  526. globals.MKScrollDecorator);
  527. smalltalk.addMethod(
  528. smalltalk.method({
  529. selector: "resized",
  530. protocol: 'actions',
  531. fn: function (){
  532. var self=this;
  533. return smalltalk.withContext(function($ctx1) {
  534. globals.MKScrollDecorator.superclass.fn.prototype._resized.apply(_st(self), []);
  535. self._updateScrollbars();
  536. return self}, function($ctx1) {$ctx1.fill(self,"resized",{},globals.MKScrollDecorator)})},
  537. args: [],
  538. source: "resized\x0a\x09super resized.\x0a\x09self updateScrollbars",
  539. messageSends: ["resized", "updateScrollbars"],
  540. referencedClasses: []
  541. }),
  542. globals.MKScrollDecorator);
  543. smalltalk.addMethod(
  544. smalltalk.method({
  545. selector: "scrollDeltaX:",
  546. protocol: 'actions',
  547. fn: function (aNumber){
  548. var self=this;
  549. var scrollbar,left,maxLeft;
  550. return smalltalk.withContext(function($ctx1) {
  551. var $1;
  552. scrollbar=_st(self._horizontalScrollbar())._asJQuery();
  553. $ctx1.sendIdx["asJQuery"]=1;
  554. $1=_st(self._domSize())._x();
  555. $ctx1.sendIdx["x"]=1;
  556. maxLeft=_st($1).__minus(_st(scrollbar)._width());
  557. left=_st(_st(_st(_st(_st(scrollbar)._position())._left()).__plus(aNumber))._max_((0)))._min_(maxLeft);
  558. _st(scrollbar)._css_put_("left",left);
  559. _st(_st(_st(self._decorated())._asJQuery())._get_((0)))._at_put_("scrollLeft",_st(self._domScrollPosition())._x());
  560. return self}, function($ctx1) {$ctx1.fill(self,"scrollDeltaX:",{aNumber:aNumber,scrollbar:scrollbar,left:left,maxLeft:maxLeft},globals.MKScrollDecorator)})},
  561. args: ["aNumber"],
  562. source: "scrollDeltaX: aNumber\x0a\x09| scrollbar left maxLeft |\x0a\x09scrollbar := self horizontalScrollbar asJQuery.\x0a\x09maxLeft := self domSize x - scrollbar width.\x0a\x09left := ((scrollbar position left + aNumber) max: 0) min: maxLeft.\x0a\x09scrollbar css: 'left' put: left.\x0a\x09(self decorated asJQuery get: 0) at: 'scrollLeft' put: self domScrollPosition x",
  563. messageSends: ["asJQuery", "horizontalScrollbar", "-", "x", "domSize", "width", "min:", "max:", "+", "left", "position", "css:put:", "at:put:", "get:", "decorated", "domScrollPosition"],
  564. referencedClasses: []
  565. }),
  566. globals.MKScrollDecorator);
  567. smalltalk.addMethod(
  568. smalltalk.method({
  569. selector: "scrollDeltaY:",
  570. protocol: 'actions',
  571. fn: function (aNumber){
  572. var self=this;
  573. var scrollbar,top,maxTop;
  574. return smalltalk.withContext(function($ctx1) {
  575. var $1;
  576. scrollbar=_st(self._verticalScrollbar())._asJQuery();
  577. $ctx1.sendIdx["asJQuery"]=1;
  578. $1=_st(self._domSize())._y();
  579. $ctx1.sendIdx["y"]=1;
  580. maxTop=_st($1).__minus(_st(scrollbar)._height());
  581. $ctx1.sendIdx["-"]=1;
  582. top=_st(_st(_st(_st(_st(scrollbar)._position())._top()).__minus(aNumber))._max_((0)))._min_(maxTop);
  583. _st(scrollbar)._css_put_("top",top);
  584. _st(_st(_st(self._decorated())._asJQuery())._get_((0)))._at_put_("scrollTop",_st(self._domScrollPosition())._y());
  585. return self}, function($ctx1) {$ctx1.fill(self,"scrollDeltaY:",{aNumber:aNumber,scrollbar:scrollbar,top:top,maxTop:maxTop},globals.MKScrollDecorator)})},
  586. args: ["aNumber"],
  587. source: "scrollDeltaY: aNumber\x0a\x09| scrollbar top maxTop |\x0a\x09scrollbar := self verticalScrollbar asJQuery.\x0a\x09maxTop := self domSize y - scrollbar height.\x0a\x09top := ((scrollbar position top - aNumber) max: 0) min: maxTop.\x0a\x09scrollbar css: 'top' put: top.\x0a\x09(self decorated asJQuery get: 0) at: 'scrollTop' put: self domScrollPosition y",
  588. messageSends: ["asJQuery", "verticalScrollbar", "-", "y", "domSize", "height", "min:", "max:", "top", "position", "css:put:", "at:put:", "get:", "decorated", "domScrollPosition"],
  589. referencedClasses: []
  590. }),
  591. globals.MKScrollDecorator);
  592. smalltalk.addMethod(
  593. smalltalk.method({
  594. selector: "scrollPercent",
  595. protocol: 'accessing',
  596. fn: function (){
  597. var self=this;
  598. var element;
  599. return smalltalk.withContext(function($ctx1) {
  600. var $2,$1;
  601. element=_st(_st(self._decorated())._asJQuery())._get_((0));
  602. $2=_st(_st(element)._scrollLeft()).__slash(_st(element)._scrollWidth());
  603. $ctx1.sendIdx["/"]=1;
  604. $1=_st($2).__at(_st(_st(element)._scrollTop()).__slash(_st(element)._scrollHeight()));
  605. return $1;
  606. }, function($ctx1) {$ctx1.fill(self,"scrollPercent",{element:element},globals.MKScrollDecorator)})},
  607. args: [],
  608. source: "scrollPercent\x0a\x09| element |\x0a\x09element := self decorated asJQuery get: 0.\x0a\x09^ (element scrollLeft / element scrollWidth) @ (element scrollTop / element scrollHeight)",
  609. messageSends: ["get:", "asJQuery", "decorated", "@", "/", "scrollLeft", "scrollWidth", "scrollTop", "scrollHeight"],
  610. referencedClasses: []
  611. }),
  612. globals.MKScrollDecorator);
  613. smalltalk.addMethod(
  614. smalltalk.method({
  615. selector: "scrollbarPosition",
  616. protocol: 'accessing',
  617. fn: function (){
  618. var self=this;
  619. var position;
  620. return smalltalk.withContext(function($ctx1) {
  621. var $2,$1;
  622. position=_st(self._scrollPercent()).__star(_st(self._domSize()).__minus(self._domScrollbarSize()));
  623. $2=_st(_st(position)._x())._rounded();
  624. $ctx1.sendIdx["rounded"]=1;
  625. $1=_st($2).__at(_st(_st(position)._y())._rounded());
  626. return $1;
  627. }, function($ctx1) {$ctx1.fill(self,"scrollbarPosition",{position:position},globals.MKScrollDecorator)})},
  628. args: [],
  629. source: "scrollbarPosition\x0a\x09| position |\x0a\x09position := self scrollPercent * (self domSize - self domScrollbarSize).\x0a\x09^ position x rounded @ position y rounded",
  630. messageSends: ["*", "scrollPercent", "-", "domSize", "domScrollbarSize", "@", "rounded", "x", "y"],
  631. referencedClasses: []
  632. }),
  633. globals.MKScrollDecorator);
  634. smalltalk.addMethod(
  635. smalltalk.method({
  636. selector: "scrollbarSize",
  637. protocol: 'accessing',
  638. fn: function (){
  639. var self=this;
  640. var domSize,overflow;
  641. return smalltalk.withContext(function($ctx1) {
  642. var $4,$6,$5,$3,$2,$9,$11,$10,$8,$7,$1;
  643. domSize=self._domSize();
  644. overflow=self._domOverflow();
  645. $4=_st(domSize)._x();
  646. $ctx1.sendIdx["x"]=1;
  647. $6=_st(overflow)._x();
  648. $ctx1.sendIdx["x"]=2;
  649. $5=_st($6).__plus(_st(domSize)._x());
  650. $ctx1.sendIdx["+"]=1;
  651. $3=_st($4).__slash($5);
  652. $ctx1.sendIdx["/"]=1;
  653. $2=_st($3).__star((100));
  654. $ctx1.sendIdx["*"]=1;
  655. $9=_st(domSize)._y();
  656. $ctx1.sendIdx["y"]=1;
  657. $11=_st(overflow)._y();
  658. $ctx1.sendIdx["y"]=2;
  659. $10=_st($11).__plus(_st(domSize)._y());
  660. $8=_st($9).__slash($10);
  661. $7=_st($8).__star((100));
  662. $1=_st($2).__at($7);
  663. return $1;
  664. }, function($ctx1) {$ctx1.fill(self,"scrollbarSize",{domSize:domSize,overflow:overflow},globals.MKScrollDecorator)})},
  665. args: [],
  666. source: "scrollbarSize\x0a\x09| domSize overflow |\x0a\x09\x0a\x09domSize := self domSize.\x0a\x09overflow := self domOverflow.\x0a\x09^ ((domSize x / (overflow x + domSize x)) * 100) @ ((domSize y / (overflow y + domSize y) * 100))",
  667. messageSends: ["domSize", "domOverflow", "@", "*", "/", "x", "+", "y"],
  668. referencedClasses: []
  669. }),
  670. globals.MKScrollDecorator);
  671. smalltalk.addMethod(
  672. smalltalk.method({
  673. selector: "setupEventHandlers",
  674. protocol: 'private',
  675. fn: function (){
  676. var self=this;
  677. return smalltalk.withContext(function($ctx1) {
  678. globals.MKScrollDecorator.superclass.fn.prototype._setupEventHandlers.apply(_st(self), []);
  679. _st(_st(self["@root"])._asJQuery())._mousewheel_((function(event){
  680. return smalltalk.withContext(function($ctx2) {
  681. return _st(self._controller())._onMousewheel_(event);
  682. }, function($ctx2) {$ctx2.fillBlock({event:event},$ctx1,1)})}));
  683. _st(_st(jQuery)._value_(window))._resize_((function(event){
  684. return smalltalk.withContext(function($ctx2) {
  685. return self._resized();
  686. }, function($ctx2) {$ctx2.fillBlock({event:event},$ctx1,2)})}));
  687. return self}, function($ctx1) {$ctx1.fill(self,"setupEventHandlers",{},globals.MKScrollDecorator)})},
  688. args: [],
  689. source: "setupEventHandlers\x0a\x09super setupEventHandlers.\x0a\x09\x0a\x09root asJQuery mousewheel: [ :event | \x0a\x09\x09self controller onMousewheel: event ].\x0a\x09\x09\x0a\x09(jQuery value: window) resize: [ :event | \x0a\x09\x09self resized ]",
  690. messageSends: ["setupEventHandlers", "mousewheel:", "asJQuery", "onMousewheel:", "controller", "resize:", "value:", "resized"],
  691. referencedClasses: []
  692. }),
  693. globals.MKScrollDecorator);
  694. smalltalk.addMethod(
  695. smalltalk.method({
  696. selector: "setupScrollbars",
  697. protocol: 'private',
  698. fn: function (){
  699. var self=this;
  700. return smalltalk.withContext(function($ctx1) {
  701. var $1,$3,$4,$6,$5,$2,$7,$9,$10,$8;
  702. $1=_st(self["@verticalScrollbar"])._asJQuery();
  703. $ctx1.sendIdx["asJQuery"]=1;
  704. $3="containment".__minus_gt("parent");
  705. $ctx1.sendIdx["->"]=1;
  706. $4="axis".__minus_gt("y");
  707. $ctx1.sendIdx["->"]=2;
  708. $5="drag".__minus_gt((function(event){
  709. return smalltalk.withContext(function($ctx2) {
  710. $6=self._controller();
  711. $ctx2.sendIdx["controller"]=1;
  712. return _st($6)._onVerticalDrag_(event);
  713. }, function($ctx2) {$ctx2.fillBlock({event:event},$ctx1,1)})}));
  714. $ctx1.sendIdx["->"]=3;
  715. $2=globals.HashedCollection._from_([$3,$4,$5]);
  716. _st($1)._draggable_($2);
  717. $ctx1.sendIdx["draggable:"]=1;
  718. $7=_st(self["@horizontalScrollbar"])._asJQuery();
  719. $9="containment".__minus_gt("parent");
  720. $ctx1.sendIdx["->"]=4;
  721. $10="axis".__minus_gt("x");
  722. $ctx1.sendIdx["->"]=5;
  723. $8=globals.HashedCollection._from_([$9,$10,"drag".__minus_gt((function(event){
  724. return smalltalk.withContext(function($ctx2) {
  725. return _st(self._controller())._onHorizontalDrag_(event);
  726. }, function($ctx2) {$ctx2.fillBlock({event:event},$ctx1,2)})}))]);
  727. _st($7)._draggable_($8);
  728. self._updateScrollbars();
  729. return self}, function($ctx1) {$ctx1.fill(self,"setupScrollbars",{},globals.MKScrollDecorator)})},
  730. args: [],
  731. source: "setupScrollbars\x0a\x09verticalScrollbar asJQuery draggable: #{\x0a\x09\x09'containment' -> 'parent'.\x0a\x09\x09'axis' -> 'y'.\x0a\x09\x09'drag' -> [ :event | self controller onVerticalDrag: event ]\x0a\x09}.\x0a\x09horizontalScrollbar asJQuery draggable: #{\x0a\x09\x09'containment' -> 'parent'.\x0a\x09\x09'axis' -> 'x'.\x0a\x09\x09'drag' -> [ :event | self controller onHorizontalDrag: event ]\x0a\x09}.\x0a\x09\x0a\x09self updateScrollbars",
  732. messageSends: ["draggable:", "asJQuery", "->", "onVerticalDrag:", "controller", "onHorizontalDrag:", "updateScrollbars"],
  733. referencedClasses: []
  734. }),
  735. globals.MKScrollDecorator);
  736. smalltalk.addMethod(
  737. smalltalk.method({
  738. selector: "updateScrollbars",
  739. protocol: 'updating',
  740. fn: function (){
  741. var self=this;
  742. var width,height;
  743. return smalltalk.withContext(function($ctx1) {
  744. var $1,$3,$2,$4,$5,$7,$6;
  745. $1=self._hasHorizontalOverflow();
  746. if(smalltalk.assert($1)){
  747. $3=self._scrollbarSize();
  748. $ctx1.sendIdx["scrollbarSize"]=1;
  749. $2=_st($3)._x();
  750. width=_st($2)._max_((10));
  751. $ctx1.sendIdx["max:"]=1;
  752. } else {
  753. width=(0);
  754. };
  755. $4=self._hasVerticalOverflow();
  756. if(smalltalk.assert($4)){
  757. height=_st(_st(self._scrollbarSize())._y())._max_((10));
  758. } else {
  759. height=(0);
  760. };
  761. $5=_st(self["@horizontalScrollbar"])._asJQuery();
  762. $ctx1.sendIdx["asJQuery"]=1;
  763. $7=_st(width)._asString();
  764. $ctx1.sendIdx["asString"]=1;
  765. $6=_st($7).__comma("%");
  766. $ctx1.sendIdx[","]=1;
  767. _st($5)._width_($6);
  768. _st(_st(self["@verticalScrollbar"])._asJQuery())._height_(_st(_st(height)._asString()).__comma("%"));
  769. return self}, function($ctx1) {$ctx1.fill(self,"updateScrollbars",{width:width,height:height},globals.MKScrollDecorator)})},
  770. args: [],
  771. source: "updateScrollbars\x0a\x09| width height |\x0a\x09\x0a\x09width := self hasHorizontalOverflow\x0a\x09\x09ifTrue: [ self scrollbarSize x max: 10 ]\x0a\x09\x09ifFalse: [ 0 ].\x0a\x09height := self hasVerticalOverflow\x0a\x09\x09ifTrue: [ self scrollbarSize y max: 10 ]\x0a\x09\x09ifFalse: [ 0 ].\x0a\x09\x0a\x09horizontalScrollbar asJQuery \x0a\x09\x09width: width asString, '%'.\x0a\x09verticalScrollbar asJQuery \x0a\x09\x09height: height asString, '%'",
  772. messageSends: ["ifTrue:ifFalse:", "hasHorizontalOverflow", "max:", "x", "scrollbarSize", "hasVerticalOverflow", "y", "width:", "asJQuery", ",", "asString", "height:"],
  773. referencedClasses: []
  774. }),
  775. globals.MKScrollDecorator);
  776. smalltalk.addMethod(
  777. smalltalk.method({
  778. selector: "updateScrollbarsPosition",
  779. protocol: 'updating',
  780. fn: function (){
  781. var self=this;
  782. var position;
  783. return smalltalk.withContext(function($ctx1) {
  784. var $1;
  785. position=self._scrollbarPosition();
  786. $1=_st(self["@horizontalScrollbar"])._asJQuery();
  787. $ctx1.sendIdx["asJQuery"]=1;
  788. _st($1)._css_put_("left",_st(position)._x());
  789. $ctx1.sendIdx["css:put:"]=1;
  790. _st(_st(self["@verticalScrollbar"])._asJQuery())._css_put_("top",_st(position)._y());
  791. return self}, function($ctx1) {$ctx1.fill(self,"updateScrollbarsPosition",{position:position},globals.MKScrollDecorator)})},
  792. args: [],
  793. source: "updateScrollbarsPosition\x0a\x09| position |\x0a\x09position := self scrollbarPosition.\x0a\x09horizontalScrollbar asJQuery\x0a\x09\x09css: 'left' put: position x.\x0a\x09verticalScrollbar asJQuery\x0a\x09\x09css: 'top' put: position y",
  794. messageSends: ["scrollbarPosition", "css:put:", "asJQuery", "x", "y"],
  795. referencedClasses: []
  796. }),
  797. globals.MKScrollDecorator);
  798. smalltalk.addMethod(
  799. smalltalk.method({
  800. selector: "verticalScrollbar",
  801. protocol: 'accessing',
  802. fn: function (){
  803. var self=this;
  804. var $1;
  805. $1=self["@verticalScrollbar"];
  806. return $1;
  807. },
  808. args: [],
  809. source: "verticalScrollbar\x0a\x09^ verticalScrollbar",
  810. messageSends: [],
  811. referencedClasses: []
  812. }),
  813. globals.MKScrollDecorator);
  814. });