JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.4.3
[ckeditor.git] / _source / plugins / dialog / plugin.js
index f2430cc..26d8a8d 100644 (file)
@@ -33,6 +33,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
 \r
 (function()\r
 {\r
+       var cssLength = CKEDITOR.tools.cssLength;\r
        function isTabVisible( tabId )\r
        {\r
                return !!this._.tabs[ tabId ][ 0 ].$.offsetHeight;\r
@@ -68,6 +69,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
@@ -477,7 +502,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
                        page && this.addPage( page );\r
                }\r
 \r
-               this.parts['tabs'].on( 'click', function( evt )\r
+               this.parts[ 'tabs' ].on( 'click', function( evt )\r
                                {\r
                                        var target = evt.data.getTarget();\r
                                        // If we aren't inside a tab, bail out.\r
@@ -685,12 +710,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
@@ -966,9 +991,24 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
                                page.setAttribute( 'aria-hidden', i != id );\r
                        }\r
 \r
-                       var selected = this._.tabs[id];\r
-                       selected[0].addClass( 'cke_dialog_tab_selected' );\r
-                       selected[1].show();\r
+                       var selected = this._.tabs[ id ];\r
+                       selected[ 0 ].addClass( 'cke_dialog_tab_selected' );\r
+\r
+                       // [IE] an invisible input[type='text'] will enlarge it's width\r
+                       // if it's value is long when it shows, so we clear it's value\r
+                       // before it shows and then recover it (#5649)\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 ], 1 );\r
+                               }, 0 );\r
+                       }\r
+                       else\r
+                               selected[ 1 ].show();\r
+\r
                        this._.currentTabId = id;\r
                        this._.currentTabIndex = CKEDITOR.tools.indexOf( this._.tabIdList, id );\r
                },\r
@@ -989,7 +1029,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
                hidePage : function( id )\r
                {\r
                        var tab = this._.tabs[id] && this._.tabs[id][0];\r
-                       if ( !tab || this._.pageCount == 1 )\r
+                       if ( !tab || this._.pageCount == 1 || !tab.isVisible() )\r
                                return;\r
                        // Switch to other tab first when we're hiding the active tab.\r
                        else if ( id == this._.currentTabId )\r
@@ -1775,9 +1815,10 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
        function showCover( editor )\r
        {\r
                var win = CKEDITOR.document.getWindow();\r
-               var backgroundColorStyle = editor.config.dialog_backgroundCoverColor || 'white',\r
-                       backgroundCoverOpacity = editor.config.dialog_backgroundCoverOpacity,\r
-                       baseFloatZIndex = editor.config.baseFloatZIndex,\r
+               var config = editor.config,\r
+                       backgroundColorStyle = config.dialog_backgroundCoverColor || 'white',\r
+                       backgroundCoverOpacity = config.dialog_backgroundCoverOpacity,\r
+                       baseFloatZIndex = config.baseFloatZIndex,\r
                        coverKey = CKEDITOR.tools.genKey(\r
                                        backgroundColorStyle,\r
                                        backgroundCoverOpacity,\r
@@ -2208,14 +2249,14 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
                                                if ( widths )\r
                                                {\r
                                                        if ( widths[i] )\r
-                                                               styles.push( 'width:' + CKEDITOR.tools.cssLength( widths[i] ) );\r
+                                                               styles.push( 'width:' + cssLength( widths[i] ) );\r
                                                }\r
                                                else\r
                                                        styles.push( 'width:' + Math.floor( 100 / childHtmlList.length ) + '%' );\r
                                                if ( height )\r
-                                                       styles.push( 'height:' + CKEDITOR.tools.cssLength( height ) );\r
+                                                       styles.push( 'height:' + cssLength( height ) );\r
                                                if ( elementDefinition && elementDefinition.padding != undefined )\r
-                                                       styles.push( 'padding:' + CKEDITOR.tools.cssLength( elementDefinition.padding ) );\r
+                                                       styles.push( 'padding:' + cssLength( elementDefinition.padding ) );\r
                                                if ( styles.length > 0 )\r
                                                        html.push( 'style="' + styles.join('; ') + '" ' );\r
                                                html.push( '>', childHtmlList[i], '</td>' );\r
@@ -2268,7 +2309,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
                         */\r
                        vbox : function( dialog, childObjList, childHtmlList, htmlList, elementDefinition )\r
                        {\r
-                               if (arguments.length < 3 )\r
+                               if ( arguments.length < 3 )\r
                                        return;\r
 \r
                                this._ || ( this._ = {} );\r
@@ -2283,7 +2324,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
                                        html.push( 'style="' );\r
                                        if ( elementDefinition && elementDefinition.expand )\r
                                                html.push( 'height:100%;' );\r
-                                       html.push( 'width:' + CKEDITOR.tools.cssLength( width || '100%' ), ';' );\r
+                                       html.push( 'width:' + cssLength( width || '100%' ), ';' );\r
                                        html.push( '"' );\r
                                        html.push( 'align="', CKEDITOR.tools.htmlEncode(\r
                                                ( elementDefinition && elementDefinition.align ) || ( dialog.getParentEditor().lang.dir == 'ltr' ? 'left' : 'right' ) ), '" ' );\r
@@ -2294,13 +2335,13 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
                                                var styles = [];\r
                                                html.push( '<tr><td role="presentation" ' );\r
                                                if ( width )\r
-                                                       styles.push( 'width:' + CKEDITOR.tools.cssLength( width || '100%' ) );\r
+                                                       styles.push( 'width:' + cssLength( width || '100%' ) );\r
                                                if ( heights )\r
-                                                       styles.push( 'height:' + CKEDITOR.tools.cssLength( heights[i] ) );\r
+                                                       styles.push( 'height:' + cssLength( heights[i] ) );\r
                                                else if ( elementDefinition && elementDefinition.expand )\r
                                                        styles.push( 'height:' + Math.floor( 100 / childHtmlList.length ) + '%' );\r
                                                if ( elementDefinition && elementDefinition.padding != undefined )\r
-                                                       styles.push( 'padding:' + CKEDITOR.tools.cssLength( elementDefinition.padding ) );\r
+                                                       styles.push( 'padding:' + cssLength( elementDefinition.padding ) );\r
                                                if ( styles.length > 0 )\r
                                                        html.push( 'style="', styles.join( '; ' ), '" ' );\r
                                                html.push( ' class="cke_dialog_ui_vbox_child">', childHtmlList[i], '</td></tr>' );\r