Ticket #8985: 8985_3.patch
File 8985_3.patch, 6.9 KB (added by , 12 years ago) |
---|
-
_source/plugins/dialog/plugin.js
141 141 dir = editor.lang.dir, 142 142 tabsToRemove = {}, 143 143 i, 144 processed ;144 processed, stopPropagation; 145 145 146 146 if ( ( buttonsOrder == 'OS' && CKEDITOR.env.mac ) || // The buttons in MacOS Apps are in reverse order (#4750) 147 147 ( buttonsOrder == 'rtl' && dir == 'ltr' ) || … … 397 397 this.changeFocus = changeFocus; 398 398 399 399 400 function focusKeydownHandler( evt )400 function keydownHandler( evt ) 401 401 { 402 402 // If I'm not the top dialog, ignore. 403 403 if ( me != CKEDITOR.dialog._.currentTop ) 404 404 return; 405 405 406 406 var keystroke = evt.data.getKeystroke(), 407 rtl = editor.lang.dir == 'rtl'; 407 rtl = editor.lang.dir == 'rtl', 408 button; 408 409 409 processed = 0; 410 processed = stopPropagation = 0; 411 410 412 if ( keystroke == 9 || keystroke == CKEDITOR.SHIFT + 9 ) 411 413 { 412 414 var shiftPressed = ( keystroke == CKEDITOR.SHIFT + 9 ); … … 450 452 changeFocus( 1 ); 451 453 processed = 1; 452 454 } 453 454 if ( processed)455 // If user presses enter key in a text box, it implies clicking OK for the dialog. 456 else if ( keystroke == 13 /*ENTER*/ ) 455 457 { 456 evt.stop(); 457 evt.data.preventDefault(); 458 // Don't do that for a target that handles ENTER. 459 var target = evt.data.getTarget(); 460 if ( !target.is( 'a', 'button' ) && ( !target.is( 'input' ) || target.$.type != 'button' ) ) 461 { 462 button = this.getButton( 'ok' ); 463 button && CKEDITOR.tools.setTimeout( button.click, 0, button ); 464 processed = 1 465 } 466 stopPropagation = 1; // Always block the propagation (#4269) 458 467 } 468 else if ( keystroke == 27 /*ESC*/ ) 469 { 470 button = this.getButton( 'cancel' ); 471 472 // If there's a Cancel button, click it, else just fire the cancel event and hide the dialog. 473 if ( button ) 474 CKEDITOR.tools.setTimeout( button.click, 0, button ); 475 else 476 { 477 if ( this.fire( 'cancel', { hide : true } ).hide !== false ) 478 this.hide(); 479 } 480 stopPropagation = 1; // Always block the propagation (#4269) 481 } 482 else 483 return; 484 485 keypressHandler( evt ); 459 486 } 460 487 461 function focusKeyPressHandler( evt )488 function keypressHandler( evt ) 462 489 { 463 processed && evt.data.preventDefault(); 490 if ( processed ) 491 evt.data.preventDefault(1); 492 else if ( stopPropagation ) 493 evt.data.stopPropagation(); 464 494 } 465 495 466 496 var dialogElement = this._.element; 467 497 // Add the dialog keyboard handlers. 468 498 this.on( 'show', function() 469 499 { 470 dialogElement.on( 'keydown', focusKeydownHandler, this, null, 0 ); 500 dialogElement.on( 'keydown', keydownHandler, this ); 501 471 502 // Some browsers instead, don't cancel key events in the keydown, but in the 472 // keypress. So we must do a longer trip in those cases. (#4531 )473 if ( CKEDITOR.env.opera || ( CKEDITOR.env.gecko && CKEDITOR.env.mac ))474 dialogElement.on( 'keypress', focusKeyPressHandler, this );503 // keypress. So we must do a longer trip in those cases. (#4531,#8985) 504 if ( CKEDITOR.env.opera || CKEDITOR.env.gecko ) 505 dialogElement.on( 'keypress', keypressHandler, this ); 475 506 476 507 } ); 477 508 this.on( 'hide', function() 478 509 { 479 dialogElement.removeListener( 'keydown', focusKeydownHandler );480 if ( CKEDITOR.env.opera || ( CKEDITOR.env.gecko && CKEDITOR.env.mac ))481 dialogElement.removeListener( 'keypress', focusKeyPressHandler );510 dialogElement.removeListener( 'keydown', keydownHandler ); 511 if ( CKEDITOR.env.opera || CKEDITOR.env.gecko ) 512 dialogElement.removeListener( 'keypress', keypressHandler ); 482 513 483 514 // Reset fields state when closing dialog. 484 515 iterContents( function( item ) { resetField.apply( item ); } ); … … 486 517 this.on( 'iframeAdded', function( evt ) 487 518 { 488 519 var doc = new CKEDITOR.dom.document( evt.data.iframe.$.contentWindow.document ); 489 doc.on( 'keydown', focusKeydownHandler, this, null, 0 );520 doc.on( 'keydown', keydownHandler, this, null, 0 ); 490 521 } ); 491 522 492 523 // Auto-focus logic in dialog. … … 815 846 element.on( 'keydown', accessKeyDownHandler ); 816 847 element.on( CKEDITOR.env.opera ? 'keypress' : 'keyup', accessKeyUpHandler ); 817 848 818 // Prevent some keys from bubbling up. (#4269)819 for ( var event in { keyup :1, keydown :1, keypress :1 } )820 element.on( event, preventKeyBubbling );821 822 // Register the Esc hotkeys.823 registerAccessKey( this, this, '\x1b', null, function()824 {825 var button = this.getButton( 'cancel' );826 // If there's a Cancel button, click it, else just fire the cancel event and hide the dialog827 if ( button )828 button.click();829 else830 {831 if ( this.fire( 'cancel', { hide : true } ).hide !== false )832 this.hide();833 }834 } );835 836 849 // Reset the hasFocus state. 837 850 this._.hasFocus = false; 838 851 … … 979 992 element.removeListener( 'keydown', accessKeyDownHandler ); 980 993 element.removeListener( CKEDITOR.env.opera ? 'keypress' : 'keyup', accessKeyUpHandler ); 981 994 982 // Remove bubbling-prevention handler. (#4269)983 for ( var event in { keyup :1, keydown :1, keypress :1 } )984 element.removeListener( event, preventKeyBubbling );985 986 995 var editor = this._.editor; 987 996 editor.focus(); 988 997 … … 2199 2208 { 2200 2209 }; 2201 2210 2202 // ESC, ENTER2203 var preventKeyBubblingKeys = { 27 :1, 13 :1 };2204 var preventKeyBubbling = function( e )2205 {2206 if ( e.data.getKeystroke() in preventKeyBubblingKeys )2207 e.data.stopPropagation();2208 };2209 2210 2211 (function() 2211 2212 { 2212 2213 CKEDITOR.ui.dialog = -
_source/plugins/dialogui/plugin.js
240 240 if ( elementDefinition.inputStyle ) 241 241 attributes.style = elementDefinition.inputStyle; 242 242 243 // If user presses Enter in a text box, it implies clicking OK for the dialog.244 var me = this, keyPressedOnMe = false;245 dialog.on( 'load', function()246 {247 me.getInputElement().on( 'keydown', function( evt )248 {249 if ( evt.data.getKeystroke() == 13 )250 keyPressedOnMe = true;251 } );252 253 // Lower the priority this 'keyup' since 'ok' will close the dialog.(#3749)254 me.getInputElement().on( 'keyup', function( evt )255 {256 if ( evt.data.getKeystroke() == 13 && keyPressedOnMe )257 {258 dialog.getButton( 'ok' ) && setTimeout( function ()259 {260 dialog.getButton( 'ok' ).click();261 }, 0 );262 keyPressedOnMe = false;263 }264 }, null, null, 1000 );265 } );266 267 243 /** @ignore */ 268 244 var innerHTML = function() 269 245 {