2 Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
\r
3 For licensing, see LICENSE.html or http://ckeditor.com/license
\r
7 * @fileOverview Defines the {@link CKEDITOR.plugins} object, which is used to
\r
8 * manage plugins registration and loading.
\r
12 * Manages plugins registration and loading.
\r
14 * @augments CKEDITOR.resourceManager
\r
17 CKEDITOR.plugins = new CKEDITOR.resourceManager(
\r
18 '_source/' + // @Packager.RemoveLine
\r
19 'plugins/', 'plugin' );
\r
21 // PACKAGER_RENAME( CKEDITOR.plugins )
\r
23 CKEDITOR.plugins.load = CKEDITOR.tools.override( CKEDITOR.plugins.load, function( originalLoad )
\r
25 return function( name, callback, scope )
\r
27 var allPlugins = {};
\r
29 var loadPlugins = function( names )
\r
31 originalLoad.call( this, names, function( plugins )
\r
33 CKEDITOR.tools.extend( allPlugins, plugins );
\r
35 var requiredPlugins = [];
\r
36 for ( var pluginName in plugins )
\r
38 var plugin = plugins[ pluginName ],
\r
39 requires = plugin && plugin.requires;
\r
43 for ( var i = 0 ; i < requires.length ; i++ )
\r
45 if ( !allPlugins[ requires[ i ] ] )
\r
46 requiredPlugins.push( requires[ i ] );
\r
51 if ( requiredPlugins.length )
\r
52 loadPlugins.call( this, requiredPlugins );
\r
55 // Call the "onLoad" function for all plugins.
\r
56 for ( pluginName in allPlugins )
\r
58 plugin = allPlugins[ pluginName ];
\r
59 if ( plugin.onLoad && !plugin.onLoad._called )
\r
62 plugin.onLoad._called = 1;
\r
66 // Call the callback.
\r
68 callback.call( scope || window, allPlugins );
\r
75 loadPlugins.call( this, name );
\r
80 * Loads a specific language file, or auto detect it. A callback is
\r
81 * then called when the file gets loaded.
\r
82 * @param {String} pluginName The name of the plugin to which the provided translation
\r
83 * should be attached.
\r
84 * @param {String} languageCode The code of the language translation provided.
\r
85 * @param {Object} languageEntries An object that contains pairs of label and
\r
86 * the respective translation.
\r
88 * CKEDITOR.plugins.setLang( 'myPlugin', 'en', {
\r
89 * title : 'My plugin',
\r
90 * selectOption : 'Please select an option'
\r
93 CKEDITOR.plugins.setLang = function( pluginName, languageCode, languageEntries )
\r
95 var plugin = this.get( pluginName ),
\r
96 pluginLangEntries = plugin.langEntries || ( plugin.langEntries = {} ),
\r
97 pluginLang = plugin.lang || ( plugin.lang = [] );
\r
99 if ( CKEDITOR.tools.indexOf( pluginLang, languageCode ) == -1 )
\r
100 pluginLang.push( languageCode );
\r
102 pluginLangEntries[ languageCode ] = languageEntries;
\r