listitemview.js 835 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /**
  6. * @module ui/list/listitemview
  7. */
  8. import View from '../view';
  9. /**
  10. * The list item view class.
  11. *
  12. * @extends module:ui/view~View
  13. */
  14. export default class ListItemView extends View {
  15. /**
  16. * @inheritDoc
  17. */
  18. constructor( locale ) {
  19. super( locale );
  20. /**
  21. * Collection of the child views inside of the list item {@link #element}.
  22. *
  23. * @readonly
  24. * @member {module:ui/viewcollection~ViewCollection}
  25. */
  26. this.children = this.createCollection();
  27. this.setTemplate( {
  28. tag: 'li',
  29. attributes: {
  30. class: [
  31. 'ck',
  32. 'ck-list__item'
  33. ]
  34. },
  35. children: this.children
  36. } );
  37. }
  38. /**
  39. * Focuses the list item.
  40. */
  41. focus() {
  42. this.children.first.focus();
  43. }
  44. }