X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fdialog%2Fplugin.js;h=13f632719684082337990ceab0de6d28c1aa0105;hb=039a051ccf3901311661022a30afd60fc38130c9;hp=f2430ccd24a8acbe50dca3a11c5a2fc8007d70d2;hpb=9873d66421922c7aef8be0f5d2ab51e547b19e66;p=ckeditor.git diff --git a/_source/plugins/dialog/plugin.js b/_source/plugins/dialog/plugin.js index f2430cc..13f6327 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. @@ -477,7 +502,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; 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. @@ -685,12 +710,12 @@ 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 ); - // 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; @@ -966,9 +991,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 ); }, @@ -1775,9 +1815,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, @@ -2208,14 +2249,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], '' ); @@ -2268,7 +2309,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; */ vbox : function( dialog, childObjList, childHtmlList, htmlList, elementDefinition ) { - if (arguments.length < 3 ) + if ( arguments.length < 3 ) return; this._ || ( this._ = {} ); @@ -2283,7 +2324,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' ) ), '" ' ); @@ -2294,13 +2335,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], '' );