JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.4.1
[ckeditor.git] / _source / plugins / dialog / plugin.js
index f2430cc..d708616 100644 (file)
@@ -68,6 +68,30 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
                return null;\r
        }\r
 \r
+\r
+       function clearOrRecoverTextInputValue( container, isRecover )\r
+       {\r
+               var inputs = container.$.getElementsByTagName( 'input' );\r
+               for ( var i = 0, length = inputs.length; i < length ; i++ )\r
+               {\r
+                       var item = new CKEDITOR.dom.element( inputs[ i ] );\r
+\r
+                       if ( item.getAttribute( 'type' ).toLowerCase() == 'text' )\r
+                       {\r
+                               if ( isRecover )\r
+                               {\r
+                                       item.setAttribute( 'value', item.getCustomData( 'fake_value' ) || '' );\r
+                                       item.removeCustomData( 'fake_value' );\r
+                               }\r
+                               else\r
+                               {\r
+                                       item.setCustomData( 'fake_value', item.getAttribute( 'value' ) );\r
+                                       item.setAttribute( 'value', '' );\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+\r
        /**\r
         * This is the base class for runtime dialog objects. An instance of this\r
         * class represents a single named dialog for a single editor instance.\r
@@ -685,12 +709,12 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
                        // First, set the dialog to an appropriate size.\r
                        this.resize( definition.minWidth, definition.minHeight );\r
 \r
-                       // Select the first tab by default.\r
-                       this.selectPage( this.definition.contents[0].id );\r
-\r
                        // Reset all inputs back to their default value.\r
                        this.reset();\r
 \r
+                       // Select the first tab by default.\r
+                       this.selectPage( this.definition.contents[0].id );\r
+\r
                        // Set z-index.\r
                        if ( CKEDITOR.dialog._.currentZIndex === null )\r
                                CKEDITOR.dialog._.currentZIndex = this._.editor.config.baseFloatZIndex;\r
@@ -968,7 +992,25 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
 \r
                        var selected = this._.tabs[id];\r
                        selected[0].addClass( 'cke_dialog_tab_selected' );\r
-                       selected[1].show();\r
+\r
+                       // [IE] a unvisible input[type='text'] will enlarge it's width\r
+                       // if it's value is long when it show( #5649 )\r
+                       // so we clear it's value before it shows and then recover it\r
+                       if ( CKEDITOR.env.ie6Compat || CKEDITOR.env.ie7Compat )\r
+                       {\r
+                               clearOrRecoverTextInputValue( selected[1] );\r
+                               selected[1].show();\r
+                               setTimeout( function()\r
+                               {\r
+                                       clearOrRecoverTextInputValue( selected[1], true );\r
+                               }, 0 );\r
+                       }\r
+                       else\r
+                       {\r
+                               selected[1].show();\r
+                       }\r
+\r
+\r
                        this._.currentTabId = id;\r
                        this._.currentTabIndex = CKEDITOR.tools.indexOf( this._.tabIdList, id );\r
                },\r