editoruiview.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /**
  2. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /**
  6. * @module ui/editorui/editoruiview
  7. */
  8. /* globals document */
  9. import View from '../view';
  10. import Template from '../template';
  11. import '../../theme/components/editorui/editorui.css';
  12. /**
  13. * The editor UI view class. Base class for the editor main views.
  14. *
  15. * @extends module:ui/view~View
  16. */
  17. export default class EditorUIView extends View {
  18. /**
  19. * Creates an instance of the editor UI view class.
  20. *
  21. * @param {module:utils/locale~Locale} [locale] The locale instance.
  22. */
  23. constructor( locale ) {
  24. super( locale );
  25. /**
  26. * Collection of the child views, detached from the DOM
  27. * structure of the editor, like panels, icons etc.
  28. *
  29. * @readonly
  30. * @member {module:ui/viewcollection~ViewCollection} #body
  31. */
  32. this.body = this.createCollection();
  33. /**
  34. * The element holding elements of the 'body' region.
  35. *
  36. * @private
  37. * @member {HTMLElement} #_bodyCollectionContainer
  38. */
  39. }
  40. /**
  41. * @inheritDoc
  42. */
  43. render() {
  44. super.render();
  45. this._renderBodyCollection();
  46. }
  47. /**
  48. * @inheritDoc
  49. */
  50. destroy() {
  51. this._bodyCollectionContainer.remove();
  52. return super.destroy();
  53. }
  54. /**
  55. * Creates and appends to `<body>` the {@link #body} collection container.
  56. *
  57. * @private
  58. */
  59. _renderBodyCollection() {
  60. const bodyElement = this._bodyCollectionContainer = new Template( {
  61. tag: 'div',
  62. attributes: {
  63. class: [
  64. 'ck-body',
  65. 'ck-rounded-corners',
  66. 'ck-reset_all'
  67. ]
  68. },
  69. children: this.body
  70. } ).render();
  71. document.body.appendChild( bodyElement );
  72. }
  73. }