JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.2.1
[ckeditor.git] / _source / plugins / dialog / plugin.js
index 6b5c2e4..ee8d0e6 100644 (file)
@@ -335,7 +335,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
 \r
                                processed = 1;\r
                        }\r
-                       else if ( keystroke == CKEDITOR.ALT + 121 && !me._.tabBarMode )\r
+                       else if ( keystroke == CKEDITOR.ALT + 121 && !me._.tabBarMode && me.getPageCount() > 1 )\r
                        {\r
                                // Alt-F10 puts focus into the current tab item in the tab bar.\r
                                me._.tabBarMode = true;\r
@@ -505,8 +505,6 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
 \r
                for ( i = 0 ; i < buttons.length ; i++ )\r
                        this._.buttons[ buttons[i].id ] = buttons[i];\r
-\r
-               CKEDITOR.skins.load( editor, 'dialog' );\r
        };\r
 \r
        // Focusable interface. Use it via dialog.addFocusable.\r
@@ -868,7 +866,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
                                                        children : contents.elements,\r
                                                        expand : !!contents.expand,\r
                                                        padding : contents.padding,\r
-                                                       style : contents.style || 'width: 100%;' + ( CKEDITOR.env.ie6Compat ? '' : 'height: 100%;' )\r
+                                                       style : contents.style || 'width: 100%; height: 100%;'\r
                                                }, pageHtml );\r
 \r
                        // Create the HTML for the tab and the content block.\r
@@ -893,17 +891,12 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
 \r
                        page.setAttribute( 'aria-labelledby', tabId );\r
 \r
-                       // If only a single page exist, a different style is used in the central pane.\r
-                       if ( this._.pageCount === 0 )\r
-                               this.parts.dialog.addClass( 'cke_single_page' );\r
-                       else\r
-                               this.parts.dialog.removeClass( 'cke_single_page' );\r
-\r
                        // Take records for the tabs and elements created.\r
                        this._.tabs[ contents.id ] = [ tab, page ];\r
                        this._.tabIdList.push( contents.id );\r
-                       this._.pageCount++;\r
+                       !contents.hidden && this._.pageCount++;\r
                        this._.lastTab = tab;\r
+                       this.updateStyle();\r
 \r
                        var contentMap = this._.contents[ contents.id ] = {},\r
                                cursor,\r
@@ -961,6 +954,13 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
                        this._.currentTabIndex = CKEDITOR.tools.indexOf( this._.tabIdList, id );\r
                },\r
 \r
+               // Dialog state-specific style updates.\r
+               updateStyle : function()\r
+               {\r
+                       // If only a single page shown, a different style is used in the central pane.\r
+                       this.parts.dialog[ ( this._.pageCount === 1 ? 'add' : 'remove' ) + 'Class' ]( 'cke_single_page' );\r
+               },\r
+\r
                /**\r
                 * Hides a page's tab away from the dialog.\r
                 * @param {String} id The page's Id.\r
@@ -970,9 +970,15 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
                hidePage : function( id )\r
                {\r
                        var tab = this._.tabs[id] && this._.tabs[id][0];\r
-                       if ( !tab )\r
+                       if ( !tab || this._.pageCount == 1 )\r
                                return;\r
+                       // Switch to other tab first when we're hiding the active tab.\r
+                       else if ( id == this._.currentTabId )\r
+                               this.selectPage( getPreviousVisibleTab.call( this ) );\r
+\r
                        tab.hide();\r
+                       this._.pageCount--;\r
+                       this.updateStyle();\r
                },\r
 \r
                /**\r
@@ -987,6 +993,8 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
                        if ( !tab )\r
                                return;\r
                        tab.show();\r
+                       this._.pageCount++;\r
+                       this.updateStyle();\r
                },\r
 \r
                /**\r
@@ -1269,12 +1277,15 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
 \r
        var defaultDialogDefinition =\r
        {\r
-               resizable : CKEDITOR.DIALOG_RESIZE_NONE,\r
+               resizable : CKEDITOR.DIALOG_RESIZE_BOTH,\r
                minWidth : 600,\r
                minHeight : 400,\r
                buttons : [ CKEDITOR.dialog.okButton, CKEDITOR.dialog.cancelButton ]\r
        };\r
 \r
+       // The buttons in MacOS Apps are in reverse order #4750\r
+       CKEDITOR.env.mac && defaultDialogDefinition.buttons.reverse();\r
+\r
        // Tool function used to return an item from an array based on its id\r
        // property.\r
        var getById = function( array, id, recurse )\r
@@ -2784,10 +2795,11 @@ CKEDITOR.tools.extend( CKEDITOR.editor.prototype,
                 */\r
                openDialog : function( dialogName, callback )\r
                {\r
-                       var dialogDefinitions = CKEDITOR.dialog._.dialogDefinitions[ dialogName ];\r
+                       var dialogDefinitions = CKEDITOR.dialog._.dialogDefinitions[ dialogName ],\r
+                                       dialogSkin = this.skin.dialog;\r
 \r
                        // If the dialogDefinition is already loaded, open it immediately.\r
-                       if ( typeof dialogDefinitions == 'function' )\r
+                       if ( typeof dialogDefinitions == 'function' && dialogSkin._isLoaded )\r
                        {\r
                                var storedDialogs = this._.storedDialogs ||\r
                                        ( this._.storedDialogs = {} );\r
@@ -2809,14 +2821,31 @@ CKEDITOR.tools.extend( CKEDITOR.editor.prototype,
                                me = this;\r
 \r
                        body.setStyle( 'cursor', 'wait' );\r
-                       CKEDITOR.scriptLoader.load( CKEDITOR.getUrl( dialogDefinitions ), function()\r
-                               {\r
-                                       // In case of plugin error, mark it as loading failed.\r
-                                       if ( typeof CKEDITOR.dialog._.dialogDefinitions[ dialogName ] != 'function' )\r
-                                                       CKEDITOR.dialog._.dialogDefinitions[ dialogName ] =  'failed';\r
-                                       me.openDialog( dialogName, callback );\r
-                                       body.setStyle( 'cursor', cursor );\r
-                               } );\r
+\r
+                       function onDialogFileLoaded( success )\r
+                       {\r
+                               var dialogDefinition = CKEDITOR.dialog._.dialogDefinitions[ dialogName ],\r
+                                               skin = me.skin.dialog;\r
+\r
+                               // Check if both skin part and definition is loaded.\r
+                               if ( !skin._isLoaded || loadDefinition && typeof success == 'undefined' )\r
+                                       return;\r
+\r
+                               // In case of plugin error, mark it as loading failed.\r
+                               if ( typeof dialogDefinition != 'function' )\r
+                                       CKEDITOR.dialog._.dialogDefinitions[ dialogName ] = 'failed';\r
+\r
+                               me.openDialog( dialogName, callback );\r
+                               body.setStyle( 'cursor', cursor );\r
+                       }\r
+\r
+                       if ( typeof dialogDefinitions == 'string' )\r
+                       {\r
+                               var loadDefinition = 1;\r
+                               CKEDITOR.scriptLoader.load( CKEDITOR.getUrl( dialogDefinitions ), onDialogFileLoaded );\r
+                       }\r
+\r
+                       CKEDITOR.skins.load( this, 'dialog', onDialogFileLoaded );\r
 \r
                        return null;\r
                }\r