Moka-Views.st 18 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027
  1. Smalltalk createPackage: 'Moka-Views'!
  2. MKSingleAspectView subclass: #MKButtonView
  3. instanceVariableNames: 'default label icon'
  4. package: 'Moka-Views'!
  5. !MKButtonView commentStamp!
  6. I am a push button view. My default controller is `MKButtonController`.
  7. My controller must answer to `#onPressed`.
  8. ## API
  9. - Instances can be set a `default` button
  10. - Use `#label:` to set the label string!
  11. !MKButtonView methodsFor: 'accessing'!
  12. cssClass
  13. ^ String streamContents: [ :stream |
  14. stream << super cssClass << ' mk_button'.
  15. self isDefault
  16. ifTrue: [ stream << ' default' ] ]
  17. !
  18. default
  19. ^ default
  20. !
  21. default: aBoolean
  22. default := aBoolean
  23. !
  24. icon
  25. ^ icon
  26. !
  27. icon: aString
  28. icon := aString
  29. !
  30. label
  31. ^ label ifNil: [ self defaultLabel ]
  32. !
  33. label: aString
  34. label := aString
  35. !
  36. tag
  37. ^ 'button'
  38. ! !
  39. !MKButtonView methodsFor: 'defaults'!
  40. defaultControllerClass
  41. ^ MKButtonController
  42. !
  43. defaultLabel
  44. ^ 'OK'
  45. !
  46. defaultLayout
  47. ^ super defaultLayout
  48. width: 80;
  49. height: 24;
  50. yourself
  51. ! !
  52. !MKButtonView methodsFor: 'rendering'!
  53. renderContentOn: html
  54. self hasIcon ifTrue: [
  55. html img
  56. class: 'mk_icon';
  57. src: self icon ].
  58. html with: self label
  59. ! !
  60. !MKButtonView methodsFor: 'testing'!
  61. hasIcon
  62. ^ self icon notNil
  63. !
  64. isDefault
  65. ^ self default ifNil: [ false ]
  66. ! !
  67. MKSingleAspectView subclass: #MKCheckboxView
  68. instanceVariableNames: 'id'
  69. package: 'Moka-Views'!
  70. !MKCheckboxView commentStamp!
  71. I am a checkbox view. My default controller is `MKCheckboxController`.
  72. My controller must answer to `#onToggled:`.
  73. ##API
  74. - If no `aspect` is provided, the ckeckbox state will always be off.
  75. - use `#label:` to set the label string.!
  76. !MKCheckboxView methodsFor: 'accessing'!
  77. checked
  78. ^ self aspectValue ifNil: [ false ]
  79. !
  80. cssClass
  81. ^ super cssClass, ' mk_checkbox'
  82. !
  83. id
  84. ^ id ifNil: [ id := 1000000 atRandom asString ]
  85. ! !
  86. !MKCheckboxView methodsFor: 'defaults'!
  87. defaultControllerClass
  88. ^ MKCheckboxController
  89. !
  90. defaultLayout
  91. ^ super defaultLayout
  92. width: 16;
  93. height: 16;
  94. yourself
  95. ! !
  96. !MKCheckboxView methodsFor: 'events'!
  97. update
  98. self checked
  99. ifTrue: [ root asJQuery addClass: 'checked' ]
  100. ifFalse: [ root asJQuery removeClass: 'checked' ]
  101. ! !
  102. !MKCheckboxView methodsFor: 'rendering'!
  103. renderContentOn: html
  104. self checked ifTrue: [
  105. root asJQuery addClass: 'checked' ].
  106. root at: 'tabindex' put: '0'
  107. ! !
  108. MKCheckboxView subclass: #MKSwitchView
  109. instanceVariableNames: ''
  110. package: 'Moka-Views'!
  111. !MKSwitchView commentStamp!
  112. I am a switch view, similar to a `MKCheckboxView` but displayed as a switch.
  113. My default controller is `MKCheckboxController`.!
  114. !MKSwitchView methodsFor: 'accessing'!
  115. checkboxCssClass
  116. ^ 'mk_switch'
  117. !
  118. cssClass
  119. ^ super cssClass, ' mk_switch'
  120. ! !
  121. !MKSwitchView methodsFor: 'defaults'!
  122. defaultLayout
  123. ^ super defaultLayout
  124. width: 48;
  125. height: 20;
  126. yourself
  127. ! !
  128. MKLayoutView subclass: #MKImageView
  129. instanceVariableNames: 'imagePath alternativeContents'
  130. package: 'Moka-Views'!
  131. !MKImageView commentStamp!
  132. I display an image.
  133. Note that several views support adding icons using either `#icon:` or `#iconBlock:`.
  134. ##API
  135. Create instances using `MKImageView class>>imagePath:`.!
  136. !MKImageView methodsFor: 'accessing'!
  137. alternativeContents
  138. ^ alternativeContents ifNil: [ self imagePath ]
  139. !
  140. alternativeContents: aString
  141. alternativeContents := aString
  142. !
  143. imagePath
  144. ^ imagePath ifNil: [ '' ]
  145. !
  146. imagePath: aString
  147. imagePath := aString
  148. !
  149. tag
  150. ^ 'img'
  151. ! !
  152. !MKImageView methodsFor: 'rendering'!
  153. renderContentOn: html
  154. root
  155. src: self imagePath;
  156. alt: self alternativeContents
  157. ! !
  158. !MKImageView class methodsFor: 'instance creation'!
  159. imagePath: aString
  160. ^ self new
  161. imagePath: aString;
  162. yourself
  163. ! !
  164. MKSingleAspectView subclass: #MKLabelView
  165. instanceVariableNames: ''
  166. package: 'Moka-Views'!
  167. !MKLabelView commentStamp!
  168. I am an label view. I display a `String`.!
  169. !MKLabelView methodsFor: 'accessing'!
  170. cssClass
  171. ^ super cssClass, ' mk_label'
  172. ! !
  173. !MKLabelView methodsFor: 'defaults'!
  174. defaultControllerClass
  175. ^ super defaultControllerClass
  176. !
  177. defaultLayout
  178. ^ MKLabelLayout new
  179. height: 24;
  180. top: 0;
  181. left:0;
  182. right: 0;
  183. textAlign: 'left';
  184. yourself
  185. ! !
  186. !MKLabelView methodsFor: 'layout'!
  187. textAlign: aString
  188. self layout textAlign: aString
  189. ! !
  190. !MKLabelView methodsFor: 'rendering'!
  191. renderContentOn: html
  192. html with: self aspectValue
  193. ! !
  194. MKLabelView subclass: #MKHeadingView
  195. instanceVariableNames: 'level'
  196. package: 'Moka-Views'!
  197. !MKHeadingView commentStamp!
  198. I display a heading, with a `level` from 1 to 6.!
  199. !MKHeadingView methodsFor: 'accessing'!
  200. cssClass
  201. ^ String streamContents: [ :stream |
  202. stream
  203. << super cssClass
  204. << ' mk_heading level'
  205. << self level asString ]
  206. !
  207. level
  208. ^ level ifNil: [ 1 ]
  209. !
  210. level: aNumber
  211. level := aNumber
  212. !
  213. tag
  214. ^ 'h', self level asString
  215. ! !
  216. MKLayoutView subclass: #MKOverlayView
  217. instanceVariableNames: 'childView'
  218. package: 'Moka-Views'!
  219. !MKOverlayView commentStamp!
  220. I display an transparent overlay, typically over other views, except my `childView`.
  221. ## API
  222. Create instances using the class-side `childView:` method.!
  223. !MKOverlayView methodsFor: 'accessing'!
  224. childView
  225. ^ childView
  226. !
  227. childView: aView
  228. childView := aView
  229. !
  230. children
  231. ^ { self childView }
  232. !
  233. cssClass
  234. ^ super cssClass, ' mk_overlay'
  235. ! !
  236. !MKOverlayView methodsFor: 'actions'!
  237. remove
  238. super remove.
  239. self childView remove
  240. ! !
  241. !MKOverlayView methodsFor: 'defaults'!
  242. defaultControllerClass
  243. ^ MKOverlayController
  244. !
  245. renderContentOn: html
  246. "Left empty on purpose.
  247. No Content is rendered, as the childView is actually displayed separately"
  248. ! !
  249. !MKOverlayView class methodsFor: 'instance creation'!
  250. childView: aView
  251. ^ self new
  252. childView: aView;
  253. yourself
  254. ! !
  255. MKLayoutView subclass: #MKPaneView
  256. instanceVariableNames: 'views'
  257. package: 'Moka-Views'!
  258. !MKPaneView commentStamp!
  259. I am a view containing other views.
  260. ## API
  261. Use `#addView:` to add a view to the pane.!
  262. !MKPaneView methodsFor: 'accessing'!
  263. children
  264. ^ self views
  265. !
  266. cssClass
  267. ^ super cssClass, ' mk_pane'
  268. !
  269. views
  270. ^ views ifNil: [ views := OrderedCollection new ]
  271. ! !
  272. !MKPaneView methodsFor: 'adding'!
  273. addView: aView
  274. self views add: aView
  275. ! !
  276. !MKPaneView methodsFor: 'defaults'!
  277. defaultLayout
  278. ^ MKPaneLayout new
  279. left: 0;
  280. top: 0;
  281. right: 0;
  282. bottom: 0;
  283. yourself
  284. ! !
  285. !MKPaneView methodsFor: 'layout'!
  286. borderBottom: aNumber
  287. self layout borderBottom: aNumber
  288. !
  289. borderLeft: aNumber
  290. self layout borderLeft: aNumber
  291. !
  292. borderRight: aNumber
  293. self layout borderRight: aNumber
  294. !
  295. borderTop: aNumber
  296. self layout borderTop: aNumber
  297. ! !
  298. !MKPaneView methodsFor: 'rendering'!
  299. renderContentOn: html
  300. self views do: [ :each |
  301. html with: each ]
  302. ! !
  303. MKPaneView subclass: #MKPanelView
  304. instanceVariableNames: ''
  305. package: 'Moka-Views'!
  306. !MKPanelView commentStamp!
  307. I am similar to a `MKPaneView` but I am scrollable and display a light background.!
  308. !MKPanelView methodsFor: 'accessing'!
  309. cssClass
  310. ^ super cssClass, ' mk_panel'
  311. ! !
  312. MKAspectsView subclass: #MKSelectionView
  313. instanceVariableNames: 'selectionAspect collectionAspect displayBlock iconBlock'
  314. package: 'Moka-Views'!
  315. !MKSelectionView commentStamp!
  316. I an abstract selection view of a list of elements.
  317. ## API
  318. Rendering can be customized with `#displayBlock:` and `#iconBlock:`. Both take the item of the list as argument and answer a string.!
  319. !MKSelectionView methodsFor: 'accessing'!
  320. collection
  321. ^ self valueForAspect: self collectionAspect
  322. !
  323. collectionAspect
  324. ^ collectionAspect
  325. !
  326. collectionAspect: aSelector
  327. collectionAspect := aSelector
  328. !
  329. displayBlock
  330. ^ displayBlock ifNil: [ self defaultDisplayBlock ]
  331. !
  332. displayBlock: aBlock
  333. displayBlock := aBlock
  334. !
  335. iconBlock
  336. ^ iconBlock
  337. !
  338. iconBlock: aBlock
  339. iconBlock := aBlock
  340. !
  341. selectedItem
  342. ^ self valueForAspect: self selectionAspect
  343. !
  344. selectionAspect
  345. ^ selectionAspect
  346. !
  347. selectionAspect: aSelector
  348. selectionAspect := aSelector
  349. ! !
  350. !MKSelectionView methodsFor: 'defaults'!
  351. defaultDisplayBlock
  352. ^ [ :item | item asString ]
  353. ! !
  354. !MKSelectionView methodsFor: 'rendering'!
  355. renderIconFor: anObject on: html
  356. self hasIcon ifTrue: [
  357. html img
  358. class: 'mk_icon';
  359. src: (self iconBlock value: anObject) ]
  360. ! !
  361. !MKSelectionView methodsFor: 'testing'!
  362. hasIcon
  363. ^ self iconBlock notNil
  364. ! !
  365. !MKSelectionView class methodsFor: 'instance creation'!
  366. model: aModel collectionAspect: collectionSelector selectionAspect: selectionSelector
  367. ^ (self model: aModel)
  368. collectionAspect: collectionSelector;
  369. selectionAspect: selectionSelector;
  370. yourself
  371. ! !
  372. MKSelectionView subclass: #MKDropdownView
  373. instanceVariableNames: 'modalPaneView listView'
  374. package: 'Moka-Views'!
  375. !MKDropdownView commentStamp!
  376. I am a push button view. My default controller is `MKButtonController`.
  377. My controller must answer to `#onPressed`.
  378. ## API
  379. - Instances can be set a `default` button
  380. - Use `#label:` to set the label string!
  381. !MKDropdownView methodsFor: 'accessing'!
  382. cssClass
  383. ^ super cssClass, ' mk_dropdown'
  384. !
  385. selectedListItem
  386. ^ (root asJQuery find: ':selected') text
  387. !
  388. tag
  389. ^ 'button'
  390. !
  391. update: anAnnouncement
  392. ({self selectionAspect. self collectionAspect}
  393. includes: anAnnouncement aspect) ifTrue: [
  394. self update ]
  395. ! !
  396. !MKDropdownView methodsFor: 'actions'!
  397. popupList
  398. "Show a new list view inside a modal pane"
  399. self modalPaneView
  400. left: self domPosition x;
  401. top: self domPosition y;
  402. render.
  403. self listView focus
  404. ! !
  405. !MKDropdownView methodsFor: 'defaults'!
  406. defaultControllerClass
  407. ^ MKDropdownController
  408. !
  409. defaultLayout
  410. ^ super defaultLayout
  411. width: 120;
  412. height: 24;
  413. yourself
  414. ! !
  415. !MKDropdownView methodsFor: 'rendering'!
  416. renderContentOn: html
  417. html div class: 'mk_dropdown_arrows'.
  418. self renderIconFor: self selectedItem on: html.
  419. html with: (self displayBlock value: self selectedItem)
  420. ! !
  421. !MKDropdownView methodsFor: 'views'!
  422. listView
  423. ^ listView ifNil: [
  424. listView := (MKDropdownListView
  425. model: self model
  426. collectionAspect: self collectionAspect
  427. selectionAspect: self selectionAspect)
  428. width: self width;
  429. height: 'auto';
  430. displayBlock: self displayBlock;
  431. iconBlock: self iconBlock;
  432. yourself ]
  433. !
  434. modalPaneView
  435. ^ modalPaneView ifNil: [
  436. modalPaneView := (MKModalDecorator decorate: self listView)
  437. extraCssClass: 'mk_dropdown_pane';
  438. closeOnEnter: true;
  439. closeOnClick: true;
  440. yourself.
  441. modalPaneView
  442. on: MKViewRemoved
  443. send: #focus
  444. to: self.
  445. modalPaneView ]
  446. ! !
  447. MKSelectionView subclass: #MKListView
  448. instanceVariableNames: ''
  449. package: 'Moka-Views'!
  450. !MKListView commentStamp!
  451. I display a list of elements in a list control field.!
  452. !MKListView methodsFor: 'accessing'!
  453. activeItem
  454. ^ self findItemFor: (root asJQuery find: '.', self selectedCssClass)
  455. !
  456. cssClass
  457. ^ super cssClass, ' mk_list'
  458. !
  459. findItemFor: aListItem
  460. ^ aListItem asJQuery data at: 'item'
  461. !
  462. findListItemFor: anObject
  463. ^ (((root asJQuery find: 'li')
  464. filter: [ :thisArg | (thisArg asJQuery data: 'item') = anObject ] currySelf) eq: 0)
  465. !
  466. selectedCssClass
  467. ^ 'selected'
  468. !
  469. tag
  470. ^ 'ul'
  471. ! !
  472. !MKListView methodsFor: 'actions'!
  473. activateItem: anObject
  474. self activateListItem: (self findListItemFor: anObject)
  475. !
  476. activateListItem: aListItem
  477. | item |
  478. (aListItem get: 0) ifNil: [ ^ self ].
  479. aListItem parent children removeClass: self selectedCssClass.
  480. aListItem addClass: self selectedCssClass.
  481. self ensureVisible: aListItem
  482. ! !
  483. !MKListView methodsFor: 'defaults'!
  484. defaultControllerClass
  485. ^ MKListController
  486. ! !
  487. !MKListView methodsFor: 'private'!
  488. ensureVisible: aListItem
  489. "Move the scrollbar to show the active element"
  490. | parent position |
  491. (aListItem get: 0) ifNil: [ ^ self ].
  492. position := self positionOf: aListItem.
  493. parent := aListItem parent.
  494. aListItem position top < 0 ifTrue: [
  495. (parent get: 0) scrollTop: ((parent get: 0) scrollTop + aListItem position top - 10) ].
  496. aListItem position top + aListItem height > parent height ifTrue: [
  497. (parent get: 0) scrollTop: ((parent get: 0) scrollTop + aListItem height - (parent height - aListItem position top)) +10 ].
  498. self announce: (MKViewScroll view: self)
  499. !
  500. positionOf: aListItem
  501. "TODO: rewrite in smalltalk"
  502. <return aListItem.parent().children().get().indexOf(aListItem.get(0)) + 1>
  503. ! !
  504. !MKListView methodsFor: 'rendering'!
  505. renderContentOn: html
  506. self collection do: [ :each |
  507. self renderItem: each on: html ].
  508. "make the list focusable"
  509. root at: 'tabindex' put: '0'
  510. !
  511. renderItem: anObject on: html
  512. | li |
  513. li := html li.
  514. li asJQuery data: 'item' put: anObject.
  515. self selectedItem = anObject ifTrue: [
  516. li class: self selectedCssClass ].
  517. li with: [ self renderIconFor: anObject on: html ].
  518. li with: (self displayBlock value: anObject)
  519. ! !
  520. !MKListView methodsFor: 'updating'!
  521. update: anAnnouncement
  522. anAnnouncement aspect = self selectionAspect ifTrue: [
  523. self updateSelectedItem ].
  524. anAnnouncement aspect = self collectionAspect ifTrue: [
  525. self update ]
  526. !
  527. updateSelectedItem
  528. self activateItem: self selectedItem
  529. ! !
  530. !MKListView class methodsFor: 'instance creation'!
  531. model: aModel collectionAspect: collectionSelector selectionAspect: selectionSelector
  532. ^ (self model: aModel)
  533. collectionAspect: collectionSelector;
  534. selectionAspect: selectionSelector;
  535. yourself
  536. ! !
  537. MKListView subclass: #MKDropdownListView
  538. instanceVariableNames: ''
  539. package: 'Moka-Views'!
  540. !MKDropdownListView commentStamp!
  541. I am similar to a `MKListView`, but inside a `MKDropdownView`.!
  542. !MKDropdownListView methodsFor: 'accessing'!
  543. cssClass
  544. ^ super cssClass, ' mk_dropdown_list'
  545. !
  546. defaultControllerClass
  547. ^ MKDropdownListController
  548. ! !
  549. MKListView subclass: #MKSourceListView
  550. instanceVariableNames: ''
  551. package: 'Moka-Views'!
  552. !MKSourceListView commentStamp!
  553. I am similar to a `MKListView`, but displayed slightly differently, in a similar way as in the left-side the of Finder in OSX.!
  554. !MKSourceListView methodsFor: 'accessing'!
  555. cssClass
  556. ^ super cssClass, ' mk_sourcelist'
  557. ! !
  558. MKLayoutView subclass: #MKSplitView
  559. instanceVariableNames: 'firstView secondView splitter thickness minimumThickness'
  560. package: 'Moka-Views'!
  561. !MKSplitView commentStamp!
  562. I am the superclass of all split views. I arrange two child view with a splitter between them.
  563. ## API
  564. Create instances using the class-side method `firstView:secondView:`.!
  565. !MKSplitView methodsFor: 'accessing'!
  566. children
  567. ^ { self firstView. self secondView }
  568. !
  569. cssClass
  570. ^ super cssClass, ' mk_split_view'
  571. !
  572. firstView
  573. ^ firstView
  574. !
  575. firstView: aView
  576. firstView := MKDecorator decorate: aView
  577. !
  578. minimumThickness
  579. ^ minimumThickness ifNil: [ self defaultMinimumThickness ]
  580. !
  581. minimumThickness: aNumber
  582. minimumThickness := aNumber
  583. !
  584. secondView
  585. ^ secondView
  586. !
  587. secondView: aView
  588. secondView := MKDecorator decorate: aView
  589. !
  590. splitter
  591. "Answer the `splitter` TagBrush"
  592. ^ splitter
  593. !
  594. splitterCssClass
  595. ^ 'mk_splitter'
  596. !
  597. thickness
  598. ^ thickness ifNil: [ self defaultThickness ]
  599. !
  600. thickness: aNumber
  601. thickness := aNumber
  602. ! !
  603. !MKSplitView methodsFor: 'defaults'!
  604. defaultMinimumThickness
  605. ^ 50
  606. !
  607. defaultThickness
  608. ^ 300
  609. ! !
  610. !MKSplitView methodsFor: 'rendering'!
  611. renderContentOn: html
  612. html with: self firstView.
  613. splitter := html div class: self splitterCssClass.
  614. html with: self secondView.
  615. self controller placeSplitter: self thickness
  616. ! !
  617. !MKSplitView class methodsFor: 'instance creation'!
  618. firstView: aView secondView: anotherView
  619. ^ self new
  620. firstView: aView;
  621. secondView: anotherView;
  622. yourself
  623. ! !
  624. MKSplitView subclass: #MKHorizontalSplitView
  625. instanceVariableNames: ''
  626. package: 'Moka-Views'!
  627. !MKHorizontalSplitView commentStamp!
  628. I split my child views vertically.!
  629. !MKHorizontalSplitView methodsFor: 'accessing'!
  630. cssClass
  631. ^ super cssClass, ' horizontal'
  632. !
  633. leftThickness: aNumber
  634. self thickness: aNumber.
  635. self controller: MKLeftFixedHorizontalSplitController new
  636. !
  637. rightThickness: aNumber
  638. self thickness: aNumber.
  639. self controller: MKRightFixedHorizontalSplitController new
  640. !
  641. secondView: aView
  642. super secondView: aView.
  643. self secondView
  644. right: 0;
  645. left: 'auto'
  646. ! !
  647. !MKHorizontalSplitView methodsFor: 'defaults'!
  648. defaultControllerClass
  649. ^ MKLeftFixedHorizontalSplitController
  650. ! !
  651. !MKHorizontalSplitView methodsFor: 'private'!
  652. setupEventHandlers
  653. splitter asJQuery draggable: #{
  654. 'axis' -> 'x'.
  655. 'containment' -> splitter asJQuery parent.
  656. 'helper' -> 'clone'.
  657. 'cursor' -> 'ew-resize'.
  658. 'stop' -> [ self resized ].
  659. 'drag' -> [ :event :ui | self controller onResize: event helper: ui ] }
  660. ! !
  661. MKSplitView subclass: #MKVerticalSplitView
  662. instanceVariableNames: ''
  663. package: 'Moka-Views'!
  664. !MKVerticalSplitView commentStamp!
  665. I split my child views horizontally.!
  666. !MKVerticalSplitView methodsFor: 'accessing'!
  667. bottomThickness: aNumber
  668. self thickness: aNumber.
  669. self controller: MKBottomFixedVerticalSplitController new
  670. !
  671. cssClass
  672. ^ super cssClass, ' vertical'
  673. !
  674. secondView: aView
  675. super secondView: aView.
  676. self secondView
  677. bottom: 0;
  678. top: 'auto'
  679. !
  680. topThickness: aNumber
  681. self thickness: aNumber.
  682. self controller: MKTopFixedVerticalSplitController new
  683. ! !
  684. !MKVerticalSplitView methodsFor: 'defaults'!
  685. defaultControllerClass
  686. ^ MKTopFixedVerticalSplitController
  687. ! !
  688. !MKVerticalSplitView methodsFor: 'private'!
  689. setupEventHandlers
  690. splitter asJQuery draggable: #{
  691. 'axis' -> 'y'.
  692. 'containment' -> splitter asJQuery parent.
  693. 'cursor' -> 'ns-resize'.
  694. 'helper' -> 'clone'.
  695. 'stop' -> [ self resized ].
  696. 'drag' -> [ :event :ui | self controller onResize: event helper: ui ] }
  697. ! !
  698. MKSingleAspectView subclass: #MKTextAreaView
  699. instanceVariableNames: ''
  700. package: 'Moka-Views'!
  701. !MKTextAreaView commentStamp!
  702. I am an text area view. My default controller is `MKAnyKeyInputController`.
  703. My controller must answer to `#onKeyPressed:`.!
  704. !MKTextAreaView methodsFor: 'accessing'!
  705. cssClass
  706. ^ super cssClass, ' mk_textarea'
  707. !
  708. tag
  709. ^ 'textarea'
  710. !
  711. value
  712. ^ root asJQuery val
  713. ! !
  714. !MKTextAreaView methodsFor: 'defaults'!
  715. defaultControllerClass
  716. ^ MKAnyKeyInputController
  717. !
  718. defaultLayout
  719. ^ super defaultLayout
  720. width: 160;
  721. height: 80;
  722. yourself
  723. ! !
  724. !MKTextAreaView methodsFor: 'rendering'!
  725. renderContentOn: html
  726. root with: self aspectValue
  727. ! !
  728. !MKTextAreaView methodsFor: 'updating'!
  729. update
  730. root ifNotNil: [ root asJQuery val: self aspectValue ]
  731. ! !
  732. MKTextAreaView subclass: #MKInputView
  733. instanceVariableNames: ''
  734. package: 'Moka-Views'!
  735. !MKInputView commentStamp!
  736. I am an input view. My default controller is `MKEnterInputController`.
  737. My controller must answer to `#onKeyPressed:`.!
  738. !MKInputView methodsFor: 'accessing'!
  739. cssClass
  740. ^ 'moka_view mk_input'
  741. !
  742. tag
  743. ^ 'input'
  744. ! !
  745. !MKInputView methodsFor: 'defaults'!
  746. defaultControllerClass
  747. ^ MKEnterInputController
  748. !
  749. defaultLayout
  750. ^ super defaultLayout
  751. width: 160;
  752. height: 24;
  753. yourself
  754. ! !
  755. !MKInputView methodsFor: 'rendering'!
  756. renderContentOn: html
  757. root value: self aspectValue
  758. ! !
  759. !MKInputView methodsFor: 'settings'!
  760. triggerChangeOnAnyKey
  761. self controller: MKAnyKeyInputController new
  762. !
  763. triggerChangeOnEnter
  764. self controller: MKEnterInputController new
  765. ! !