JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-4.0.2_full
[ckeditor.git] / samples / sample.js
1 /**\r
2  * Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.\r
3  * For licensing, see LICENSE.html or http://ckeditor.com/license\r
4  */\r
5 \r
6 // Tool scripts for the sample pages.\r
7 // This file can be ignored and is not required to make use of CKEditor.\r
8 \r
9 (function() {\r
10         // Check for sample compliance.\r
11         CKEDITOR.on( 'instanceReady', function( ev ) {\r
12                 var editor = ev.editor,\r
13                         meta = CKEDITOR.document.$.getElementsByName( 'ckeditor-sample-required-plugins' ),\r
14                         requires = meta.length ? CKEDITOR.dom.element.get( meta[ 0 ] ).getAttribute( 'content' ).split( ',' ) : [],\r
15                         missing = [];\r
16 \r
17                 if ( requires.length ) {\r
18                         for ( var i = 0; i < requires.length; i++ ) {\r
19                                 if ( !editor.plugins[ requires[ i ] ] )\r
20                                         missing.push( '<code>' + requires[ i ] + '</code>' );\r
21                         }\r
22 \r
23                         if ( missing.length ) {\r
24                                 var warn = CKEDITOR.dom.element.createFromHtml(\r
25                                         '<div class="warning">' +\r
26                                                 '<span>To fully experience this demo, the ' + missing.join( ', ' ) + ' plugin' + ( missing.length > 1 ? 's are' : ' is' ) + ' required.</span>' +\r
27                                         '</div>'\r
28                                 );\r
29                                 warn.insertBefore( editor.container );\r
30                         }\r
31                 }\r
32         });\r
33 })();\r