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