Index: _source/core/tools.js =================================================================== --- _source/core/tools.js (revision 5403) +++ _source/core/tools.js (revision ) @@ -691,6 +691,18 @@ catch (e) {} } return returnValue; + }, + + /** + * Generate a combined key from a series of params. + * @param {String} subKey One or more string used as sub keys. + * @example + * var key = CKEDITOR.tools.genKey( 'key1', 'key2', 'key3' ); + * alert( key ); // "key1-key2-key3". + */ + genKey : function() + { + return Array.prototype.slice.call( arguments ).join( '-' ); } }; })(); Index: _source/plugins/dialog/plugin.js =================================================================== --- _source/plugins/dialog/plugin.js (revision 5412) +++ _source/plugins/dialog/plugin.js (revision ) @@ -545,6 +545,7 @@ { destroy : function() { + this.hide(); this._.element.remove(); }, @@ -698,7 +699,7 @@ { CKEDITOR.dialog._.currentTop = this; this._.parentDialog = null; - addCover( this._.editor ); + showCover( this._.editor ); element.on( 'keydown', accessKeyDownHandler ); element.on( CKEDITOR.env.opera ? 'keypress' : 'keyup', accessKeyUpHandler ); @@ -711,7 +712,6 @@ { this._.parentDialog = CKEDITOR.dialog._.currentTop; var parentElement = this._.parentDialog.getElement().getFirst(); - parentElement.$.style.zIndex -= Math.floor( this._.editor.config.baseFloatZIndex / 2 ); CKEDITOR.dialog._.currentTop = this; } @@ -802,6 +802,9 @@ */ hide : function() { + if ( !this.parts.dialog.isVisible() ) + return; + this.fire( 'hide', {} ); this._.editor.fire( 'dialogHide', this ); var element = this._.element; @@ -810,14 +813,14 @@ // Unregister all access keys associated with this dialog. unregisterAccessKey( this ); + // Close any child(top) dialogs first. + while( CKEDITOR.dialog._.currentTop != this ) + CKEDITOR.dialog._.currentTop.hide(); + // Maintain dialog ordering and remove cover if needed. if ( !this._.parentDialog ) - removeCover(); - else - { - var parentElement = this._.parentDialog.getElement().getFirst(); - parentElement.setStyle( 'z-index', parseInt( parentElement.$.style.zIndex, 10 ) + Math.floor( this._.editor.config.baseFloatZIndex / 2 ) ); - } + hideCover(); + CKEDITOR.dialog._.currentTop = this._.parentDialog; // Deduct or clear the z-index. @@ -845,7 +848,7 @@ else CKEDITOR.dialog._.currentZIndex -= 10; - + delete this._.parentDialog; // Reset the initial values of the dialog. this.foreach( function( contentObj ) { contentObj.resetInitValue && contentObj.resetInitValue(); } ); }, @@ -1749,22 +1752,27 @@ } var resizeCover; - var coverElement; + // Caching resuable covers and allowing only one cover + // on screen. + var covers = {}, + currentCover; - var addCover = function( editor ) + function showCover( editor ) { var win = CKEDITOR.document.getWindow(); + var backgroundColorStyle = editor.config.dialog_backgroundCoverColor || 'white', + baseFloatZIndex = editor.config.baseFloatZIndex, + coverKey = CKEDITOR.tools.genKey( backgroundColorStyle, baseFloatZIndex ), + coverElement = covers[ coverKey ]; if ( !coverElement ) { - var backgroundColorStyle = editor.config.dialog_backgroundCoverColor || 'white'; - var html = [ '