Ticket #4797: 4797_4.patch

File 4797_4.patch, 6.1 KB (added by Garry Yao, 14 years ago)
  • _source/core/tools.js

     
    691691                                catch (e) {}
    692692                        }
    693693                        return returnValue;
     694                },
     695
     696                /**
     697                 * Generate a combined key from a series of params.
     698                 * @param {String} subKey One or more string used as sub keys.
     699                 * @example
     700                 * var key = CKEDITOR.tools.genKey( 'key1', 'key2', 'key3' );
     701                 * alert( key );                // "key1-key2-key3".
     702                 */
     703                genKey : function()
     704                {
     705                        return Array.prototype.slice.call( arguments ).join( '-' );
    694706                }
    695707        };
    696708})();
  • _source/plugins/dialog/plugin.js

     
    545545        {
    546546                destroy : function()
    547547                {
     548                        this.hide();
    548549                        this._.element.remove();
    549550                },
    550551
     
    698699                        {
    699700                                CKEDITOR.dialog._.currentTop = this;
    700701                                this._.parentDialog = null;
    701                                 addCover( this._.editor );
     702                                showCover( this._.editor );
    702703
    703704                                element.on( 'keydown', accessKeyDownHandler );
    704705                                element.on( CKEDITOR.env.opera ? 'keypress' : 'keyup', accessKeyUpHandler );
     
    711712                        {
    712713                                this._.parentDialog = CKEDITOR.dialog._.currentTop;
    713714                                var parentElement = this._.parentDialog.getElement().getFirst();
    714                                 parentElement.$.style.zIndex  -= Math.floor( this._.editor.config.baseFloatZIndex / 2 );
    715715                                CKEDITOR.dialog._.currentTop = this;
    716716                        }
    717717
     
    802802                 */
    803803                hide : function()
    804804                {
     805                        if ( !this.parts.dialog.isVisible() )
     806                                return;
     807
    805808                        this.fire( 'hide', {} );
    806809                        this._.editor.fire( 'dialogHide', this );
    807810                        var element = this._.element;
     
    810813                        // Unregister all access keys associated with this dialog.
    811814                        unregisterAccessKey( this );
    812815
     816                        // Close any child(top) dialogs first.
     817                        while( CKEDITOR.dialog._.currentTop != this )
     818                                CKEDITOR.dialog._.currentTop.hide();
     819
    813820                        // Maintain dialog ordering and remove cover if needed.
    814821                        if ( !this._.parentDialog )
    815                                 removeCover();
    816                         else
    817                         {
    818                                 var parentElement = this._.parentDialog.getElement().getFirst();
    819                                 parentElement.setStyle( 'z-index', parseInt( parentElement.$.style.zIndex, 10 ) + Math.floor( this._.editor.config.baseFloatZIndex / 2 ) );
    820                         }
     822                                hideCover();
     823
    821824                        CKEDITOR.dialog._.currentTop = this._.parentDialog;
    822825
    823826                        // Deduct or clear the z-index.
     
    845848                        else
    846849                                CKEDITOR.dialog._.currentZIndex -= 10;
    847850
    848 
     851                        delete this._.parentDialog;
    849852                        // Reset the initial values of the dialog.
    850853                        this.foreach( function( contentObj ) { contentObj.resetInitValue && contentObj.resetInitValue(); } );
    851854                },
     
    17491752        }
    17501753
    17511754        var resizeCover;
    1752         var coverElement;
     1755        // Caching resuable covers and allowing only one cover
     1756        // on screen.
     1757        var covers = {},
     1758                currentCover;
    17531759
    1754         var addCover = function( editor )
     1760        function showCover( editor )
    17551761        {
    17561762                var win = CKEDITOR.document.getWindow();
     1763                var backgroundColorStyle = editor.config.dialog_backgroundCoverColor || 'white',
     1764                        baseFloatZIndex = editor.config.baseFloatZIndex,
     1765                        coverKey = CKEDITOR.tools.genKey( backgroundColorStyle, baseFloatZIndex ),
     1766                        coverElement = covers[ coverKey ];
    17571767
    17581768                if ( !coverElement )
    17591769                {
    1760                         var backgroundColorStyle = editor.config.dialog_backgroundCoverColor || 'white';
    1761 
    17621770                        var html = [
    17631771                                        '<div style="position: ', ( CKEDITOR.env.ie6Compat ? 'absolute' : 'fixed' ),
    1764                                         '; z-index: ', editor.config.baseFloatZIndex,
     1772                                        '; z-index: ', baseFloatZIndex,
    17651773                                        '; top: 0px; left: 0px; ',
    17661774                                        ( !CKEDITOR.env.ie6Compat ? 'background-color: ' + backgroundColorStyle : '' ),
    1767                                         '" id="cke_dialog_background_cover">'
     1775                                        '" class="cke_dialog_background_cover">'
    17681776                                ];
    17691777
    17701778
     
    18031811                        html.push( '</div>' );
    18041812
    18051813                        coverElement = CKEDITOR.dom.element.createFromHtml( html.join( '' ) );
     1814                        covers[ coverKey ] = coverElement;
    18061815                }
     1816                else
     1817                        coverElement.   show();
    18071818
    1808                 var element = coverElement;
    1809 
     1819                currentCover = coverElement;
    18101820                var resizeFunc = function()
    18111821                {
    18121822                        var size = win.getViewPaneSize();
    1813                         element.setStyles(
     1823                        coverElement.setStyles(
    18141824                                {
    18151825                                        width : size.width + 'px',
    18161826                                        height : size.height + 'px'
     
    18211831                {
    18221832                        var pos = win.getScrollPosition(),
    18231833                                cursor = CKEDITOR.dialog._.currentTop;
    1824                         element.setStyles(
     1834                        coverElement.setStyles(
    18251835                                        {
    18261836                                                left : pos.x + 'px',
    18271837                                                top : pos.y + 'px'
     
    18551865                }
    18561866
    18571867                var opacity = editor.config.dialog_backgroundCoverOpacity;
    1858                 element.setOpacity( typeof opacity != 'undefined' ? opacity : 0.5 );
     1868                coverElement.setOpacity( typeof opacity != 'undefined' ? opacity : 0.5 );
    18591869
    1860                 element.appendTo( CKEDITOR.document.getBody() );
     1870                coverElement.appendTo( CKEDITOR.document.getBody() );
    18611871        };
    18621872
    1863         var removeCover = function()
     1873        function hideCover()
    18641874        {
    1865                 if ( !coverElement )
     1875                if ( !currentCover )
    18661876                        return;
    18671877
    18681878                var win = CKEDITOR.document.getWindow();
    1869                 coverElement.remove();
     1879                currentCover.hide();
    18701880                win.removeListener( 'resize', resizeCover );
    18711881
    18721882                if ( CKEDITOR.env.ie6Compat )
     
    18791889                }
    18801890                resizeCover = null;
    18811891        };
    1882 
     1892       
     1893        function removeCovers()
     1894        {
     1895                for ( var coverId in covers )
     1896                        covers[ coverId ].remove();
     1897                covers = {};
     1898        }
     1899
    18831900        var accessKeyProcessors = {};
    18841901
    18851902        var accessKeyDownHandler = function( evt )
     
    27812798
    27822799        CKEDITOR.on( 'instanceDestroyed', function( evt )
    27832800        {
     2801                // Remove dialog cover on last instance destroy.
     2802                if ( CKEDITOR.tools.isEmpty( CKEDITOR.instances ) )
     2803                {
     2804                        var currentTopDialog;
     2805                        while ( currentTopDialog = CKEDITOR.dialog._.currentTop )
     2806                                currentTopDialog.hide();
     2807                        removeCovers();
     2808                }
     2809
    27842810                var dialogs = evt.editor._.storedDialogs;
    27852811                for ( var name in dialogs )
    27862812                        dialogs[ name ].destroy();
    27872813
    2788                 // Remove dialog cover on last instance destroy.
    2789                 if ( CKEDITOR.tools.isEmpty( CKEDITOR.instances ) );
    2790                         coverElement.remove();
    27912814        });
    27922815
    27932816        })();
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy