JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.1.1
[ckeditor.git] / _source / plugins / floatpanel / plugin.js
index 79c5197..849d5fc 100644 (file)
@@ -135,6 +135,9 @@ CKEDITOR.plugins.add( 'floatpanel',
                                                display : ''\r
                                        });\r
 \r
+                               // To allow the context menu to decrease back their width\r
+                               element.getFirst().removeStyle('width');\r
+\r
                                // Configure the IFrame blur event. Do that only once.\r
                                if ( !this._.blurSet )\r
                                {\r
@@ -192,9 +195,34 @@ CKEDITOR.plugins.add( 'floatpanel',
 \r
                                                var panelLoad = CKEDITOR.tools.bind( function ()\r
                                                {\r
+                                                       var target = element.getFirst();\r
+\r
                                                        if ( block.autoSize )\r
                                                        {\r
-                                                               var target = element.getFirst();\r
+                                                               // We must adjust first the width or IE6 could include extra lines in the height computation\r
+                                                               var widthNode = block.element.$;\r
+\r
+                                                               if ( CKEDITOR.env.gecko || CKEDITOR.env.opera)\r
+                                                                       widthNode = widthNode.parentNode;\r
+\r
+                                                               if ( CKEDITOR.env.ie)\r
+                                                                       widthNode = widthNode.document.body;\r
+\r
+                                                               var width = widthNode.scrollWidth;\r
+                                                               // Account for extra height needed due to IE quirks box model bug:\r
+                                                               // http://en.wikipedia.org/wiki/Internet_Explorer_box_model_bug\r
+                                                               // (#3426)\r
+                                                               if ( CKEDITOR.env.ie && CKEDITOR.env.quirks && width > 0 )\r
+                                                                       width += ( target.$.offsetWidth || 0 ) - ( target.$.clientWidth || 0 );\r
+                                                               // A little extra at the end.\r
+                                                               // If not present, IE6 might break into the next line, but also it looks better this way\r
+                                                               width += 4 ;\r
+\r
+                                                               target.setStyle( 'width', width + 'px' );\r
+\r
+                                                               // IE doesn't compute the scrollWidth if a filter is applied previously\r
+                                                               block.element.addClass( 'cke_frameLoaded' );\r
+\r
                                                                var height = block.element.$.scrollHeight;\r
 \r
                                                                // Account for extra height needed due to IE quirks box model bug:\r
@@ -209,7 +237,7 @@ CKEDITOR.plugins.add( 'floatpanel',
                                                                panel._.currentBlock.element.setStyle( 'display', 'none' ).removeStyle( 'display' );\r
                                                        }\r
                                                        else\r
-                                                               element.getFirst().removeStyle( 'height' );\r
+                                                               target.removeStyle( 'height' );\r
 \r
                                                        var panelElement = panel.element,\r
                                                                panelWindow = panelElement.getWindow(),\r
@@ -227,7 +255,7 @@ CKEDITOR.plugins.add( 'floatpanel',
                                                                left += ( panelSize.width * ( rtl ? 1 : -1 ) );\r
 \r
                                                        // Vertical off screen is simpler.\r
-                                                       if( top + panelSize.height > viewportSize.height + windowScroll.y )\r
+                                                       if ( top + panelSize.height > viewportSize.height + windowScroll.y )\r
                                                                top -= panelSize.height;\r
 \r
                                                        element.setStyles(\r
@@ -343,11 +371,11 @@ CKEDITOR.plugins.add( 'floatpanel',
        {\r
                var isLastInstance = CKEDITOR.tools.isEmpty( CKEDITOR.instances );\r
 \r
-               for( var i in panels )\r
+               for ( var i in panels )\r
                {\r
                        var panel = panels[ i ];\r
                        // Safe to destroy it since there're no more instances.(#4241)\r
-                       if( isLastInstance )\r
+                       if ( isLastInstance )\r
                                panel.destroy();\r
                        // Panel might be used by other instances, just hide them.(#4552)\r
                        else\r