Ticket #6390: 6390_3.patch

File 6390_3.patch, 6.6 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;
     
    758751                        {
    759752                                CKEDITOR.dialog._.currentTop = this;
    760753                                this._.parentDialog = null;
    761                                 showCover( this._.editor );
    762754
    763755                                element.on( 'keydown', accessKeyDownHandler );
    764756                                element.on( CKEDITOR.env.opera ? 'keypress' : 'keyup', accessKeyUpHandler );
     
    18521844                if ( !coverElement )
    18531845                {
    18541846                        var html = [
    1855                                         '<div style="position: ', ( CKEDITOR.env.ie6Compat ? 'absolute' : 'fixed' ),
     1847                                        '<div tabIndex="-1" style="position: ', ( CKEDITOR.env.ie6Compat ? 'absolute' : 'fixed' ),
    18561848                                        '; z-index: ', baseFloatZIndex,
    18571849                                        '; top: 0px; left: 0px; ',
    18581850                                        ( !CKEDITOR.env.ie6Compat ? 'background-color: ' + backgroundColorStyle : '' ),
     
    19331925                resizeCover = resizeFunc;
    19341926                win.on( 'resize', resizeFunc );
    19351927                resizeFunc();
     1928                coverElement.focus();
    19361929                if ( CKEDITOR.env.ie6Compat )
    19371930                {
    19381931                        // IE BUG: win.$.onscroll assignment doesn't work.. it must be window.onscroll.
     
    28962889        });
    28972890
    28982891        })();
    2899 })();
    29002892
    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;
     2893        // Extend the CKEDITOR.editor class with dialog specific functions.
     2894        CKEDITOR.tools.extend( CKEDITOR.editor.prototype,
     2895                /** @lends CKEDITOR.editor.prototype */
     2896                {
     2897                        /**
     2898                         * Loads and opens a registered dialog.
     2899                         * @param {String} dialogName The registered name of the dialog.
     2900                         * @param {Function} callback The function to be invoked after dialog instance created.
     2901                         * @see CKEDITOR.dialog.add
     2902                         * @example
     2903                         * CKEDITOR.instances.editor1.openDialog( 'smiley' );
     2904                         * @returns {CKEDITOR.dialog} The dialog object corresponding to the dialog displayed. null if the dialog name is not registered.
     2905                         */
     2906                        openDialog : function( dialogName, callback )
     2907                        {
     2908                                if ( this.mode == 'wysiwyg' && CKEDITOR.env.ie )
     2909                                {
     2910                                        var selection = this.getSelection();
     2911                                        selection && selection.lock();
     2912                                }
     2913
     2914                                var dialogDefinitions = CKEDITOR.dialog._.dialogDefinitions[ dialogName ],
     2915                                                dialogSkin = this.skin.dialog;
    29182916
    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 = {} );
     2917                                // If the dialogDefinition is already loaded, open it immediately.
     2918                                if ( typeof dialogDefinitions == 'function' && dialogSkin._isLoaded )
     2919                                {
     2920                                        var storedDialogs = this._.storedDialogs ||
     2921                                                ( this._.storedDialogs = {} );
    29242922
    2925                                 var dialog = storedDialogs[ dialogName ] ||
    2926                                         ( storedDialogs[ dialogName ] = new CKEDITOR.dialog( this, dialogName ) );
     2923                                        var dialog = storedDialogs[ dialogName ] ||
     2924                                                ( storedDialogs[ dialogName ] = new CKEDITOR.dialog( this, dialogName ) );
    29272925
    2928                                 callback && callback.call( dialog, dialog );
    2929                                 dialog.show();
     2926                                        callback && callback.call( dialog, dialog );
     2927                                        dialog.show();
    29302928
    2931                                 return dialog;
    2932                         }
    2933                         else if ( dialogDefinitions == 'failed' )
    2934                                 throw new Error( '[CKEDITOR.dialog.openDialog] Dialog "' + dialogName + '" failed when loading definition.' );
     2929                                        return dialog;
     2930                                }
     2931                                else if ( dialogDefinitions == 'failed' )
     2932                                        throw new Error( '[CKEDITOR.dialog.openDialog] Dialog "' + dialogName + '" failed when loading definition.' );
    29352933
    2936                         // Not loaded? Load the .js file first.
    2937                         var body = CKEDITOR.document.getBody(),
    2938                                 cursor = body.$.style.cursor,
    2939                                 me = this;
     2934                                var me = this;
    29402935
    2941                         body.setStyle( 'cursor', 'wait' );
    2942 
    2943                         function onDialogFileLoaded( success )
    2944                         {
    2945                                 var dialogDefinition = CKEDITOR.dialog._.dialogDefinitions[ dialogName ],
    2946                                                 skin = me.skin.dialog;
     2936                                function onDialogFileLoaded( success )
     2937                                {
     2938                                        var dialogDefinition = CKEDITOR.dialog._.dialogDefinitions[ dialogName ],
     2939                                                        skin = me.skin.dialog;
    29472940
    2948                                 // Check if both skin part and definition is loaded.
    2949                                 if ( !skin._isLoaded || loadDefinition && typeof success == 'undefined' )
    2950                                         return;
     2941                                        // Check if both skin part and definition is loaded.
     2942                                        if ( !skin._isLoaded || loadDefinition && typeof success == 'undefined' )
     2943                                                return;
    29512944
    2952                                 // In case of plugin error, mark it as loading failed.
    2953                                 if ( typeof dialogDefinition != 'function' )
    2954                                         CKEDITOR.dialog._.dialogDefinitions[ dialogName ] = 'failed';
     2945                                        // In case of plugin error, mark it as loading failed.
     2946                                        if ( typeof dialogDefinition != 'function' )
     2947                                                CKEDITOR.dialog._.dialogDefinitions[ dialogName ] = 'failed';
    29552948
    2956                                 me.openDialog( dialogName, callback );
    2957                                 body.setStyle( 'cursor', cursor );
    2958                         }
     2949                                        me.openDialog( dialogName, callback );
     2950                                }
    29592951
    2960                         if ( typeof dialogDefinitions == 'string' )
    2961                         {
    2962                                 var loadDefinition = 1;
    2963                                 CKEDITOR.scriptLoader.load( CKEDITOR.getUrl( dialogDefinitions ), onDialogFileLoaded );
    2964                         }
     2952                                if ( CKEDITOR.dialog._.currentTop === null )
     2953                                        showCover( this );
     2954
     2955                                if ( typeof dialogDefinitions == 'string' )
     2956                                {
     2957                                        var loadDefinition = 1;
     2958                                        CKEDITOR.scriptLoader.load( CKEDITOR.getUrl( dialogDefinitions ), onDialogFileLoaded, null, 0, 1 );
     2959                                }
    29652960
    2966                         CKEDITOR.skins.load( this, 'dialog', onDialogFileLoaded );
     2961                                CKEDITOR.skins.load( this, 'dialog', onDialogFileLoaded );
    29672962
    2968                         return null;
    2969                 }
    2970         });
     2963                                return null;
     2964                        }
     2965                });
     2966})();
    29712967
    29722968CKEDITOR.plugins.add( 'dialog',
    29732969        {
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy