]>
git.immae.eu Git - perso/Immae/Projets/packagist/piedsjaloux-ckeditor-component.git/blob - plugins.js
8e6c95280c1463e5f3494aac5cb5c3b75ccec4fc
2 * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
3 * For licensing, see LICENSE.md 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.
15 * @extends CKEDITOR.resourceManager
18 CKEDITOR
.plugins
= new CKEDITOR
.resourceManager( 'plugins/', 'plugin' );
20 // PACKAGER_RENAME( CKEDITOR.plugins )
22 CKEDITOR
.plugins
.load
= CKEDITOR
.tools
.override( CKEDITOR
.plugins
.load
, function( originalLoad
) {
25 return function( name
, callback
, scope
) {
28 var loadPlugins = function( names
) {
29 originalLoad
.call( this, names
, function( plugins
) {
30 CKEDITOR
.tools
.extend( allPlugins
, plugins
);
32 var requiredPlugins
= [];
33 for ( var pluginName
in plugins
) {
34 var plugin
= plugins
[ pluginName
],
35 requires
= plugin
&& plugin
.requires
;
37 if ( !initialized
[ pluginName
] ) {
38 // Register all icons eventually defined by this plugin.
40 var icons
= plugin
.icons
.split( ',' );
41 for ( var ic
= icons
.length
; ic
--; ) {
42 CKEDITOR
.skin
.addIcon( icons
[ ic
],
45 ( CKEDITOR
.env
.hidpi
&& plugin
.hidpi
? 'hidpi/' : '' ) +
50 initialized
[ pluginName
] = 1;
54 // Trasnform it into an array, if it's not one.
56 requires
= requires
.split( ',' );
58 for ( var i
= 0; i
< requires
.length
; i
++ ) {
59 if ( !allPlugins
[ requires
[ i
] ] )
60 requiredPlugins
.push( requires
[ i
] );
65 if ( requiredPlugins
.length
)
66 loadPlugins
.call( this, requiredPlugins
);
68 // Call the "onLoad" function for all plugins.
69 for ( pluginName
in allPlugins
) {
70 plugin
= allPlugins
[ pluginName
];
71 if ( plugin
.onLoad
&& !plugin
.onLoad
._called
) {
72 // Make it possible to return false from plugin::onLoad to disable it.
73 if ( plugin
.onLoad() === false )
74 delete allPlugins
[ pluginName
];
76 plugin
.onLoad
._called
= 1;
82 callback
.call( scope
|| window
, allPlugins
);
88 loadPlugins
.call( this, name
);
93 * Loads a specific language file, or auto detect it. A callback is
94 * then called when the file gets loaded.
96 * CKEDITOR.plugins.setLang( 'myPlugin', 'en', {
98 * selectOption: 'Please select an option'
101 * @param {String} pluginName The name of the plugin to which the provided translation
102 * should be attached.
103 * @param {String} languageCode The code of the language translation provided.
104 * @param {Object} languageEntries An object that contains pairs of label and
105 * the respective translation.
107 CKEDITOR
.plugins
.setLang = function( pluginName
, languageCode
, languageEntries
) {
108 var plugin
= this.get( pluginName
),
109 pluginLangEntries
= plugin
.langEntries
|| ( plugin
.langEntries
= {} ),
110 pluginLang
= plugin
.lang
|| ( plugin
.lang
= [] );
112 if ( pluginLang
.split
)
113 pluginLang
= pluginLang
.split( ',' );
115 if ( CKEDITOR
.tools
.indexOf( pluginLang
, languageCode
) == -1 )
116 pluginLang
.push( languageCode
);
118 pluginLangEntries
[ languageCode
] = languageEntries
;