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