Changeset 7516
- Timestamp:
- 06/27/12 18:10:56 (12 months ago)
- Location:
- CKEditor/trunk
- Files:
-
- 3 edited
-
CHANGES.html (modified) (1 diff)
-
_source/plugins/dialog/plugin.js (modified) (9 diffs)
-
_source/plugins/dialogui/plugin.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
CKEditor/trunk/CHANGES.html
r7515 r7516 60 60 <li><a href="http://dev.ckeditor.com/ticket/8917">#8917</a> : [IE7] Dialog size are stretched when long text field value is received.</li> 61 61 <li><a href="http://dev.ckeditor.com/ticket/8945">#8945</a> : Fake elements now show alternative text on High Contrast mode.</li> 62 <li><a href="http://dev.ckeditor.com/ticket/8985">#8985</a> : Better handling of ENTER key events on dialogs.</li> 62 63 </ul> 63 64 <h3> -
CKEditor/trunk/_source/plugins/dialog/plugin.js
r7477 r7516 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) … … 398 398 399 399 400 function focusKeydownHandler( evt )400 function keydownHandler( evt ) 401 401 { 402 402 // If I'm not the top dialog, ignore. … … 405 405 406 406 var keystroke = evt.data.getKeystroke(), 407 rtl = editor.lang.dir == 'rtl'; 408 409 processed = 0; 407 rtl = editor.lang.dir == 'rtl', 408 button; 409 410 processed = stopPropagation = 0; 411 410 412 if ( keystroke == 9 || keystroke == CKEDITOR.SHIFT + 9 ) 411 413 { … … 451 453 processed = 1; 452 454 } 453 455 // If user presses enter key in a text box, it implies clicking OK for the dialog. 456 else if ( keystroke == 13 /*ENTER*/ ) 457 { 458 // Don't do that for a target that handles ENTER. 459 var target = evt.data.getTarget(); 460 if ( !target.is( 'a', 'button', 'select' ) && ( !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) 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 ); 486 } 487 488 function keypressHandler( evt ) 489 { 454 490 if ( processed ) 455 { 456 evt.stop(); 457 evt.data.preventDefault(); 458 } 459 } 460 461 function focusKeyPressHandler( evt ) 462 { 463 processed && evt.data.preventDefault(); 491 evt.data.preventDefault(1); 492 else if ( stopPropagation ) 493 evt.data.stopPropagation(); 464 494 } 465 495 … … 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. … … 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 … … 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; … … 979 992 element.removeListener( 'keydown', accessKeyDownHandler ); 980 993 element.removeListener( CKEDITOR.env.opera ? 'keypress' : 'keyup', accessKeyUpHandler ); 981 982 // Remove bubbling-prevention handler. (#4269)983 for ( var event in { keyup :1, keydown :1, keypress :1 } )984 element.removeListener( event, preventKeyBubbling );985 994 986 995 var editor = this._.editor; … … 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 { -
CKEditor/trunk/_source/plugins/dialogui/plugin.js
r7495 r7516 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()
Note: See TracChangeset
for help on using the changeset viewer.
