8
0

theme.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 iconManagerModel from '/theme/iconmanagermodel.js';
  8. function setupIconManager() {
  9. const iconManagerView = new IconManagerView( iconManagerModel );
  10. document.body.appendChild( iconManagerView.element );
  11. iconManagerView.init();
  12. }
  13. function renderIcons() {
  14. const buttonIcons = document.getElementById( 'button-icon' );
  15. const icons = document.getElementById( 'icons' );
  16. const tmp = document.createElement( 'div' );
  17. iconManagerModel.icons.forEach( i => {
  18. tmp.innerHTML = `<svg class="ck-icon"><use xlink:href="#ck-icon-${ i }"></use></svg>`;
  19. icons.appendChild( tmp.firstChild );
  20. icons.appendChild( document.createTextNode( ' ' ) );
  21. tmp.innerHTML =
  22. `<button class="ck-button ck-button-notext">
  23. <svg class="ck-icon ck-icon-left"><use xlink:href="#ck-icon-${ i }"></use></svg>
  24. </button>`;
  25. buttonIcons.appendChild( tmp.firstChild );
  26. buttonIcons.appendChild( document.createTextNode( ' ' ) );
  27. } );
  28. }
  29. function renderResponsiveButtons() {
  30. const responsive = document.getElementById( 'button-responsive' );
  31. let current = responsive.firstElementChild;
  32. for ( let i = 3; i--; ) {
  33. const clone = current.cloneNode( 1 );
  34. current.appendChild( clone );
  35. current = clone;
  36. }
  37. }
  38. setupIconManager();
  39. renderIcons();
  40. renderResponsiveButtons();