X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fdialog%2Fplugin.js;h=eee4916bd47f96b2eac1b1a9be4680956a8653a7;hb=2f22c0c38f17e75be5541089076885442aaa2377;hp=b5aab8182c2060c5e27b7863ba76f6b848dce35b;hpb=9afde8772159bd3436f1f5b7862960307710ae5a;p=ckeditor.git diff --git a/_source/plugins/dialog/plugin.js b/_source/plugins/dialog/plugin.js index b5aab81..eee4916 100644 --- a/_source/plugins/dialog/plugin.js +++ b/_source/plugins/dialog/plugin.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -93,6 +93,36 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; } } + // Handle dialog element validation state UI changes. + function handleFieldValidated( isValid, msg ) + { + var input = this.getInputElement(); + if ( input ) + { + isValid ? input.removeAttribute( 'aria-invalid' ) + : input.setAttribute( 'aria-invalid', true ); + } + + if ( !isValid ) + { + if ( this.select ) + this.select(); + else + this.focus(); + } + + msg && alert( msg ); + + this.fire( 'validated', { valid : isValid, msg : msg } ); + } + + function resetField() + { + var input = this.getInputElement(); + input && input.removeAttribute( 'aria-invalid' ); + } + + /** * This is the base class for runtime dialog objects. An instance of this * class represents a single named dialog for a single editor instance. @@ -108,7 +138,10 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; var definition = CKEDITOR.dialog._.dialogDefinitions[ dialogName ], defaultDefinition = CKEDITOR.tools.clone( defaultDialogDefinition ), buttonsOrder = editor.config.dialog_buttonsOrder || 'OS', - dir = editor.lang.dir; + dir = editor.lang.dir, + tabsToRemove = {}, + i, + processed; if ( ( buttonsOrder == 'OS' && CKEDITOR.env.mac ) || // The buttons in MacOS Apps are in reverse order (#4750) ( buttonsOrder == 'rtl' && dir == 'ltr' ) || @@ -167,13 +200,15 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; // Set the startup styles for the dialog, avoiding it enlarging the // page size on the dialog creation. - this.parts.dialog.setStyles( - { + var startStyles = { position : CKEDITOR.env.ie6Compat ? 'absolute' : 'fixed', top : 0, - left: 0, visibility : 'hidden' - }); + }; + + startStyles[ dir == 'rtl' ? 'right' : 'left' ] = 0; + this.parts.dialog.setStyles( startStyles ); + // Call the CKEDITOR.event constructor to initialize this instance. CKEDITOR.event.call( this ); @@ -187,7 +222,6 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; } , editor ).definition; - var tabsToRemove = {}; // Cache tabs that should be removed. if ( !( 'removeDialogTabs' in editor._ ) && editor.config.removeDialogTabs ) { @@ -271,25 +305,17 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; { if ( item.validate ) { - var isValid = item.validate( this ); - - if ( typeof isValid == 'string' ) - { - alert( isValid ); - isValid = false; - } + var retval = item.validate( this ), + invalid = typeof ( retval ) == 'string' || retval === false; - if ( isValid === false ) + if ( invalid ) { - if ( item.select ) - item.select(); - else - item.focus(); - evt.data.hide = false; evt.stop(); - return true; } + + handleFieldValidated.call( item, !invalid, typeof retval == 'string' ? retval : undefined ); + return invalid; } }); }, this, null, 0 ); @@ -334,10 +360,11 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; focusList[ i ].focusIndex = i; } - function changeFocus( forward ) + function changeFocus( offset ) { - var focusList = me._.focusList, - offset = forward ? 1 : -1; + var focusList = me._.focusList; + offset = offset || 0; + if ( focusList.length < 1 ) return; @@ -353,12 +380,13 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; var startIndex = ( current + offset + focusList.length ) % focusList.length, currentIndex = startIndex; - while ( !focusList[ currentIndex ].isFocusable() ) + while ( offset && !focusList[ currentIndex ].isFocusable() ) { currentIndex = ( currentIndex + offset + focusList.length ) % focusList.length; if ( currentIndex == startIndex ) break; } + focusList[ currentIndex ].focus(); // Select whole field content. @@ -368,7 +396,6 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; this.changeFocus = changeFocus; - var processed; function focusKeydownHandler( evt ) { @@ -395,7 +422,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; else { // Change the focus of inputs. - changeFocus( !shiftPressed ); + changeFocus( shiftPressed ? -1 : 1 ); } processed = 1; @@ -420,7 +447,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; this.selectPage( this._.currentTabId ); this._.tabBarMode = false; this._.currentFocusIndex = -1; - changeFocus( true ); + changeFocus( 1 ); processed = 1; } @@ -452,6 +479,9 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; dialogElement.removeListener( 'keydown', focusKeydownHandler ); if ( CKEDITOR.env.opera || ( CKEDITOR.env.gecko && CKEDITOR.env.mac ) ) dialogElement.removeListener( 'keypress', focusKeyPressHandler ); + + // Reset fields state when closing dialog. + iterContents( function( item ) { resetField.apply( item ); } ); } ); this.on( 'iframeAdded', function( evt ) { @@ -485,7 +515,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; } // Focus the first field in layout order. else - changeFocus( true ); + changeFocus( 1 ); /* * IE BUG: If the initial focus went into a non-text element (e.g. button), @@ -531,7 +561,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; ( new CKEDITOR.dom.text( definition.title, CKEDITOR.document ) ).appendTo( this.parts.title ); // Insert the tabs and contents. - for ( var i = 0 ; i < definition.contents.length ; i++ ) + for ( i = 0 ; i < definition.contents.length ; i++ ) { var page = definition.contents[i]; page && this.addPage( page ); @@ -551,7 +581,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; { this._.tabBarMode = false; this._.currentFocusIndex = -1; - changeFocus( true ); + changeFocus( 1 ); } evt.data.preventDefault(); } @@ -635,6 +665,18 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; height : height }, this._.editor ); + this.fire( 'resize', + { + skin : this._.editor.skinName, + width : width, + height : height + }, this._.editor ); + + // Update dialog position when dimension get changed in RTL. + if ( this._.editor.lang.dir == 'rtl' && this._.position ) + this._.position.x = CKEDITOR.document.getWindow().getViewPaneSize().width - + this._.contentSize.width - parseInt( this._.element.getFirst().getStyle( 'right' ), 10 ); + this._.contentSize = { width : width, height : height }; }; })(), @@ -667,7 +709,9 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; { // The dialog may be fixed positioned or absolute positioned. Ask the // browser what is the current situation first. - var element = this._.element.getFirst(); + var element = this._.element.getFirst(), + rtl = this._.editor.lang.dir == 'rtl'; + if ( isFixed === undefined ) isFixed = element.getComputedStyle( 'position' ) == 'fixed'; @@ -685,11 +729,18 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; y += scrollPosition.y; } - element.setStyles( - { - 'left' : ( x > 0 ? x : 0 ) + 'px', - 'top' : ( y > 0 ? y : 0 ) + 'px' - }); + // Translate coordinate for RTL. + if ( rtl ) + { + var dialogSize = this.getSize(), + viewPaneSize = CKEDITOR.document.getWindow().getViewPaneSize(); + x = viewPaneSize.width - dialogSize.width - x; + } + + var styles = { 'top' : ( y > 0 ? y : 0 ) + 'px' }; + styles[ rtl ? 'right' : 'left' ] = ( x > 0 ? x : 0 ) + 'px'; + + element.setStyles( styles ); save && ( this._.moved = 1 ); }; @@ -710,13 +761,6 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; */ show : function() { - var editor = this._.editor; - if ( editor.mode == 'wysiwyg' && CKEDITOR.env.ie ) - { - var selection = editor.getSelection(); - selection && selection.lock(); - } - // Insert the dialog's element to the root document. var element = this._.element; var definition = this.definition; @@ -738,8 +782,8 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; // First, set the dialog to an appropriate size. - this.resize( this._.contentSize && this._.contentSize.width || definition.minWidth, - this._.contentSize && this._.contentSize.height || definition.minHeight ); + this.resize( this._.contentSize && this._.contentSize.width || definition.width || definition.minWidth, + this._.contentSize && this._.contentSize.height || definition.height || definition.minHeight ); // Reset all inputs back to their default value. this.reset(); @@ -753,19 +797,12 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; this._.element.getFirst().setStyle( 'z-index', CKEDITOR.dialog._.currentZIndex += 10 ); // Maintain the dialog ordering and dialog cover. - // Also register key handlers if first dialog. if ( CKEDITOR.dialog._.currentTop === null ) { CKEDITOR.dialog._.currentTop = this; this._.parentDialog = null; showCover( this._.editor ); - element.on( 'keydown', accessKeyDownHandler ); - element.on( CKEDITOR.env.opera ? 'keypress' : 'keyup', accessKeyUpHandler ); - - // Prevent some keys from bubbling up. (#4269) - for ( var event in { keyup :1, keydown :1, keypress :1 } ) - element.on( event, preventKeyBubbling ); } else { @@ -775,10 +812,25 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; CKEDITOR.dialog._.currentTop = this; } + element.on( 'keydown', accessKeyDownHandler ); + element.on( CKEDITOR.env.opera ? 'keypress' : 'keyup', accessKeyUpHandler ); + + // Prevent some keys from bubbling up. (#4269) + for ( var event in { keyup :1, keydown :1, keypress :1 } ) + element.on( event, preventKeyBubbling ); + // Register the Esc hotkeys. registerAccessKey( this, this, '\x1b', null, function() { - this.getButton( 'cancel' ) && this.getButton( 'cancel' ).click(); + var button = this.getButton( 'cancel' ); + // If there's a Cancel button, click it, else just fire the cancel event and hide the dialog + if ( button ) + button.click(); + else + { + if ( this.fire( 'cancel', { hide : true } ).hide !== false ) + this.hide(); + } } ); // Reset the hasFocus state. @@ -826,7 +878,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; for ( var i in this._.contents ) { for ( var j in this._.contents[i] ) - fn( this._.contents[i][j] ); + fn.call( this, this._.contents[i][j] ); } return this; }, @@ -843,6 +895,16 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; return function(){ this.foreach( fn ); return this; }; })(), + + /** + * Calls the {@link CKEDITOR.dialog.definition.uiElement#setup} method of each of the UI elements, with the arguments passed through it. + * It is usually being called when the dialog is opened, to put the initial value inside the field. + * @example + * dialogObj.setupContent(); + * @example + * var timestamp = ( new Date() ).valueOf(); + * dialogObj.setupContent( timestamp ); + */ setupContent : function() { var args = arguments; @@ -853,11 +915,24 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; }); }, + /** + * Calls the {@link CKEDITOR.dialog.definition.uiElement#commit} method of each of the UI elements, with the arguments passed through it. + * It is usually being called when the user confirms the dialog, to process the values. + * @example + * dialogObj.commitContent(); + * @example + * var timestamp = ( new Date() ).valueOf(); + * dialogObj.commitContent( timestamp ); + */ commitContent : function() { var args = arguments; this.foreach( function( widget ) { + // Make sure IE triggers "change" event on last focused input before closing the dialog. (#7915) + if ( CKEDITOR.env.ie && this._.currentFocusIndex == widget.focusIndex ) + widget.getInputElement().$.blur(); + if ( widget.commit ) widget.commit.apply( widget, args ); }); @@ -942,7 +1017,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; children : contents.elements, expand : !!contents.expand, padding : contents.padding, - style : contents.style || 'width: 100%;' + style : contents.style || 'width: 100%;height:100%' }, pageHtml ); // Create the HTML for the tab and the content block. @@ -1123,6 +1198,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; * @param {String} pageId id of dialog page. * @param {String} elementId id of UI element. * @example + * dialogObj.getContentElement( 'tabId', 'elementId' ).setValue( 'Example' ); * @returns {CKEDITOR.ui.dialog.uiElement} The dialog UI element. */ getContentElement : function( pageId, elementId ) @@ -1136,6 +1212,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; * @param {String} pageId id of dialog page. * @param {String} elementId id of UI element. * @example + * alert( dialogObj.getValueOf( 'tabId', 'elementId' ) ); * @returns {Object} The value of the UI element. */ getValueOf : function( pageId, elementId ) @@ -1149,6 +1226,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; * @param {String} elementId id of the UI element. * @param {Object} value The new value of the UI element. * @example + * dialogObj.setValueOf( 'tabId', 'elementId', 'Example' ); */ setValueOf : function( pageId, elementId, value ) { @@ -1256,9 +1334,77 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; * @param {Function|String} dialogDefinition * A function returning the dialog's definition, or the URL to the .js file holding the function. * The function should accept an argument "editor" which is the current editor instance, and - * return an object conforming to {@link CKEDITOR.dialog.dialogDefinition}. + * return an object conforming to {@link CKEDITOR.dialog.definition}. + * @see CKEDITOR.dialog.definition * @example - * @see CKEDITOR.dialog.dialogDefinition + * // Full sample plugin, which does not only register a dialog window but also adds an item to the context menu. + * // To open the dialog window, choose "Open dialog" in the context menu. + * CKEDITOR.plugins.add( 'myplugin', + * { + * init: function( editor ) + * { + * editor.addCommand( 'mydialog',new CKEDITOR.dialogCommand( 'mydialog' ) ); + * + * if ( editor.contextMenu ) + * { + * editor.addMenuGroup( 'mygroup', 10 ); + * editor.addMenuItem( 'My Dialog', + * { + * label : 'Open dialog', + * command : 'mydialog', + * group : 'mygroup' + * }); + * editor.contextMenu.addListener( function( element ) + * { + * return { 'My Dialog' : CKEDITOR.TRISTATE_OFF }; + * }); + * } + * + * CKEDITOR.dialog.add( 'mydialog', function( api ) + * { + * // CKEDITOR.dialog.definition + * var dialogDefinition = + * { + * title : 'Sample dialog', + * minWidth : 390, + * minHeight : 130, + * contents : [ + * { + * id : 'tab1', + * label : 'Label', + * title : 'Title', + * expand : true, + * padding : 0, + * elements : + * [ + * { + * type : 'html', + * html : '<p>This is some sample HTML content.</p>' + * }, + * { + * type : 'textarea', + * id : 'textareaId', + * rows : 4, + * cols : 40 + * } + * ] + * } + * ], + * buttons : [ CKEDITOR.dialog.okButton, CKEDITOR.dialog.cancelButton ], + * onOk : function() { + * // "this" is now a CKEDITOR.dialog object. + * // Accessing dialog elements: + * var textareaObj = this.getContentElement( 'tab1', 'textareaId' ); + * alert( "You have entered: " + textareaObj.getValue() ); + * } + * }; + * + * return dialogDefinition; + * } ); + * } + * } ); + * + * CKEDITOR.replace( 'editor1', { extraPlugins : 'myplugin' } ); */ add : function( name, dialogDefinition ) { @@ -1449,8 +1595,8 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; * This class is not really part of the API. It is the "definition" property value * passed to "dialogDefinition" event handlers. * @constructor - * @name CKEDITOR.dialog.dialogDefinitionObject - * @extends CKEDITOR.dialog.dialogDefinition + * @name CKEDITOR.dialog.definitionObject + * @extends CKEDITOR.dialog.definition * @example * CKEDITOR.on( 'dialogDefinition', function( evt ) * { @@ -1473,12 +1619,12 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; }; definitionObject.prototype = - /** @lends CKEDITOR.dialog.dialogDefinitionObject.prototype */ + /** @lends CKEDITOR.dialog.definitionObject.prototype */ { /** * Gets a content definition. * @param {String} id The id of the content definition. - * @returns {CKEDITOR.dialog.contentDefinition} The content definition + * @returns {CKEDITOR.dialog.definition.content} The content definition * matching id. */ getContents : function( id ) @@ -1489,7 +1635,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; /** * Gets a button definition. * @param {String} id The id of the button definition. - * @returns {CKEDITOR.dialog.buttonDefinition} The button definition + * @returns {CKEDITOR.dialog.definition.button} The button definition * matching id. */ getButton : function( id ) @@ -1499,13 +1645,13 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; /** * Adds a content definition object under this dialog definition. - * @param {CKEDITOR.dialog.contentDefinition} contentDefinition The + * @param {CKEDITOR.dialog.definition.content} contentDefinition The * content definition. * @param {String} [nextSiblingId] The id of an existing content * definition which the new content definition will be inserted * before. Omit if the new content definition is to be inserted as * the last item. - * @returns {CKEDITOR.dialog.contentDefinition} The inserted content + * @returns {CKEDITOR.dialog.definition.content} The inserted content * definition. */ addContents : function( contentDefinition, nextSiblingId ) @@ -1515,13 +1661,13 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; /** * Adds a button definition object under this dialog definition. - * @param {CKEDITOR.dialog.buttonDefinition} buttonDefinition The + * @param {CKEDITOR.dialog.definition.button} buttonDefinition The * button definition. * @param {String} [nextSiblingId] The id of an existing button * definition which the new button definition will be inserted * before. Omit if the new button definition is to be inserted as * the last item. - * @returns {CKEDITOR.dialog.buttonDefinition} The inserted button + * @returns {CKEDITOR.dialog.definition.button} The inserted button * definition. */ addButton : function( buttonDefinition, nextSiblingId ) @@ -1532,7 +1678,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; /** * Removes a content definition from this dialog definition. * @param {String} id The id of the content definition to be removed. - * @returns {CKEDITOR.dialog.contentDefinition} The removed content + * @returns {CKEDITOR.dialog.definition.content} The removed content * definition. */ removeContents : function( id ) @@ -1543,7 +1689,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; /** * Removes a button definition from the dialog definition. * @param {String} id The id of the button definition to be removed. - * @returns {CKEDITOR.dialog.buttonDefinition} The removed button + * @returns {CKEDITOR.dialog.definition.button} The removed button * definition. */ removeButton : function( id ) @@ -1555,9 +1701,9 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; /** * This class is not really part of the API. It is the template of the * objects representing content pages inside the - * CKEDITOR.dialog.dialogDefinitionObject. + * CKEDITOR.dialog.definitionObject. * @constructor - * @name CKEDITOR.dialog.contentDefinitionObject + * @name CKEDITOR.dialog.definition.contentObject * @example * CKEDITOR.on( 'dialogDefinition', function( evt ) * { @@ -1578,12 +1724,12 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; } contentObject.prototype = - /** @lends CKEDITOR.dialog.contentDefinitionObject.prototype */ + /** @lends CKEDITOR.dialog.definition.contentObject.prototype */ { /** * Gets a UI element definition under the content definition. * @param {String} id The id of the UI element definition. - * @returns {CKEDITOR.dialog.uiElementDefinition} + * @returns {CKEDITOR.dialog.definition.uiElement} */ get : function( id ) { @@ -1592,13 +1738,13 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; /** * Adds a UI element definition to the content definition. - * @param {CKEDITOR.dialog.uiElementDefinition} elementDefinition The + * @param {CKEDITOR.dialog.definition.uiElement} elementDefinition The * UI elemnet definition to be added. * @param {String} nextSiblingId The id of an existing UI element * definition which the new UI element definition will be inserted * before. Omit if the new button definition is to be inserted as * the last item. - * @returns {CKEDITOR.dialog.uiElementDefinition} The element + * @returns {CKEDITOR.dialog.definition.uiElement} The element * definition inserted. */ add : function( elementDefinition, nextSiblingId ) @@ -1610,7 +1756,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; * Removes a UI element definition from the content definition. * @param {String} id The id of the UI element definition to be * removed. - * @returns {CKEDITOR.dialog.uiElementDefinition} The element + * @returns {CKEDITOR.dialog.definition.uiElement} The element * definition removed. * @example */ @@ -1706,25 +1852,24 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; return; var editor = dialog.getParentEditor(); - var wrapperWidth, wrapperHeight, viewSize, origin, startSize; - - function positionDialog( right ) - { - // Maintain righthand sizing in RTL. - if ( dialog._.moved && editor.lang.dir == 'rtl' ) - { - var element = dialog._.element.getFirst(); - element.setStyle( 'right', right + "px" ); - element.removeStyle( 'left' ); - } - else if ( !dialog._.moved ) - dialog.layout(); - } + var wrapperWidth, wrapperHeight, + viewSize, origin, startSize, + dialogCover; var mouseDownFn = CKEDITOR.tools.addFunction( function( $event ) { startSize = dialog.getSize(); + var content = dialog.parts.contents, + iframeDialog = content.$.getElementsByTagName( 'iframe' ).length; + + // Shim to help capturing "mousemove" over iframe. + if ( iframeDialog ) + { + dialogCover = CKEDITOR.dom.element.createFromHtml( '
' ); + content.append( dialogCover ); + } + // Calculate the offset between content and chrome size. wrapperHeight = startSize.height - dialog.parts.contents.getSize( 'height', ! ( CKEDITOR.env.gecko || CKEDITOR.env.opera || CKEDITOR.env.ie && CKEDITOR.env.quirks ) ); wrapperWidth = startSize.width - dialog.parts.contents.getSize( 'width', 1 ); @@ -1754,7 +1899,8 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; direction = ' cke_resizer_horizontal'; else if ( resizable == CKEDITOR.DIALOG_RESIZE_HEIGHT ) direction = ' cke_resizer_vertical'; - var resizer = CKEDITOR.dom.element.createFromHtml( '
' ); dialog.parts.footer.append( resizer, 1 ); @@ -1774,10 +1920,6 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; right = rtl && element.getComputedStyle( 'right' ), position = dialog.getPosition(); - // IE might return "auto", we need exact position. - if ( right ) - right = right == 'auto' ? viewSize.width - ( position.x || 0 ) - element.getSize( 'width' ) : parseInt( right, 10 ); - if ( position.y + internalHeight > viewSize.height ) internalHeight = viewSize.height - position.y; @@ -1785,15 +1927,16 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; internalWidth = viewSize.width - ( rtl ? right : position.x ); // Make sure the dialog will not be resized to the wrong side when it's in the leftmost position for RTL. - if ( ( resizable == CKEDITOR.DIALOG_RESIZE_WIDTH || resizable == CKEDITOR.DIALOG_RESIZE_BOTH ) && !( rtl && dx > 0 && !position.x ) ) + if ( ( resizable == CKEDITOR.DIALOG_RESIZE_WIDTH || resizable == CKEDITOR.DIALOG_RESIZE_BOTH ) ) width = Math.max( def.minWidth || 0, internalWidth - wrapperWidth ); if ( resizable == CKEDITOR.DIALOG_RESIZE_HEIGHT || resizable == CKEDITOR.DIALOG_RESIZE_BOTH ) height = Math.max( def.minHeight || 0, internalHeight - wrapperHeight ); dialog.resize( width, height ); - // The right property might get broken during resizing, so computing it before the resizing. - positionDialog( right ); + + if ( !dialog._.moved ) + dialog.layout(); evt.data.preventDefault(); } @@ -1803,30 +1946,18 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; CKEDITOR.document.removeListener( 'mouseup', mouseUpHandler ); CKEDITOR.document.removeListener( 'mousemove', mouseMoveHandler ); + if ( dialogCover ) + { + dialogCover.remove(); + dialogCover = null; + } + if ( CKEDITOR.env.ie6Compat ) { var coverDoc = currentCover.getChild( 0 ).getFrameDocument(); coverDoc.removeListener( 'mouseup', mouseUpHandler ); coverDoc.removeListener( 'mousemove', mouseMoveHandler ); } - - // Switch back to use the left property, if RTL is used. - if ( editor.lang.dir == 'rtl' ) - { - var element = dialog._.element.getFirst(), - left = element.getComputedStyle( 'left' ); - - // IE might return "auto", we need exact position. - if ( left == 'auto' ) - left = viewSize.width - parseInt( element.getStyle( 'right' ), 10 ) - dialog.getSize().width; - else - left = parseInt( left, 10 ); - - element.removeStyle( 'right' ); - // Make sure the left property gets applied, even if it is the same as previously. - dialog._.position.x += 1; - dialog.move( left, dialog._.position.y ); - } } } @@ -1836,6 +1967,11 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; var covers = {}, currentCover; + function cancelEvent( ev ) + { + ev.data.preventDefault(1); + } + function showCover( editor ) { var win = CKEDITOR.document.getWindow(); @@ -1852,7 +1988,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; if ( !coverElement ) { var html = [ - '
', childHtmlList[i], '' ); @@ -2317,7 +2506,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; * objects in childObjList. * @param {Array} htmlList * Array of HTML code that this element will output to. - * @param {CKEDITOR.dialog.uiElementDefinition} elementDefinition + * @param {CKEDITOR.dialog.definition.uiElement} elementDefinition * The element definition. Accepted fields: *