X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fdialog%2Fplugin.js;h=d7086161bde0ed1aace413e2fdca2b2a9d2b5113;hb=c9fdde67e6384bd5a66adc2b3bba5c4ce9db56c7;hp=917d2dd0e371940840514afe96fa3af88b572b8c;hpb=055b6b0792ce7dc53d47af606b367c04b927c2ab;p=ckeditor.git diff --git a/_source/plugins/dialog/plugin.js b/_source/plugins/dialog/plugin.js index 917d2dd..d708616 100644 --- a/_source/plugins/dialog/plugin.js +++ b/_source/plugins/dialog/plugin.js @@ -68,6 +68,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. @@ -472,7 +496,10 @@ 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 ) { @@ -480,8 +507,10 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; // 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; @@ -680,12 +709,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; @@ -757,7 +786,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; }, @@ -770,7 +799,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; }; })(), @@ -881,7 +910,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' ), @@ -963,7 +992,25 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3; var selected = this._.tabs[id]; selected[0].addClass( 'cke_dialog_tab_selected' ); - selected[1].show(); + + // [IE] a unvisible input[type='text'] will enlarge it's width + // if it's value is long when it show( #5649 ) + // so we clear it's value before it shows and then recover it + if ( CKEDITOR.env.ie6Compat || CKEDITOR.env.ie7Compat ) + { + clearOrRecoverTextInputValue( selected[1] ); + selected[1].show(); + setTimeout( function() + { + clearOrRecoverTextInputValue( selected[1], true ); + }, 0 ); + } + else + { + selected[1].show(); + } + + this._.currentTabId = id; this._.currentTabIndex = CKEDITOR.tools.indexOf( this._.tabIdList, id ); }, @@ -1386,7 +1433,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 ); }; @@ -2051,7 +2098,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; @@ -2349,14 +2396,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; },