Ticket #7588: 7588_2.patch

File 7588_2.patch, 5.6 KB (added by Alfonso Martínez de Lizarrondo, 13 years ago)

Revised patch

  • _source/core/ui.js

     
    33For licensing, see LICENSE.html or http://ckeditor.com/license
    44*/
    55
    6 /**
    7  * Contains UI features related to an editor instance.
    8  * @constructor
    9  * @param {CKEDITOR.editor} editor The editor instance.
    10  * @example
    11  */
    12 CKEDITOR.ui = function( editor )
    13 {
    14         if ( editor.ui )
    15                 return editor.ui;
     6(function() {
     7        // Don't initialize twice #7588
     8        if ( CKEDITOR.ui )
     9                return;
    1610
    1711        /**
    18          * Object used to hold private stuff.
    19          * @private
     12         * Contains UI features related to an editor instance.
     13         * @constructor
     14         * @param {CKEDITOR.editor} editor The editor instance.
     15         * @example
    2016         */
    21         this._ =
     17        CKEDITOR.ui = function( editor )
    2218        {
    23                 handlers : {},
    24                 items : {},
    25                 editor : editor
     19                if ( editor.ui )
     20                        return editor.ui;
     21
     22                /**
     23                 * Object used to hold private stuff.
     24                 * @private
     25                 */
     26                this._ =
     27                {
     28                        handlers : {},
     29                        items : {},
     30                        editor : editor
     31                };
     32
     33                return this;
    2634        };
    2735
    28         return this;
    29 };
     36        // PACKAGER_RENAME( CKEDITOR.ui )
    3037
    31 // PACKAGER_RENAME( CKEDITOR.ui )
    32 
    33 CKEDITOR.ui.prototype =
    34 {
    35         /**
    36          * Adds a UI item to the items collection. These items can be later used in
    37          * the interface.
    38          * @param {String} name The UI item name.
    39          * @param {Object} type The item type.
    40          * @param {Object} definition The item definition. The properties of this
    41          *              object depend on the item type.
    42          * @example
    43          * // Add a new button named "MyBold".
    44          * editorInstance.ui.add( 'MyBold', CKEDITOR.UI_BUTTON,
    45          *     {
    46          *         label : 'My Bold',
    47          *         command : 'bold'
    48          *     });
    49          */
    50         add : function( name, type, definition )
     38        CKEDITOR.ui.prototype =
    5139        {
    52                 this._.items[ name ] =
     40                /**
     41                 * Adds a UI item to the items collection. These items can be later used in
     42                 * the interface.
     43                 * @param {String} name The UI item name.
     44                 * @param {Object} type The item type.
     45                 * @param {Object} definition The item definition. The properties of this
     46                 *              object depend on the item type.
     47                 * @example
     48                 * // Add a new button named "MyBold".
     49                 * editorInstance.ui.add( 'MyBold', CKEDITOR.UI_BUTTON,
     50                 *     {
     51                 *         label : 'My Bold',
     52                 *         command : 'bold'
     53                 *     });
     54                 */
     55                add : function( name, type, definition )
    5356                {
    54                         type : type,
    55                         // The name of {@link CKEDITOR.command} which associate with this UI.
    56                         command : definition.command || null,
    57                         args : Array.prototype.slice.call( arguments, 2 )
    58                 };
    59         },
     57                        this._.items[ name ] =
     58                        {
     59                                type : type,
     60                                // The name of {@link CKEDITOR.command} which associate with this UI.
     61                                command : definition.command || null,
     62                                args : Array.prototype.slice.call( arguments, 2 )
     63                        };
     64                },
    6065
    61         /**
    62         * Gets a UI object.
    63         * @param {String} name The UI item hame.
    64         * @example
    65         */
    66         create : function( name )
    67         {
    68                 var item        = this._.items[ name ],
    69                         handler = item && this._.handlers[ item.type ],
    70                         command = item && item.command && this._.editor.getCommand( item.command );
     66                /**
     67                * Gets a UI object.
     68                * @param {String} name The UI item hame.
     69                * @example
     70                */
     71                create : function( name )
     72                {
     73                        var item        = this._.items[ name ],
     74                                handler = item && this._.handlers[ item.type ],
     75                                command = item && item.command && this._.editor.getCommand( item.command );
    7176
    72                 var result = handler && handler.create.apply( this, item.args );
     77                        var result = handler && handler.create.apply( this, item.args );
    7378
    74                 // Add reference inside command object.
    75                 if ( command )
    76                         command.uiItems.push( result );
     79                        // Add reference inside command object.
     80                        if ( command )
     81                                command.uiItems.push( result );
    7782
    78                 return result;
    79         },
     83                        return result;
     84                },
    8085
    81         /**
    82         * Adds a handler for a UI item type. The handler is responsible for
    83         * transforming UI item definitions in UI objects.
    84         * @param {Object} type The item type.
    85         * @param {Object} handler The handler definition.
    86         * @example
    87         */
    88         addHandler : function( type, handler )
    89         {
    90                 this._.handlers[ type ] = handler;
    91         }
    92 };
     86                /**
     87                * Adds a handler for a UI item type. The handler is responsible for
     88                * transforming UI item definitions in UI objects.
     89                * @param {Object} type The item type.
     90                * @param {Object} handler The handler definition.
     91                * @example
     92                */
     93                addHandler : function( type, handler )
     94                {
     95                        this._.handlers[ type ] = handler;
     96                }
     97        };
    9398
    94 CKEDITOR.event.implementOn( CKEDITOR.ui );
     99        CKEDITOR.event.implementOn( CKEDITOR.ui );
     100})();
    95101
    96102/**
    97103 * (Virtual Class) Do not call this constructor. This class is not really part
  • _source/plugins/dialog/plugin.js

     
    3333
    3434(function()
    3535{
     36        // Don't initialize twice #7588
     37        if ( CKEDITOR.dialog )
     38                return;
     39
    3640        var cssLength = CKEDITOR.tools.cssLength;
    3741        function isTabVisible( tabId )
    3842        {
  • _source/plugins/dialogui/plugin.js

     
    99
    1010(function()
    1111{
     12        // Don't initialize twice #7588
     13        if ( CKEDITOR.ui.dialog && CKEDITOR.ui.dialog.labeledElement )
     14                return;
     15
    1216        var initPrivateObject = function( elementDefinition )
    1317        {
    1418                this._ || ( this._ = {} );
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy