X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fplugins%2Fdialog%2Fplugin.js;h=706c92b61f017e806f7888dfdaaab8fe362ef14e;hp=75067d6ad28cbf91765a50553f9cbcaa6ff00a63;hb=941b0a9ba4e673e292510d80a5a86806994b8ea6;hpb=7cd80714081a8ffdf4a1a8d2c72f120ed5ef3d6d diff --git a/_source/plugins/dialog/plugin.js b/_source/plugins/dialog/plugin.js index 75067d6..706c92b 100644 --- a/_source/plugins/dialog/plugin.js +++ b/_source/plugins/dialog/plugin.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -7,11 +7,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license * @fileOverview The floating dialog plugin. */ -CKEDITOR.plugins.add( 'dialog', - { - requires : [ 'dialogui' ] - }); - /** * No resize for this dialog. * @constant @@ -73,9 +68,6 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; return null; } - // Stores dialog related data from skin definitions. e.g. margin sizes. - var skinData = {}; - /** * This is the base class for runtime dialog objects. An instance of this * class represents a single named dialog for a single editor instance. @@ -679,6 +671,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; // Execute onLoad for the first show. this.fireOnce( 'load', {} ); this.fire( 'show', {} ); + this._.editor.fire( 'dialogShow', this ); // Save the initial values of the dialog. this.foreach( function( contentObj ) { contentObj.setInitValue && contentObj.setInitValue(); } ); @@ -742,6 +735,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; hide : function() { this.fire( 'hide', {} ); + this._.editor.fire( 'dialogHide', this ); // Remove the dialog's element from the root document. var element = this._.element; @@ -1454,7 +1448,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; element = dialog.getElement().getFirst(), editor = dialog.getParentEditor(), magnetDistance = editor.config.dialog_magnetDistance, - margins = skinData[ editor.skinName ].margins || [ 0, 0, 0, 0 ]; + margins = editor.skin.margins || [ 0, 0, 0, 0 ]; if ( typeof magnetDistance == 'undefined' ) magnetDistance = 20; @@ -1532,7 +1526,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; minWidth = definition.minWidth || 0, minHeight = definition.minHeight || 0, resizable = definition.resizable, - margins = skinData[ dialog.getParentEditor().skinName ].margins || [ 0, 0, 0, 0 ]; + margins = dialog.getParentEditor().skin.margins || [ 0, 0, 0, 0 ]; function topSizer( coords, dy ) { @@ -2692,17 +2686,6 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; } }; })(); - - // Grab the margin data from skin definition and store it away. - CKEDITOR.skins.add = ( function() - { - var original = CKEDITOR.skins.add; - return function( skinName, skinDefinition ) - { - skinData[ skinName ] = { margins : skinDefinition.margins }; - return original.apply( this, arguments ); - }; - } )(); })(); // Extend the CKEDITOR.editor class with dialog specific functions. @@ -2712,12 +2695,13 @@ CKEDITOR.tools.extend( CKEDITOR.editor.prototype, /** * Loads and opens a registered dialog. * @param {String} dialogName The registered name of the dialog. + * @param {Function} callback The function to be invoked after dialog instance created. * @see CKEDITOR.dialog.add * @example * CKEDITOR.instances.editor1.openDialog( 'smiley' ); * @returns {CKEDITOR.dialog} The dialog object corresponding to the dialog displayed. null if the dialog name is not registered. */ - openDialog : function( dialogName ) + openDialog : function( dialogName, callback ) { var dialogDefinitions = CKEDITOR.dialog._.dialogDefinitions[ dialogName ]; @@ -2730,6 +2714,7 @@ CKEDITOR.tools.extend( CKEDITOR.editor.prototype, var dialog = storedDialogs[ dialogName ] || ( storedDialogs[ dialogName ] = new CKEDITOR.dialog( this, dialogName ) ); + callback && callback.call( dialog, dialog ); dialog.show(); return dialog; @@ -2748,7 +2733,7 @@ CKEDITOR.tools.extend( CKEDITOR.editor.prototype, // In case of plugin error, mark it as loading failed. if ( typeof CKEDITOR.dialog._.dialogDefinitions[ dialogName ] != 'function' ) CKEDITOR.dialog._.dialogDefinitions[ dialogName ] = 'failed'; - me.openDialog( dialogName ); + me.openDialog( dialogName, callback ); body.setStyle( 'cursor', cursor ); } ); @@ -2756,6 +2741,11 @@ CKEDITOR.tools.extend( CKEDITOR.editor.prototype, } }); +CKEDITOR.plugins.add( 'dialog', + { + requires : [ 'dialogui' ] + }); + // Dialog related configurations. /**