aboutsummaryrefslogtreecommitdiff
path: root/sources/plugins/dialog
diff options
context:
space:
mode:
Diffstat (limited to 'sources/plugins/dialog')
-rw-r--r--sources/plugins/dialog/plugin.js58
1 files changed, 35 insertions, 23 deletions
diff --git a/sources/plugins/dialog/plugin.js b/sources/plugins/dialog/plugin.js
index d6af6a2..f26f9c9 100644
--- a/sources/plugins/dialog/plugin.js
+++ b/sources/plugins/dialog/plugin.js
@@ -177,10 +177,10 @@ CKEDITOR.DIALOG_STATE_BUSY = 2;
177 title = body.getChild( 0 ), 177 title = body.getChild( 0 ),
178 close = body.getChild( 1 ); 178 close = body.getChild( 1 );
179 179
180 // Don't allow dragging on dialog (#13184). 180 // Don't allow dragging on dialog (http://dev.ckeditor.com/ticket/13184).
181 editor.plugins.clipboard && CKEDITOR.plugins.clipboard.preventDefaultDropOnElement( body ); 181 editor.plugins.clipboard && CKEDITOR.plugins.clipboard.preventDefaultDropOnElement( body );
182 182
183 // IFrame shim for dialog that masks activeX in IE. (#7619) 183 // IFrame shim for dialog that masks activeX in IE. (http://dev.ckeditor.com/ticket/7619)
184 if ( CKEDITOR.env.ie && !CKEDITOR.env.quirks && !CKEDITOR.env.edge ) { 184 if ( CKEDITOR.env.ie && !CKEDITOR.env.quirks && !CKEDITOR.env.edge ) {
185 var src = 'javascript:void(function(){' + encodeURIComponent( 'document.open();(' + CKEDITOR.tools.fixDomain + ')();document.close();' ) + '}())', // jshint ignore:line 185 var src = 'javascript:void(function(){' + encodeURIComponent( 'document.open();(' + CKEDITOR.tools.fixDomain + ')();document.close();' ) + '}())', // jshint ignore:line
186 iframe = CKEDITOR.dom.element.createFromHtml( '<iframe' + 186 iframe = CKEDITOR.dom.element.createFromHtml( '<iframe' +
@@ -229,7 +229,7 @@ CKEDITOR.DIALOG_STATE_BUSY = 2;
229 tabsToRemove = {}, 229 tabsToRemove = {},
230 i, processed, stopPropagation; 230 i, processed, stopPropagation;
231 231
232 if ( ( buttonsOrder == 'OS' && CKEDITOR.env.mac ) || // The buttons in MacOS Apps are in reverse order (#4750) 232 if ( ( buttonsOrder == 'OS' && CKEDITOR.env.mac ) || // The buttons in MacOS Apps are in reverse order (http://dev.ckeditor.com/ticket/4750)
233 ( buttonsOrder == 'rtl' && dir == 'ltr' ) || ( buttonsOrder == 'ltr' && dir == 'rtl' ) ) 233 ( buttonsOrder == 'rtl' && dir == 'ltr' ) || ( buttonsOrder == 'ltr' && dir == 'rtl' ) )
234 defaultDefinition.buttons.reverse(); 234 defaultDefinition.buttons.reverse();
235 235
@@ -334,7 +334,7 @@ CKEDITOR.DIALOG_STATE_BUSY = 2;
334 334
335 if ( definition.onOk ) { 335 if ( definition.onOk ) {
336 this.on( 'ok', function( evt ) { 336 this.on( 'ok', function( evt ) {
337 // Dialog confirm might probably introduce content changes (#5415). 337 // Dialog confirm might probably introduce content changes (http://dev.ckeditor.com/ticket/5415).
338 editor.fire( 'saveSnapshot' ); 338 editor.fire( 'saveSnapshot' );
339 setTimeout( function() { 339 setTimeout( function() {
340 editor.fire( 'saveSnapshot' ); 340 editor.fire( 'saveSnapshot' );
@@ -451,7 +451,7 @@ CKEDITOR.DIALOG_STATE_BUSY = 2;
451 currentIndex = currentIndex + offset; 451 currentIndex = currentIndex + offset;
452 452
453 if ( hasTabs && !me._.tabBarMode && ( currentIndex == focusList.length || currentIndex == -1 ) ) { 453 if ( hasTabs && !me._.tabBarMode && ( currentIndex == focusList.length || currentIndex == -1 ) ) {
454 // If the dialog was not in tab mode, then focus the first tab (#13027). 454 // If the dialog was not in tab mode, then focus the first tab (http://dev.ckeditor.com/ticket/13027).
455 me._.tabBarMode = true; 455 me._.tabBarMode = true;
456 me._.tabs[ me._.currentTabId ][ 0 ].focus(); 456 me._.tabs[ me._.currentTabId ][ 0 ].focus();
457 me._.currentFocusIndex = -1; 457 me._.currentFocusIndex = -1;
@@ -528,7 +528,7 @@ CKEDITOR.DIALOG_STATE_BUSY = 2;
528 button && CKEDITOR.tools.setTimeout( button.click, 0, button ); 528 button && CKEDITOR.tools.setTimeout( button.click, 0, button );
529 processed = 1; 529 processed = 1;
530 } 530 }
531 stopPropagation = 1; // Always block the propagation (#4269) 531 stopPropagation = 1; // Always block the propagation (http://dev.ckeditor.com/ticket/4269)
532 } else if ( keystroke == 27 /*ESC*/ ) { 532 } else if ( keystroke == 27 /*ESC*/ ) {
533 button = this.getButton( 'cancel' ); 533 button = this.getButton( 'cancel' );
534 534
@@ -539,7 +539,7 @@ CKEDITOR.DIALOG_STATE_BUSY = 2;
539 if ( this.fire( 'cancel', { hide: true } ).hide !== false ) 539 if ( this.fire( 'cancel', { hide: true } ).hide !== false )
540 this.hide(); 540 this.hide();
541 } 541 }
542 stopPropagation = 1; // Always block the propagation (#4269) 542 stopPropagation = 1; // Always block the propagation (http://dev.ckeditor.com/ticket/4269)
543 } else { 543 } else {
544 return; 544 return;
545 } 545 }
@@ -563,7 +563,7 @@ CKEDITOR.DIALOG_STATE_BUSY = 2;
563 dialogElement.on( 'keydown', keydownHandler, this ); 563 dialogElement.on( 'keydown', keydownHandler, this );
564 564
565 // Some browsers instead, don't cancel key events in the keydown, but in the 565 // Some browsers instead, don't cancel key events in the keydown, but in the
566 // keypress. So we must do a longer trip in those cases. (#4531,#8985) 566 // keypress. So we must do a longer trip in those cases. (http://dev.ckeditor.com/ticket/4531,http://dev.ckeditor.com/ticket/8985)
567 if ( CKEDITOR.env.gecko ) 567 if ( CKEDITOR.env.gecko )
568 dialogElement.on( 'keypress', keypressHandler, this ); 568 dialogElement.on( 'keypress', keypressHandler, this );
569 569
@@ -612,7 +612,7 @@ CKEDITOR.DIALOG_STATE_BUSY = 2;
612 } 612 }
613 }, this, null, 0xffffffff ); 613 }, this, null, 0xffffffff );
614 614
615 // IE6 BUG: Text fields and text areas are only half-rendered the first time the dialog appears in IE6 (#2661). 615 // IE6 BUG: Text fields and text areas are only half-rendered the first time the dialog appears in IE6 (http://dev.ckeditor.com/ticket/2661).
616 // This is still needed after [2708] and [2709] because text fields in hidden TR tags are still broken. 616 // This is still needed after [2708] and [2709] because text fields in hidden TR tags are still broken.
617 if ( CKEDITOR.env.ie6Compat ) { 617 if ( CKEDITOR.env.ie6Compat ) {
618 this.on( 'load', function() { 618 this.on( 'load', function() {
@@ -788,7 +788,7 @@ CKEDITOR.DIALOG_STATE_BUSY = 2;
788 var element = this._.element.getFirst(), rtl = this._.editor.lang.dir == 'rtl'; 788 var element = this._.element.getFirst(), rtl = this._.editor.lang.dir == 'rtl';
789 var isFixed = element.getComputedStyle( 'position' ) == 'fixed'; 789 var isFixed = element.getComputedStyle( 'position' ) == 'fixed';
790 790
791 // (#8888) In some cases of a very small viewport, dialog is incorrectly 791 // (http://dev.ckeditor.com/ticket/8888) In some cases of a very small viewport, dialog is incorrectly
792 // positioned in IE7. It also happens that it remains sticky and user cannot 792 // positioned in IE7. It also happens that it remains sticky and user cannot
793 // scroll down/up to reveal dialog's content below/above the viewport; this is 793 // scroll down/up to reveal dialog's content below/above the viewport; this is
794 // cumbersome. 794 // cumbersome.
@@ -862,8 +862,10 @@ CKEDITOR.DIALOG_STATE_BUSY = 2;
862 // Reset all inputs back to their default value. 862 // Reset all inputs back to their default value.
863 this.reset(); 863 this.reset();
864 864
865 // Select the first tab by default. 865 // Selects the first tab if no tab is already selected.
866 this.selectPage( this.definition.contents[ 0 ].id ); 866 if ( this._.currentTabId === null ) {
867 this.selectPage( this.definition.contents[ 0 ].id );
868 }
867 869
868 // Set z-index. 870 // Set z-index.
869 if ( CKEDITOR.dialog._.currentZIndex === null ) 871 if ( CKEDITOR.dialog._.currentZIndex === null )
@@ -1038,7 +1040,7 @@ CKEDITOR.DIALOG_STATE_BUSY = 2;
1038 commitContent: function() { 1040 commitContent: function() {
1039 var args = arguments; 1041 var args = arguments;
1040 this.foreach( function( widget ) { 1042 this.foreach( function( widget ) {
1041 // Make sure IE triggers "change" event on last focused input before closing the dialog. (#7915) 1043 // Make sure IE triggers "change" event on last focused input before closing the dialog. (http://dev.ckeditor.com/ticket/7915)
1042 if ( CKEDITOR.env.ie && this._.currentFocusIndex == widget.focusIndex ) 1044 if ( CKEDITOR.env.ie && this._.currentFocusIndex == widget.focusIndex )
1043 widget.getInputElement().$.blur(); 1045 widget.getInputElement().$.blur();
1044 1046
@@ -1090,11 +1092,11 @@ CKEDITOR.DIALOG_STATE_BUSY = 2;
1090 var editor = this._.editor; 1092 var editor = this._.editor;
1091 editor.focus(); 1093 editor.focus();
1092 1094
1093 // Give a while before unlock, waiting for focus to return to the editable. (#172) 1095 // Give a while before unlock, waiting for focus to return to the editable. (http://dev.ckeditor.com/ticket/172)
1094 setTimeout( function() { 1096 setTimeout( function() {
1095 editor.focusManager.unlock(); 1097 editor.focusManager.unlock();
1096 1098
1097 // Fixed iOS focus issue (#12381). 1099 // Fixed iOS focus issue (http://dev.ckeditor.com/ticket/12381).
1098 // Keep in mind that editor.focus() does not work in this case. 1100 // Keep in mind that editor.focus() does not work in this case.
1099 if ( CKEDITOR.env.iOS ) { 1101 if ( CKEDITOR.env.iOS ) {
1100 editor.window.focus(); 1102 editor.window.focus();
@@ -1111,7 +1113,7 @@ CKEDITOR.DIALOG_STATE_BUSY = 2;
1111 contentObj.resetInitValue && contentObj.resetInitValue(); 1113 contentObj.resetInitValue && contentObj.resetInitValue();
1112 } ); 1114 } );
1113 1115
1114 // Reset dialog state back to IDLE, if busy (#13213). 1116 // Reset dialog state back to IDLE, if busy (http://dev.ckeditor.com/ticket/13213).
1115 this.setState( CKEDITOR.DIALOG_STATE_IDLE ); 1117 this.setState( CKEDITOR.DIALOG_STATE_IDLE );
1116 }, 1118 },
1117 1119
@@ -1232,7 +1234,7 @@ CKEDITOR.DIALOG_STATE_BUSY = 2;
1232 1234
1233 // [IE] an invisible input[type='text'] will enlarge it's width 1235 // [IE] an invisible input[type='text'] will enlarge it's width
1234 // if it's value is long when it shows, so we clear it's value 1236 // if it's value is long when it shows, so we clear it's value
1235 // before it shows and then recover it (#5649) 1237 // before it shows and then recover it (http://dev.ckeditor.com/ticket/5649)
1236 if ( CKEDITOR.env.ie6Compat || CKEDITOR.env.ie7Compat ) { 1238 if ( CKEDITOR.env.ie6Compat || CKEDITOR.env.ie7Compat ) {
1237 clearOrRecoverTextInputValue( selected[ 1 ] ); 1239 clearOrRecoverTextInputValue( selected[ 1 ] );
1238 selected[ 1 ].show(); 1240 selected[ 1 ].show();
@@ -2199,7 +2201,7 @@ CKEDITOR.DIALOG_STATE_BUSY = 2;
2199 resizeCover = resizeFunc; 2201 resizeCover = resizeFunc;
2200 win.on( 'resize', resizeFunc ); 2202 win.on( 'resize', resizeFunc );
2201 resizeFunc(); 2203 resizeFunc();
2202 // Using Safari/Mac, focus must be kept where it is (#7027) 2204 // Using Safari/Mac, focus must be kept where it is (http://dev.ckeditor.com/ticket/7027)
2203 if ( !( CKEDITOR.env.mac && CKEDITOR.env.webkit ) ) 2205 if ( !( CKEDITOR.env.mac && CKEDITOR.env.webkit ) )
2204 coverElement.focus(); 2206 coverElement.focus();
2205 2207
@@ -2560,7 +2562,7 @@ CKEDITOR.DIALOG_STATE_BUSY = 2;
2560 if ( elementDefinition && elementDefinition.padding !== undefined ) { 2562 if ( elementDefinition && elementDefinition.padding !== undefined ) {
2561 styles.push( 'padding:' + cssLength( elementDefinition.padding ) ); 2563 styles.push( 'padding:' + cssLength( elementDefinition.padding ) );
2562 } 2564 }
2563 // In IE Quirks alignment has to be done on table cells. (#7324) 2565 // In IE Quirks alignment has to be done on table cells. (http://dev.ckeditor.com/ticket/7324)
2564 if ( CKEDITOR.env.ie && CKEDITOR.env.quirks && children[ i ].align ) { 2566 if ( CKEDITOR.env.ie && CKEDITOR.env.quirks && children[ i ].align ) {
2565 styles.push( 'text-align:' + children[ i ].align ); 2567 styles.push( 'text-align:' + children[ i ].align );
2566 } 2568 }
@@ -2619,7 +2621,7 @@ CKEDITOR.DIALOG_STATE_BUSY = 2;
2619 html.push( 'height:100%;' ); 2621 html.push( 'height:100%;' );
2620 html.push( 'width:' + cssLength( width || '100%' ), ';' ); 2622 html.push( 'width:' + cssLength( width || '100%' ), ';' );
2621 2623
2622 // (#10123) Temp fix for dialog broken layout in latest webkit. 2624 // (http://dev.ckeditor.com/ticket/10123) Temp fix for dialog broken layout in latest webkit.
2623 if ( CKEDITOR.env.webkit ) 2625 if ( CKEDITOR.env.webkit )
2624 html.push( 'float:none;' ); 2626 html.push( 'float:none;' );
2625 2627
@@ -2639,7 +2641,7 @@ CKEDITOR.DIALOG_STATE_BUSY = 2;
2639 styles.push( 'height:' + Math.floor( 100 / childHtmlList.length ) + '%' ); 2641 styles.push( 'height:' + Math.floor( 100 / childHtmlList.length ) + '%' );
2640 if ( elementDefinition && elementDefinition.padding !== undefined ) 2642 if ( elementDefinition && elementDefinition.padding !== undefined )
2641 styles.push( 'padding:' + cssLength( elementDefinition.padding ) ); 2643 styles.push( 'padding:' + cssLength( elementDefinition.padding ) );
2642 // In IE Quirks alignment has to be done on table cells. (#7324) 2644 // In IE Quirks alignment has to be done on table cells. (http://dev.ckeditor.com/ticket/7324)
2643 if ( CKEDITOR.env.ie && CKEDITOR.env.quirks && children[ i ].align ) 2645 if ( CKEDITOR.env.ie && CKEDITOR.env.quirks && children[ i ].align )
2644 styles.push( 'text-align:' + children[ i ].align ); 2646 styles.push( 'text-align:' + children[ i ].align );
2645 if ( styles.length > 0 ) 2647 if ( styles.length > 0 )
@@ -2984,7 +2986,7 @@ CKEDITOR.DIALOG_STATE_BUSY = 2;
2984 /** 2986 /**
2985 * Generic dialog command. It opens a specific dialog when executed. 2987 * Generic dialog command. It opens a specific dialog when executed.
2986 * 2988 *
2987 * // Register the "link" command, which opens the "link" dialog. 2989 * // Register the "link" command which opens the "link" dialog.
2988 * editor.addCommand( 'link', new CKEDITOR.dialogCommand( 'link' ) ); 2990 * editor.addCommand( 'link', new CKEDITOR.dialogCommand( 'link' ) );
2989 * 2991 *
2990 * @class 2992 * @class
@@ -2993,6 +2995,10 @@ CKEDITOR.DIALOG_STATE_BUSY = 2;
2993 * @param {String} dialogName The name of the dialog to open when executing 2995 * @param {String} dialogName The name of the dialog to open when executing
2994 * this command. 2996 * this command.
2995 * @param {Object} [ext] Additional command definition's properties. 2997 * @param {Object} [ext] Additional command definition's properties.
2998 * @param {String} [ext.tabId] You can provide additional property (`tabId`) if you wish to open the dialog on a specific tabId.
2999 *
3000 * // Open the dialog on the 'keystroke' tabId.
3001 * editor.addCommand( 'keystroke', new CKEDITOR.dialogCommand( 'a11yHelp', { tabId: 'keystroke' } ) );
2996 */ 3002 */
2997 CKEDITOR.dialogCommand = function( dialogName, ext ) { 3003 CKEDITOR.dialogCommand = function( dialogName, ext ) {
2998 this.dialogName = dialogName; 3004 this.dialogName = dialogName;
@@ -3001,7 +3007,13 @@ CKEDITOR.DIALOG_STATE_BUSY = 2;
3001 3007
3002 CKEDITOR.dialogCommand.prototype = { 3008 CKEDITOR.dialogCommand.prototype = {
3003 exec: function( editor ) { 3009 exec: function( editor ) {
3004 editor.openDialog( this.dialogName ); 3010 var tabId = this.tabId;
3011 editor.openDialog( this.dialogName, function( dialog ) {
3012 // Select different tab if it's provided (#830).
3013 if ( tabId ) {
3014 dialog.selectPage( tabId );
3015 }
3016 } );
3005 }, 3017 },
3006 3018
3007 // Dialog commands just open a dialog ui, thus require no undo logic, 3019 // Dialog commands just open a dialog ui, thus require no undo logic,