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