Changeset 2336

Show
Ignore:
Timestamp:
2008-08-06 12:12:10 (5 months ago)
Author:
fredck
Message:

Plugins may now define a dependency list, so we don't need to add all plugins to the configuration to make it work.

Location:
CKEditor/branches/prototype
Files:
12 modified

Legend:

Unmodified
Added
Removed
  • CKEditor/branches/prototype/fckpackager.xml

    r2334 r2336  
    9696                <File path="_source/plugins/basicstyles/plugin.js" /> 
    9797                <File path="_source/plugins/button/plugin.js" /> 
    98                 <File path="_source/plugins/editingblock/plugin.js" /> 
    9998                <File path="_source/plugins/elementspath/plugin.js" /> 
    10099                <File path="_source/plugins/htmldataprocessor/plugin.js" /> 
    101                 <File path="_source/plugins/htmlwriter/plugin.js" /> 
    102                 <File path="_source/plugins/selection/plugin.js" /> 
    103100                <File path="_source/plugins/sourcearea/plugin.js" /> 
    104101                <File path="_source/plugins/toolbar/plugin.js" /> 
    105102                <File path="_source/plugins/wysiwygarea/plugin.js" /> 
     103                <File path="_source/plugins/selection/plugin.js" /> 
     104                <File path="_source/plugins/htmlwriter/plugin.js" /> 
     105                <File path="_source/plugins/editingblock/plugin.js" /> 
    106106                <File path="_source/themes/default/theme.js" /> 
    107107        </PackageFile> 
  • CKEditor/branches/prototype/_source/core/config.js

    r2334 r2336  
    134134         * @default 'editingblock,elementspath,sourcearea,toolbar,wysiwygarea' 
    135135         * @example 
    136          * config.plugins = 'editingblock,toolbar,wysiwygarea'; 
     136         * config.plugins = 'elementspath,toolbar,wysiwygarea'; 
    137137         */ 
    138         plugins : 'basicstyles,button,editingblock,elementspath,htmldataprocessor,htmlwriter,selection,sourcearea,toolbar,wysiwygarea', 
     138        plugins : 'basicstyles,button,elementspath,htmldataprocessor,sourcearea,toolbar,wysiwygarea', 
    139139 
    140140        /** 
  • CKEditor/branches/prototype/_source/core/editor.js

    r2278 r2336  
    152152                                for ( var m = 0 ; m < methods.length ; m++ ) 
    153153                                { 
    154                                         for ( var i = 0 ; i < plugins.length ; i++ ) 
     154                                        for ( var pluginName in plugins ) 
    155155                                        { 
    156                                                 var pluginName = plugins[ i ]; 
    157                                                 var plugin = CKEDITOR.plugins.get( pluginName ); 
     156                                                var plugin = plugins[ pluginName ]; 
    158157                                                if ( plugin && plugin[ methods[ m ] ] ) 
    159158                                                        plugin[ methods[ m ] ]( editor, CKEDITOR.plugins.getPath( pluginName ) ); 
  • CKEditor/branches/prototype/_source/core/pluginDefinition.js

    r2278 r2336  
    3333 * @constructor 
    3434 * @example 
     35 */ 
     36 
     37/** 
     38 * A list of plugins that are required by this plugin. Note that this property 
     39 * doesn't guarantee the loading order of the plugins. 
     40 * @name CKEDITOR.pluginDefinition.prototype.requires 
     41 * @type Array 
     42 * @example 
     43 * CKEDITOR.plugins.add( 'sample', 
     44 * { 
     45 *     requires : [ 'button', 'selection' ] 
     46 * }); 
    3547 */ 
    3648 
  • CKEditor/branches/prototype/_source/core/plugins.js

    r2214 r2336  
    3434        '_source/' +    // @Packager.RemoveLine 
    3535        'plugins/', 'plugin' ); 
     36 
     37CKEDITOR.plugins.load = CKEDITOR.tools.override( CKEDITOR.plugins.load, function( originalLoad ) 
     38        { 
     39                return function( name, callback, scope ) 
     40                { 
     41                        var allPlugins = {}; 
     42 
     43                        var loadPlugins = function( names ) 
     44                        { 
     45                                originalLoad.call( this, names, function( plugins ) 
     46                                        { 
     47                                                CKEDITOR.tools.extend( allPlugins, plugins ); 
     48 
     49                                                var requiredPlugins = []; 
     50                                                for ( var pluginName in plugins ) 
     51                                                { 
     52                                                        var plugin = plugins[ pluginName ], 
     53                                                                requires = plugin && plugin.requires; 
     54 
     55                                                        if ( requires ) 
     56                                                        { 
     57                                                                for ( var i = 0 ; i < requires.length ; i++ ) 
     58                                                                { 
     59                                                                        if ( !allPlugins[ requires[ i ] ] ) 
     60                                                                                requiredPlugins.push( requires[ i ] ); 
     61                                                                } 
     62                                                        } 
     63                                                } 
     64 
     65                                                if ( requiredPlugins.length ) 
     66                                                        loadPlugins.call( this, requiredPlugins ); 
     67                                                else 
     68                                                        callback.call( scope || window, allPlugins ); 
     69                                        } 
     70                                        , this); 
     71 
     72                        }; 
     73 
     74                        loadPlugins.call( this, name ); 
     75                }; 
     76        }); 
  • CKEditor/branches/prototype/_source/core/resourcemanager.js

    r2261 r2336  
    164164        { 
    165165                // Ensure that we have an Array of names. 
    166                 var names = CKEDITOR.tools.isArray( name ) ? name : [ name ]; 
    167                 var total = names.length; 
     166                var names = CKEDITOR.tools.isArray( name ) ? name : name ? [ name ] : [], 
     167                        total = names.length, 
     168                        resources = {}; 
    168169 
    169170                // Nothing to load, just call the callback. 
    170171                if ( !total ) 
    171172                { 
    172                         callback.call( scope || window, names ); 
     173                        callback.call( scope || window, resources ); 
    173174                        return; 
    174175                } 
     
    181182                { 
    182183                        if ( ++callback._loaded == callback._total ) 
    183                                 callback.call( scope || window, names ); 
     184                                callback.call( scope || window, resources ); 
    184185                }; 
    185186 
     
    190191                { 
    191192                        // Calculate the plugin script path. 
    192                         var path = this.externals[ name ] || ( this.basePath + name + '/' ); 
    193                         var filePath = CKEDITOR.getUrl( path + this.fileName + '.js' ); 
     193                        var path = this.externals[ name ] || ( this.basePath + name + '/' ), 
     194                                filePath = CKEDITOR.getUrl( path + this.fileName + '.js' ); 
    194195 
    195196                        // Load the plugin script. 
     
    201202                                        loaded[ name ] = path; 
    202203 
     204                                        resources[ name ] = this.get( name ); 
     205 
    203206                                        // Check all callbacks that were waiting for this 
    204207                                        // resource. 
     
    207210 
    208211                                        delete waitingList[ name ]; 
    209                                 }); 
     212                                }, this); 
    210213                }; 
    211214 
     
    215218                        name = names[ i ]; 
    216219 
    217                         // If not loaded already. 
    218                         if ( name && !loaded[ name ] && !this.registered[ name ] ) 
     220                        if ( name && typeof resources[ name ] == 'undefined' ) 
    219221                        { 
    220                                 var waitingInfo = waitingList[ name ] || ( waitingList[ name ] = [] ); 
    221                                 waitingInfo.push( callback ); 
    222  
    223                                 // If this is the first call for it, go ahead loading. 
    224                                 if ( waitingInfo.length == 1 ) 
    225                                         loadPlugin.call( this, name ); 
     222                                resources[ name ] = this.get( name ); 
     223 
     224                                // If not loaded already. 
     225                                if ( !loaded[ name ] && !this.registered[ name ] ) 
     226                                { 
     227                                        var waitingInfo = waitingList[ name ] || ( waitingList[ name ] = [] ); 
     228                                        waitingInfo.push( callback ); 
     229 
     230                                        // If this is the first call for it, go ahead loading. 
     231                                        if ( waitingInfo.length == 1 ) 
     232                                                loadPlugin.call( this, name ); 
     233 
     234                                        continue; 
     235                                } 
    226236                        } 
    227                         else 
    228                                 loadCheck( callback ); 
     237                        loadCheck( callback ); 
    229238                } 
    230239        } 
  • CKEditor/branches/prototype/_source/core/tools.js

    r2334 r2336  
    201201                }; 
    202202        })(), 
     203 
     204        /** 
     205         * Creates a function override. 
     206         * @param {Function} originalFunction The function to be overridden. 
     207         * @param {Function} functionBuilder A function that returns the new 
     208         *              function. The original function reference will be passed to this 
     209         *              function. 
     210         * @returns {Function} The new function. 
     211         * @example 
     212         * var example = 
     213         * { 
     214         *     myFunction : function( name ) 
     215         *     { 
     216         *         alert( 'Name: ' + name ); 
     217         *     } 
     218         * }; 
     219         * 
     220         * example.myFunction = CKEDITOR.tools.override( example.myFunction, function( myFunctionOriginal ) 
     221         *     { 
     222         *         return function( name ) 
     223         *             { 
     224         *                 alert( 'Override Name: ' + name ); 
     225         *                 myFunctionOriginal.call( this, name ); 
     226         *             }; 
     227         *     }); 
     228         */ 
     229        override : function( originalFunction, functionBuilder ) 
     230        { 
     231                return functionBuilder( originalFunction ); 
     232        }, 
    203233 
    204234        /** 
  • CKEditor/branches/prototype/_source/plugins/elementspath/plugin.js

    r2278 r2336  
    2727CKEDITOR.plugins.add( 'elementspath', 
    2828{ 
     29        requires : [ 'selection' ], 
     30 
    2931        init : function( editor, pluginPath ) 
    3032        { 
  • CKEditor/branches/prototype/_source/plugins/htmldataprocessor/plugin.js

    r2334 r2336  
    2222CKEDITOR.plugins.add( 'htmldataprocessor', 
    2323{ 
     24        requires : [ 'htmlwriter' ], 
     25 
    2426        init : function( editor, pluginPath ) 
    2527        { 
  • CKEditor/branches/prototype/_source/plugins/htmlwriter/plugin.js

    r2335 r2336  
    316316}; 
    317317 
    318 CKEDITOR.plugins.add( 'htmlwriter', {} ); 
     318CKEDITOR.plugins.add( 'htmlwriter' ); 
  • CKEditor/branches/prototype/_source/plugins/sourcearea/plugin.js

    r2278 r2336  
    2727CKEDITOR.plugins.add( 'sourcearea', 
    2828{ 
     29        requires : [ 'editingblock' ], 
     30 
    2931        init : function( editor, pluginPath ) 
    3032        { 
  • CKEditor/branches/prototype/_source/plugins/wysiwygarea/plugin.js

    r2254 r2336  
    6262        CKEDITOR.plugins.add( 'wysiwygarea', 
    6363        { 
     64                requires : [ 'editingblock' ], 
     65 
    6466                init : function( editor, pluginPath ) 
    6567                {