Moka-Decorators.js 32 KB

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