Ticket #6390: 6390_4.patch

File 6390_4.patch, 6.3 KB (added by Garry Yao, 13 years ago)
  • _source/plugins/dialog/plugin.js

     
    710710                 */
    711711                show : function()
    712712                {
    713                         var editor = this._.editor;
    714                         if ( editor.mode == 'wysiwyg' && CKEDITOR.env.ie )
    715                         {
    716                                 var selection = editor.getSelection();
    717                                 selection && selection.lock();
    718                         }
    719 
    720713                        // Insert the dialog's element to the root document.
    721714                        var element = this._.element;
    722715                        var definition = this.definition;
     
    18521845                if ( !coverElement )
    18531846                {
    18541847                        var html = [
    1855                                         '<div style="position: ', ( CKEDITOR.env.ie6Compat ? 'absolute' : 'fixed' ),
     1848                                        '<div tabIndex="-1" style="position: ', ( CKEDITOR.env.ie6Compat ? 'absolute' : 'fixed' ),
    18561849                                        '; z-index: ', baseFloatZIndex,
    18571850                                        '; top: 0px; left: 0px; ',
    18581851                                        ( !CKEDITOR.env.ie6Compat ? 'background-color: ' + backgroundColorStyle : '' ),
     
    19331926                resizeCover = resizeFunc;
    19341927                win.on( 'resize', resizeFunc );
    19351928                resizeFunc();
     1929                coverElement.focus();
    19361930                if ( CKEDITOR.env.ie6Compat )
    19371931                {
    19381932                        // IE BUG: win.$.onscroll assignment doesn't work.. it must be window.onscroll.
     
    28962890        });
    28972891
    28982892        })();
    2899 })();
    29002893
    2901 // Extend the CKEDITOR.editor class with dialog specific functions.
    2902 CKEDITOR.tools.extend( CKEDITOR.editor.prototype,
    2903         /** @lends CKEDITOR.editor.prototype */
    2904         {
    2905                 /**
    2906                  * Loads and opens a registered dialog.
    2907                  * @param {String} dialogName The registered name of the dialog.
    2908                  * @param {Function} callback The function to be invoked after dialog instance created.
    2909                  * @see CKEDITOR.dialog.add
    2910                  * @example
    2911                  * CKEDITOR.instances.editor1.openDialog( 'smiley' );
    2912                  * @returns {CKEDITOR.dialog} The dialog object corresponding to the dialog displayed. null if the dialog name is not registered.
    2913                  */
    2914                 openDialog : function( dialogName, callback )
    2915                 {
    2916                         var dialogDefinitions = CKEDITOR.dialog._.dialogDefinitions[ dialogName ],
    2917                                         dialogSkin = this.skin.dialog;
     2894        // Extend the CKEDITOR.editor class with dialog specific functions.
     2895        CKEDITOR.tools.extend( CKEDITOR.editor.prototype,
     2896                /** @lends CKEDITOR.editor.prototype */
     2897                {
     2898                        /**
     2899                         * Loads and opens a registered dialog.
     2900                         * @param {String} dialogName The registered name of the dialog.
     2901                         * @param {Function} callback The function to be invoked after dialog instance created.
     2902                         * @see CKEDITOR.dialog.add
     2903                         * @example
     2904                         * CKEDITOR.instances.editor1.openDialog( 'smiley' );
     2905                         * @returns {CKEDITOR.dialog} The dialog object corresponding to the dialog displayed. null if the dialog name is not registered.
     2906                         */
     2907                        openDialog : function( dialogName, callback )
     2908                        {
     2909                                if ( this.mode == 'wysiwyg' && CKEDITOR.env.ie )
     2910                                {
     2911                                        var selection = this.getSelection();
     2912                                        selection && selection.lock();
     2913                                }
     2914
     2915                                var dialogDefinitions = CKEDITOR.dialog._.dialogDefinitions[ dialogName ],
     2916                                                dialogSkin = this.skin.dialog;
    29182917
    2919                         // If the dialogDefinition is already loaded, open it immediately.
    2920                         if ( typeof dialogDefinitions == 'function' && dialogSkin._isLoaded )
    2921                         {
    2922                                 var storedDialogs = this._.storedDialogs ||
    2923                                         ( this._.storedDialogs = {} );
     2918                                if ( CKEDITOR.dialog._.currentTop === null )
     2919                                        showCover( this );
     2920
     2921                                // If the dialogDefinition is already loaded, open it immediately.
     2922                                if ( typeof dialogDefinitions == 'function' && dialogSkin._isLoaded )
     2923                                {
     2924                                        var storedDialogs = this._.storedDialogs ||
     2925                                                ( this._.storedDialogs = {} );
    29242926
    2925                                 var dialog = storedDialogs[ dialogName ] ||
    2926                                         ( storedDialogs[ dialogName ] = new CKEDITOR.dialog( this, dialogName ) );
     2927                                        var dialog = storedDialogs[ dialogName ] ||
     2928                                                ( storedDialogs[ dialogName ] = new CKEDITOR.dialog( this, dialogName ) );
    29272929
    2928                                 callback && callback.call( dialog, dialog );
    2929                                 dialog.show();
     2930                                        callback && callback.call( dialog, dialog );
     2931                                        dialog.show();
    29302932
    2931                                 return dialog;
    2932                         }
    2933                         else if ( dialogDefinitions == 'failed' )
    2934                                 throw new Error( '[CKEDITOR.dialog.openDialog] Dialog "' + dialogName + '" failed when loading definition.' );
     2933                                        return dialog;
     2934                                }
     2935                                else if ( dialogDefinitions == 'failed' )
     2936                                        throw new Error( '[CKEDITOR.dialog.openDialog] Dialog "' + dialogName + '" failed when loading definition.' );
    29352937
    2936                         // Not loaded? Load the .js file first.
    2937                         var body = CKEDITOR.document.getBody(),
    2938                                 cursor = body.$.style.cursor,
    2939                                 me = this;
     2938                                var me = this;
    29402939
    2941                         body.setStyle( 'cursor', 'wait' );
    2942 
    2943                         function onDialogFileLoaded( success )
    2944                         {
    2945                                 var dialogDefinition = CKEDITOR.dialog._.dialogDefinitions[ dialogName ],
    2946                                                 skin = me.skin.dialog;
     2940                                function onDialogFileLoaded( success )
     2941                                {
     2942                                        var dialogDefinition = CKEDITOR.dialog._.dialogDefinitions[ dialogName ],
     2943                                                        skin = me.skin.dialog;
    29472944
    2948                                 // Check if both skin part and definition is loaded.
    2949                                 if ( !skin._isLoaded || loadDefinition && typeof success == 'undefined' )
    2950                                         return;
     2945                                        // Check if both skin part and definition is loaded.
     2946                                        if ( !skin._isLoaded || loadDefinition && typeof success == 'undefined' )
     2947                                                return;
    29512948
    2952                                 // In case of plugin error, mark it as loading failed.
    2953                                 if ( typeof dialogDefinition != 'function' )
    2954                                         CKEDITOR.dialog._.dialogDefinitions[ dialogName ] = 'failed';
     2949                                        // In case of plugin error, mark it as loading failed.
     2950                                        if ( typeof dialogDefinition != 'function' )
     2951                                                CKEDITOR.dialog._.dialogDefinitions[ dialogName ] = 'failed';
    29552952
    2956                                 me.openDialog( dialogName, callback );
    2957                                 body.setStyle( 'cursor', cursor );
    2958                         }
     2953                                        me.openDialog( dialogName, callback );
     2954                                }
    29592955
    2960                         if ( typeof dialogDefinitions == 'string' )
    2961                         {
    2962                                 var loadDefinition = 1;
    2963                                 CKEDITOR.scriptLoader.load( CKEDITOR.getUrl( dialogDefinitions ), onDialogFileLoaded );
    2964                         }
     2956                                if ( typeof dialogDefinitions == 'string' )
     2957                                {
     2958                                        var loadDefinition = 1;
     2959                                        CKEDITOR.scriptLoader.load( CKEDITOR.getUrl( dialogDefinitions ), onDialogFileLoaded, null, 0, 1 );
     2960                                }
    29652961
    2966                         CKEDITOR.skins.load( this, 'dialog', onDialogFileLoaded );
     2962                                CKEDITOR.skins.load( this, 'dialog', onDialogFileLoaded );
    29672963
    2968                         return null;
    2969                 }
    2970         });
     2964                                return null;
     2965                        }
     2966                });
     2967})();
    29712968
    29722969CKEDITOR.plugins.add( 'dialog',
    29732970        {
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy