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