8
0

theme.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. 'use strict';
  6. import IconManagerView from '/ckeditor5/ui/iconmanagerview.js';
  7. import Model from '/ckeditor5/ui/model.js';
  8. import IconView from '/ckeditor5/ui/icon/iconview.js';
  9. import ButtonView from '/ckeditor5/ui/button/buttonview.js';
  10. import iconManagerModel from '/theme/iconmanagermodel.js';
  11. function setupIconManager() {
  12. const iconManagerView = new IconManagerView( iconManagerModel );
  13. document.body.appendChild( iconManagerView.element );
  14. iconManagerView.init();
  15. }
  16. function renderIcons() {
  17. const containers = [
  18. document.getElementById( 'icons' ),
  19. document.getElementById( 'iconsColored' )
  20. ];
  21. const buttonIcons = document.getElementById( 'buttonIcon' );
  22. iconManagerModel.icons.forEach( i => {
  23. const view = new IconView( new Model( { icon: i } ) );
  24. const button = new ButtonView( new Model( { label: i, icon: i, isEnabled: true } ) );
  25. button.init();
  26. containers.forEach( c => {
  27. c.appendChild( view.element.cloneNode( 1 ) );
  28. c.appendChild( document.createTextNode( ' ' ) );
  29. } );
  30. buttonIcons.appendChild( button.element );
  31. buttonIcons.appendChild( document.createTextNode( ' ' ) );
  32. } );
  33. }
  34. function renderResponsiveButtons() {
  35. const responsive = document.getElementById( 'buttonResponsive' );
  36. let current = responsive.firstElementChild;
  37. for ( let i = 3; i--; ) {
  38. const clone = current.cloneNode( 1 );
  39. current.appendChild( clone );
  40. current = clone;
  41. }
  42. }
  43. setupIconManager();
  44. renderIcons();
  45. renderResponsiveButtons();