You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.6 KiB

  1. /**
  2. * Copyright (c) 2003-2014, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or http://ckeditor.com/license
  4. */
  5. // Tool scripts for the sample pages.
  6. // This file can be ignored and is not required to make use of CKEditor.
  7. ( function() {
  8. CKEDITOR.on( 'instanceReady', function( ev ) {
  9. // Check for sample compliance.
  10. var editor = ev.editor,
  11. meta = CKEDITOR.document.$.getElementsByName( 'ckeditor-sample-required-plugins' ),
  12. requires = meta.length ? CKEDITOR.dom.element.get( meta[ 0 ] ).getAttribute( 'content' ).split( ',' ) : [],
  13. missing = [],
  14. i;
  15. if ( requires.length ) {
  16. for ( i = 0; i < requires.length; i++ ) {
  17. if ( !editor.plugins[ requires[ i ] ] )
  18. missing.push( '<code>' + requires[ i ] + '</code>' );
  19. }
  20. if ( missing.length ) {
  21. var warn = CKEDITOR.dom.element.createFromHtml(
  22. '<div class="warning">' +
  23. '<span>To fully experience this demo, the ' + missing.join( ', ' ) + ' plugin' + ( missing.length > 1 ? 's are' : ' is' ) + ' required.</span>' +
  24. '</div>'
  25. );
  26. warn.insertBefore( editor.container );
  27. }
  28. }
  29. // Set icons.
  30. var doc = new CKEDITOR.dom.document( document ),
  31. icons = doc.find( '.button_icon' );
  32. for ( i = 0; i < icons.count(); i++ ) {
  33. var icon = icons.getItem( i ),
  34. name = icon.getAttribute( 'data-icon' ),
  35. style = CKEDITOR.skin.getIconStyle( name, ( CKEDITOR.lang.dir == 'rtl' ) );
  36. icon.addClass( 'cke_button_icon' );
  37. icon.addClass( 'cke_button__' + name + '_icon' );
  38. icon.setAttribute( 'style', style );
  39. icon.setStyle( 'float', 'none' );
  40. }
  41. } );
  42. } )();