Moka-Views.st 17 KB

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