X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fdialog%2Fplugin.js;h=b5aab8182c2060c5e27b7863ba76f6b848dce35b;hb=9afde8772159bd3436f1f5b7862960307710ae5a;hp=5615b11db6c473ade07a0554934a702f78814f74;hpb=8665a7c6c60586526e32e8941fe2896739b6ebfb;p=ckeditor.git diff --git a/_source/plugins/dialog/plugin.js b/_source/plugins/dialog/plugin.js index 5615b11..b5aab81 100644 --- a/_source/plugins/dialog/plugin.js +++ b/_source/plugins/dialog/plugin.js @@ -33,6 +33,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; (function() { + var cssLength = CKEDITOR.tools.cssLength; function isTabVisible( tabId ) { return !!this._.tabs[ tabId ][ 0 ].$.offsetHeight; @@ -68,6 +69,30 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; return null; } + + function clearOrRecoverTextInputValue( container, isRecover ) + { + var inputs = container.$.getElementsByTagName( 'input' ); + for ( var i = 0, length = inputs.length; i < length ; i++ ) + { + var item = new CKEDITOR.dom.element( inputs[ i ] ); + + if ( item.getAttribute( 'type' ).toLowerCase() == 'text' ) + { + if ( isRecover ) + { + item.setAttribute( 'value', item.getCustomData( 'fake_value' ) || '' ); + item.removeCustomData( 'fake_value' ); + } + else + { + item.setCustomData( 'fake_value', item.getAttribute( 'value' ) ); + item.setAttribute( 'value', '' ); + } + } + } + } + /** * This is the base class for runtime dialog objects. An instance of this * class represents a single named dialog for a single editor instance. @@ -80,10 +105,19 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; CKEDITOR.dialog = function( editor, dialogName ) { // Load the dialog definition. - var definition = CKEDITOR.dialog._.dialogDefinitions[ dialogName ]; + var definition = CKEDITOR.dialog._.dialogDefinitions[ dialogName ], + defaultDefinition = CKEDITOR.tools.clone( defaultDialogDefinition ), + buttonsOrder = editor.config.dialog_buttonsOrder || 'OS', + dir = editor.lang.dir; + + if ( ( buttonsOrder == 'OS' && CKEDITOR.env.mac ) || // The buttons in MacOS Apps are in reverse order (#4750) + ( buttonsOrder == 'rtl' && dir == 'ltr' ) || + ( buttonsOrder == 'ltr' && dir == 'rtl' ) ) + defaultDefinition.buttons.reverse(); + // Completes the definition with the default values. - definition = CKEDITOR.tools.extend( definition( editor ), defaultDialogDefinition ); + definition = CKEDITOR.tools.extend( definition( editor ), defaultDefinition ); // Clone a functionally independent copy for this dialog. definition = CKEDITOR.tools.clone( definition ); @@ -92,7 +126,6 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; // functions. definition = new definitionObject( this, definition ); - var doc = CKEDITOR.document; var themeBuilt = editor.theme.buildDialog( editor ); @@ -105,7 +138,6 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; name : dialogName, contentSize : { width : 0, height : 0 }, size : { width : 0, height : 0 }, - updateSize : false, contents : {}, buttons : {}, accessKeyMap : {}, @@ -154,6 +186,34 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; definition : definition } , editor ).definition; + + var tabsToRemove = {}; + // Cache tabs that should be removed. + if ( !( 'removeDialogTabs' in editor._ ) && editor.config.removeDialogTabs ) + { + var removeContents = editor.config.removeDialogTabs.split( ';' ); + + for ( i = 0; i < removeContents.length; i++ ) + { + var parts = removeContents[ i ].split( ':' ); + if ( parts.length == 2 ) + { + var removeDialogName = parts[ 0 ]; + if ( !tabsToRemove[ removeDialogName ] ) + tabsToRemove[ removeDialogName ] = []; + tabsToRemove[ removeDialogName ].push( parts[ 1 ] ); + } + } + editor._.removeDialogTabs = tabsToRemove; + } + + // Remove tabs of this dialog. + if ( editor._.removeDialogTabs && ( tabsToRemove = editor._.removeDialogTabs[ dialogName ] ) ) + { + for ( i = 0; i < tabsToRemove.length; i++ ) + definition.removeContents( tabsToRemove[ i ] ); + } + // Initialize load, show, hide, ok and cancel events. if ( definition.onLoad ) this.on( 'load', definition.onLoad ); @@ -168,6 +228,9 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; { this.on( 'ok', function( evt ) { + // Dialog confirm might probably introduce content changes (#5415). + editor.fire( 'saveSnapshot' ); + setTimeout( function () { editor.fire( 'saveSnapshot' ); }, 0 ); if ( definition.onOk.call( this, evt ) === false ) evt.data.hide = false; }); @@ -404,7 +467,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; setupFocus(); if ( editor.config.dialog_startupFocusTab - && me._.tabIdList.length > 1 ) + && me._.pageCount > 1 ) { me._.tabBarMode = true; me._.tabs[ me._.currentTabId ][ 0 ].focus(); @@ -469,16 +532,21 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; // Insert the tabs and contents. for ( var i = 0 ; i < definition.contents.length ; i++ ) - this.addPage( definition.contents[i] ); + { + var page = definition.contents[i]; + page && this.addPage( page ); + } - this.parts['tabs'].on( 'click', function( evt ) + this.parts[ 'tabs' ].on( 'click', function( evt ) { var target = evt.data.getTarget(); // If we aren't inside a tab, bail out. if ( target.hasClass( 'cke_dialog_tab' ) ) { + // Get the ID of the tab, without the 'cke_' prefix and the unique number suffix. var id = target.$.id; - this.selectPage( id.substr( 0, id.lastIndexOf( '_' ) ) ); + this.selectPage( id.substring( 4, id.lastIndexOf( '_' ) ) ); + if ( this._.tabBarMode ) { this._.tabBarMode = false; @@ -568,7 +636,6 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; }, this._.editor ); this._.contentSize = { width : width, height : height }; - this._.updateSize = true; }; })(), @@ -580,15 +647,8 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; */ getSize : function() { - if ( !this._.updateSize ) - return this._.size; var element = this._.element.getFirst(); - var size = this._.size = { width : element.$.offsetWidth || 0, height : element.$.offsetHeight || 0}; - - // If either the offsetWidth or offsetHeight is 0, the element isn't visible. - this._.updateSize = !size.width || !size.height; - - return size; + return { width : element.$.offsetWidth || 0, height : element.$.offsetHeight || 0}; }, /** @@ -596,13 +656,14 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; * @function * @param {Number} x The target x-coordinate. * @param {Number} y The target y-coordinate. + * @param {Boolean} save Flag indicate whether the dialog position should be remembered on next open up. * @example * dialogObj.move( 10, 40 ); */ move : (function() { var isFixed; - return function( x, y ) + return function( x, y, save ) { // The dialog may be fixed positioned or absolute positioned. Ask the // browser what is the current situation first. @@ -629,6 +690,8 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; 'left' : ( x > 0 ? x : 0 ) + 'px', 'top' : ( y > 0 ? y : 0 ) + 'px' }); + + save && ( this._.moved = 1 ); }; })(), @@ -675,14 +738,15 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; // First, set the dialog to an appropriate size. - this.resize( definition.minWidth, definition.minHeight ); - - // Select the first tab by default. - this.selectPage( this.definition.contents[0].id ); + this.resize( this._.contentSize && this._.contentSize.width || definition.minWidth, + this._.contentSize && this._.contentSize.height || definition.minHeight ); // Reset all inputs back to their default value. this.reset(); + // Select the first tab by default. + this.selectPage( this.definition.contents[0].id ); + // Set z-index. if ( CKEDITOR.dialog._.currentZIndex === null ) CKEDITOR.dialog._.currentZIndex = this._.editor.config.baseFloatZIndex; @@ -720,20 +784,15 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; // Reset the hasFocus state. this._.hasFocus = false; - // Rearrange the dialog to the middle of the window. CKEDITOR.tools.setTimeout( function() { - var viewSize = CKEDITOR.document.getWindow().getViewPaneSize(); - var dialogSize = this.getSize(); - - // We're using definition size for initial position because of - // offten corrupted data in offsetWidth at this point. (#4084) - this.move( ( viewSize.width - definition.minWidth ) / 2, ( viewSize.height - dialogSize.height ) / 2 ); - + this.layout(); this.parts.dialog.setStyle( 'visibility', '' ); // Execute onLoad for the first show. this.fireOnce( 'load', {} ); + CKEDITOR.ui.fire( 'ready', this ); + this.fire( 'show', {} ); this._.editor.fire( 'dialogShow', this ); @@ -745,6 +804,19 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; }, /** + * Rearrange the dialog to its previous position or the middle of the window. + * @since 3.5 + */ + layout : function() + { + var viewSize = CKEDITOR.document.getWindow().getViewPaneSize(), + dialogSize = this.getSize(); + + this.move( this._.moved ? this._.position.x : ( viewSize.width - dialogSize.width ) / 2, + this._.moved ? this._.position.y : ( viewSize.height - dialogSize.height ) / 2 ); + }, + + /** * Executes a function for each UI element. * @param {Function} fn Function to execute for each UI element. * @returns {CKEDITOR.dialog} The current dialog object. @@ -754,7 +826,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( this._.contents[i][j] ); } return this; }, @@ -767,7 +839,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; */ reset : (function() { - var fn = function( widget ){ if ( widget.reset ) widget.reset(); }; + var fn = function( widget ){ if ( widget.reset ) widget.reset( 1 ); }; return function(){ this.foreach( fn ); return this; }; })(), @@ -870,7 +942,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; children : contents.elements, expand : !!contents.expand, padding : contents.padding, - style : contents.style || 'width: 100%; height: 100%;' + style : contents.style || 'width: 100%;' }, pageHtml ); // Create the HTML for the tab and the content block. @@ -878,7 +950,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; page.setAttribute( 'role', 'tabpanel' ); var env = CKEDITOR.env; - var tabId = contents.id + '_' + CKEDITOR.tools.getNextNumber(), + var tabId = 'cke_' + contents.id + '_' + CKEDITOR.tools.getNextNumber(), tab = CKEDITOR.dom.element.createFromHtml( [ ' 0 ? ' cke_last' : 'cke_first' ), @@ -938,6 +1010,13 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; */ selectPage : function( id ) { + if ( this._.currentTabId == id ) + return; + + // Returning true means that the event has been canceled + if ( this.fire( 'selectPage', { page : id, currentPage : this._.currentTabId } ) === true ) + return; + // Hide the non-selected tabs and pages. for ( var i in this._.tabs ) { @@ -951,9 +1030,24 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; page.setAttribute( 'aria-hidden', i != id ); } - var selected = this._.tabs[id]; - selected[0].addClass( 'cke_dialog_tab_selected' ); - selected[1].show(); + var selected = this._.tabs[ id ]; + selected[ 0 ].addClass( 'cke_dialog_tab_selected' ); + + // [IE] an invisible input[type='text'] will enlarge it's width + // if it's value is long when it shows, so we clear it's value + // before it shows and then recover it (#5649) + if ( CKEDITOR.env.ie6Compat || CKEDITOR.env.ie7Compat ) + { + clearOrRecoverTextInputValue( selected[ 1 ] ); + selected[ 1 ].show(); + setTimeout( function() + { + clearOrRecoverTextInputValue( selected[ 1 ], 1 ); + }, 0 ); + } + else + selected[ 1 ].show(); + this._.currentTabId = id; this._.currentTabIndex = CKEDITOR.tools.indexOf( this._.tabIdList, id ); }, @@ -974,7 +1068,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; hidePage : function( id ) { var tab = this._.tabs[id] && this._.tabs[id][0]; - if ( !tab || this._.pageCount == 1 ) + if ( !tab || this._.pageCount == 1 || !tab.isVisible() ) return; // Switch to other tab first when we're hiding the active tab. else if ( id == this._.currentTabId ) @@ -1287,9 +1381,6 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; buttons : [ CKEDITOR.dialog.okButton, CKEDITOR.dialog.cancelButton ] }; - // The buttons in MacOS Apps are in reverse order #4750 - CKEDITOR.env.mac && defaultDialogDefinition.buttons.reverse(); - // Tool function used to return an item from an array based on its id // property. var getById = function( array, id, recurse ) @@ -1376,7 +1467,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; // Transform the contents entries in contentObjects. var contents = dialogDefinition.contents; for ( var i = 0, content ; ( content = contents[i] ) ; i++ ) - contents[ i ] = new contentObject( dialog, content ); + contents[ i ] = content && new contentObject( dialog, content ); CKEDITOR.tools.extend( this, dialogDefinition ); }; @@ -1558,7 +1649,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; if ( abstractDialogCoords.x + margins[3] < magnetDistance ) realX = - margins[3]; else if ( abstractDialogCoords.x - margins[1] > viewPaneSize.width - dialogSize.width - magnetDistance ) - realX = viewPaneSize.width - dialogSize.width + margins[1]; + realX = viewPaneSize.width - dialogSize.width + ( editor.lang.dir == 'rtl' ? 0 : margins[1] ); else realX = abstractDialogCoords.x; @@ -1569,7 +1660,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; else realY = abstractDialogCoords.y; - dialog.move( realX, realY ); + dialog.move( realX, realY, 1 ); evt.data.preventDefault(); } @@ -1589,8 +1680,6 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; dialog.parts.title.on( 'mousedown', function( evt ) { - dialog._.updateSize = true; - lastCoords = { x : evt.data.$.screenX, y : evt.data.$.screenY }; CKEDITOR.document.on( 'mousemove', mouseMoveHandler ); @@ -1610,118 +1699,106 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; function initResizeHandles( dialog ) { - var definition = dialog.definition, - minWidth = definition.minWidth || 0, - minHeight = definition.minHeight || 0, - resizable = definition.resizable, - margins = dialog.getParentEditor().skin.margins || [ 0, 0, 0, 0 ]; + var def = dialog.definition, + resizable = def.resizable; - function topSizer( coords, dy ) - { - coords.y += dy; - } + if ( resizable == CKEDITOR.DIALOG_RESIZE_NONE ) + return; - function rightSizer( coords, dx ) - { - coords.x2 += dx; - } + var editor = dialog.getParentEditor(); + var wrapperWidth, wrapperHeight, viewSize, origin, startSize; - function bottomSizer( coords, dy ) + function positionDialog( right ) { - coords.y2 += dy; + // 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(); } - function leftSizer( coords, dx ) + var mouseDownFn = CKEDITOR.tools.addFunction( function( $event ) { - coords.x += dx; - } + startSize = dialog.getSize(); - var lastCoords = null, - abstractDialogCoords = null, - magnetDistance = dialog._.editor.config.magnetDistance, - parts = [ 'tl', 't', 'tr', 'l', 'r', 'bl', 'b', 'br' ]; + // 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 ); - function mouseDownHandler( evt ) - { - var partName = evt.listenerData.part, size = dialog.getSize(); - abstractDialogCoords = dialog.getPosition(); - CKEDITOR.tools.extend( abstractDialogCoords, - { - x2 : abstractDialogCoords.x + size.width, - y2 : abstractDialogCoords.y + size.height - } ); - lastCoords = { x : evt.data.$.screenX, y : evt.data.$.screenY }; + origin = { x : $event.screenX, y : $event.screenY }; - CKEDITOR.document.on( 'mousemove', mouseMoveHandler, dialog, { part : partName } ); - CKEDITOR.document.on( 'mouseup', mouseUpHandler, dialog, { part : partName } ); + viewSize = CKEDITOR.document.getWindow().getViewPaneSize(); + + CKEDITOR.document.on( 'mousemove', mouseMoveHandler ); + CKEDITOR.document.on( 'mouseup', mouseUpHandler ); if ( CKEDITOR.env.ie6Compat ) { var coverDoc = currentCover.getChild( 0 ).getFrameDocument(); - coverDoc.on( 'mousemove', mouseMoveHandler, dialog, { part : partName } ); - coverDoc.on( 'mouseup', mouseUpHandler, dialog, { part : partName } ); + coverDoc.on( 'mousemove', mouseMoveHandler ); + coverDoc.on( 'mouseup', mouseUpHandler ); } - evt.data.preventDefault(); - } + $event.preventDefault && $event.preventDefault(); + }); + + // Prepend the grip to the dialog. + dialog.on( 'load', function() + { + var direction = ''; + if ( resizable == CKEDITOR.DIALOG_RESIZE_WIDTH ) + 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 ); + }); + editor.on( 'destroy', function() { CKEDITOR.tools.removeFunction( mouseDownFn ); } ); function mouseMoveHandler( evt ) { - var x = evt.data.$.screenX, - y = evt.data.$.screenY, - dx = x - lastCoords.x, - dy = y - lastCoords.y, - viewPaneSize = CKEDITOR.document.getWindow().getViewPaneSize(), - partName = evt.listenerData.part; + var rtl = editor.lang.dir == 'rtl', + dx = ( evt.data.$.screenX - origin.x ) * ( rtl ? -1 : 1 ), + dy = evt.data.$.screenY - origin.y, + width = startSize.width, + height = startSize.height, + internalWidth = width + dx * ( dialog._.moved ? 1 : 2 ), + internalHeight = height + dy * ( dialog._.moved ? 1 : 2 ), + element = dialog._.element.getFirst(), + right = rtl && element.getComputedStyle( 'right' ), + position = dialog.getPosition(); - if ( partName.search( 't' ) != -1 ) - topSizer( abstractDialogCoords, dy ); - if ( partName.search( 'l' ) != -1 ) - leftSizer( abstractDialogCoords, dx ); - if ( partName.search( 'b' ) != -1 ) - bottomSizer( abstractDialogCoords, dy ); - if ( partName.search( 'r' ) != -1 ) - rightSizer( abstractDialogCoords, dx ); + // IE might return "auto", we need exact position. + if ( right ) + right = right == 'auto' ? viewSize.width - ( position.x || 0 ) - element.getSize( 'width' ) : parseInt( right, 10 ); - lastCoords = { x : x, y : y }; + if ( position.y + internalHeight > viewSize.height ) + internalHeight = viewSize.height - position.y; - var realX, realY, realX2, realY2; + if ( ( rtl ? right : position.x ) + internalWidth > viewSize.width ) + internalWidth = viewSize.width - ( rtl ? right : position.x ); - if ( abstractDialogCoords.x + margins[3] < magnetDistance ) - realX = - margins[3]; - else if ( partName.search( 'l' ) != -1 && abstractDialogCoords.x2 - abstractDialogCoords.x < minWidth + magnetDistance ) - realX = abstractDialogCoords.x2 - minWidth; - else - realX = abstractDialogCoords.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 ) ) + width = Math.max( def.minWidth || 0, internalWidth - wrapperWidth ); - if ( abstractDialogCoords.y + margins[0] < magnetDistance ) - realY = - margins[0]; - else if ( partName.search( 't' ) != -1 && abstractDialogCoords.y2 - abstractDialogCoords.y < minHeight + magnetDistance ) - realY = abstractDialogCoords.y2 - minHeight; - else - realY = abstractDialogCoords.y; - - if ( abstractDialogCoords.x2 - margins[1] > viewPaneSize.width - magnetDistance ) - realX2 = viewPaneSize.width + margins[1] ; - else if ( partName.search( 'r' ) != -1 && abstractDialogCoords.x2 - abstractDialogCoords.x < minWidth + magnetDistance ) - realX2 = abstractDialogCoords.x + minWidth; - else - realX2 = abstractDialogCoords.x2; - - if ( abstractDialogCoords.y2 - margins[2] > viewPaneSize.height - magnetDistance ) - realY2= viewPaneSize.height + margins[2] ; - else if ( partName.search( 'b' ) != -1 && abstractDialogCoords.y2 - abstractDialogCoords.y < minHeight + magnetDistance ) - realY2 = abstractDialogCoords.y + minHeight; - else - realY2 = abstractDialogCoords.y2 ; + if ( resizable == CKEDITOR.DIALOG_RESIZE_HEIGHT || resizable == CKEDITOR.DIALOG_RESIZE_BOTH ) + height = Math.max( def.minHeight || 0, internalHeight - wrapperHeight ); - dialog.move( realX, realY ); - dialog.resize( realX2 - realX, realY2 - realY ); + dialog.resize( width, height ); + // The right property might get broken during resizing, so computing it before the resizing. + positionDialog( right ); evt.data.preventDefault(); } - function mouseUpHandler( evt ) + function mouseUpHandler() { CKEDITOR.document.removeListener( 'mouseup', mouseUpHandler ); CKEDITOR.document.removeListener( 'mousemove', mouseMoveHandler ); @@ -1732,23 +1809,25 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; coverDoc.removeListener( 'mouseup', mouseUpHandler ); coverDoc.removeListener( 'mousemove', mouseMoveHandler ); } - } -// TODO : Simplify the resize logic, having just a single resize grip
. -// var widthTest = /[lr]/, -// heightTest = /[tb]/; -// for ( var i = 0 ; i < parts.length ; i++ ) -// { -// var element = dialog.parts[ parts[i] + '_resize' ]; -// if ( resizable == CKEDITOR.DIALOG_RESIZE_NONE || -// resizable == CKEDITOR.DIALOG_RESIZE_HEIGHT && widthTest.test( parts[i] ) || -// resizable == CKEDITOR.DIALOG_RESIZE_WIDTH && heightTest.test( parts[i] ) ) -// { -// element.hide(); -// continue; -// } -// element.on( 'mousedown', mouseDownHandler, dialog, { part : parts[i] } ); -// } + // 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 ); + } + } } var resizeCover; @@ -1760,9 +1839,10 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; function showCover( editor ) { var win = CKEDITOR.document.getWindow(); - var backgroundColorStyle = editor.config.dialog_backgroundCoverColor || 'white', - backgroundCoverOpacity = editor.config.dialog_backgroundCoverOpacity, - baseFloatZIndex = editor.config.baseFloatZIndex, + var config = editor.config, + backgroundColorStyle = config.dialog_backgroundCoverColor || 'white', + backgroundCoverOpacity = config.dialog_backgroundCoverOpacity, + baseFloatZIndex = config.baseFloatZIndex, coverKey = CKEDITOR.tools.genKey( backgroundColorStyle, backgroundCoverOpacity, @@ -2041,7 +2121,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; styles = ( stylesArg && stylesArg.call ? stylesArg( elementDefinition ) : stylesArg ) || {}, attributes = ( attributesArg && attributesArg.call ? attributesArg( elementDefinition ) : attributesArg ) || {}, innerHTML = ( contentsArg && contentsArg.call ? contentsArg.call( this, dialog, elementDefinition ) : contentsArg ) || '', - domId = this.domId = attributes.id || CKEDITOR.tools.getNextNumber() + '_uiElement', + domId = this.domId = attributes.id || CKEDITOR.tools.getNextId() + '_uiElement', id = this.id = elementDefinition.id, i; @@ -2193,14 +2273,14 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; if ( widths ) { if ( widths[i] ) - styles.push( 'width:' + CKEDITOR.tools.cssLength( widths[i] ) ); + styles.push( 'width:' + cssLength( widths[i] ) ); } else styles.push( 'width:' + Math.floor( 100 / childHtmlList.length ) + '%' ); if ( height ) - styles.push( 'height:' + CKEDITOR.tools.cssLength( height ) ); + styles.push( 'height:' + cssLength( height ) ); if ( elementDefinition && elementDefinition.padding != undefined ) - styles.push( 'padding:' + CKEDITOR.tools.cssLength( elementDefinition.padding ) ); + styles.push( 'padding:' + cssLength( elementDefinition.padding ) ); if ( styles.length > 0 ) html.push( 'style="' + styles.join('; ') + '" ' ); html.push( '>', childHtmlList[i], '' ); @@ -2253,7 +2333,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; */ vbox : function( dialog, childObjList, childHtmlList, htmlList, elementDefinition ) { - if (arguments.length < 3 ) + if ( arguments.length < 3 ) return; this._ || ( this._ = {} ); @@ -2268,7 +2348,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; html.push( 'style="' ); if ( elementDefinition && elementDefinition.expand ) html.push( 'height:100%;' ); - html.push( 'width:' + CKEDITOR.tools.cssLength( width || '100%' ), ';' ); + html.push( 'width:' + cssLength( width || '100%' ), ';' ); html.push( '"' ); html.push( 'align="', CKEDITOR.tools.htmlEncode( ( elementDefinition && elementDefinition.align ) || ( dialog.getParentEditor().lang.dir == 'ltr' ? 'left' : 'right' ) ), '" ' ); @@ -2279,13 +2359,13 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; var styles = []; html.push( ' 0 ) html.push( 'style="', styles.join( '; ' ), '" ' ); html.push( ' class="cke_dialog_ui_vbox_child">', childHtmlList[i], '' ); @@ -2339,14 +2419,15 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; /** * Sets the value of this dialog UI object. * @param {Object} value The new value. + * @param {Boolean} noChangeEvent Internal commit, to supress 'change' event on this element. * @returns {CKEDITOR.dialog.uiElement} The current UI element. * @example * uiElement.setValue( 'Dingo' ); */ - setValue : function( value ) + setValue : function( value, noChangeEvent ) { this.getInputElement().setValue( value ); - this.fire( 'change', { value : value } ); + !noChangeEvent && this.fire( 'change', { value : value } ); return this; }, @@ -2935,6 +3016,34 @@ CKEDITOR.plugins.add( 'dialog', */ /** + * The guildeline to follow when generating the dialog buttons. There are 3 possible options: + * + * @name CKEDITOR.config.dialog_buttonsOrder + * @type String + * @default 'OS' + * @since 3.5 + * @example + * config.dialog_buttonsOrder = 'rtl'; + */ + +/** + * The dialog contents to removed. It's a string composed by dialog name and tab name with a colon between them. + * Separate each pair with semicolon (see example). + * Note: All names are case-sensitive. + * Note: Be cautious when specifying dialog tabs that are mandatory, like "info", dialog functionality might be broken because of this! + * @name CKEDITOR.config.removeDialogTabs + * @type String + * @since 3.5 + * @default '' + * @example + * config.removeDialogTabs = 'flash:advanced;image:Link'; + */ + +/** * Fired when a dialog definition is about to be used to create a dialog into * an editor instance. This event makes it possible to customize the definition * before creating it. @@ -2948,3 +3057,11 @@ CKEDITOR.plugins.add( 'dialog', * @param {CKEDITOR.editor} editor The editor instance that will use the * dialog. */ + +/** + * Fired when a tab is going to be selected in a dialog + * @name dialog#selectPage + * @event + * @param String page The id of the page that it's gonna be selected. + * @param String currentPage The id of the current page. + */