Ticket #8985: 8985.patch

File 8985.patch, 3.9 KB (added by Garry Yao, 12 years ago)
  • _source/plugins/dialogui/plugin.js

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    240240                                if ( elementDefinition.inputStyle )
    241241                                        attributes.style = elementDefinition.inputStyle;
    242242
    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 
    267243                                /** @ignore */
    268244                                var innerHTML = function()
    269245                                {
  • _source/plugins/dialog/plugin.js

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    397397                this.changeFocus = changeFocus;
    398398
    399399
    400                 function focusKeydownHandler( evt )
     400                function keydownHandler( evt )
    401401                {
    402402                        // If I'm not the top dialog, ignore.
    403403                        if ( me != CKEDITOR.dialog._.currentTop )
     
    450450                                changeFocus( 1 );
    451451                                processed = 1;
    452452                        }
     453                        // If user presses enter key in a text box, it implies clicking OK for the dialog.
     454                        else if ( keystroke == 13 )
     455                        {
     456                                // Find the currently focused element.
     457                                var focused;
     458                                this.foreach( function( widget )
     459                                {
     460                                        if ( this._.currentFocusIndex == widget.focusIndex )
     461                                                focused = widget;
     462                                });
    453463
     464                                if ( focused && focused.type == 'text' )
     465                                {
     466                                        var okBtn = this.getButton( 'ok' );
     467                                        CKEDITOR.tools.setTimeout( okBtn.click, 0, okBtn );
     468                                }
     469                        }
     470
    454471                        if ( processed )
    455472                        {
    456473                                evt.stop();
     
    458475                        }
    459476                }
    460477
    461                 function focusKeyPressHandler( evt )
     478                function keyPressHandler( evt )
    462479                {
    463480                        processed && evt.data.preventDefault();
    464481                }
     
    467484                // Add the dialog keyboard handlers.
    468485                this.on( 'show', function()
    469486                        {
    470                                 dialogElement.on( 'keydown', focusKeydownHandler, this, null, 0 );
     487                                dialogElement.on( 'keydown', keydownHandler, this, null, 0 );
    471488                                // Some browsers instead, don't cancel key events in the keydown, but in the
    472489                                // keypress. So we must do a longer trip in those cases. (#4531)
    473490                                if ( CKEDITOR.env.opera || ( CKEDITOR.env.gecko && CKEDITOR.env.mac ) )
    474                                         dialogElement.on( 'keypress', focusKeyPressHandler, this );
     491                                        dialogElement.on( 'keypress', keyPressHandler, this );
    475492
    476493                        } );
    477494                this.on( 'hide', function()
    478495                        {
    479                                 dialogElement.removeListener( 'keydown', focusKeydownHandler );
     496                                dialogElement.removeListener( 'keydown', keydownHandler );
    480497                                if ( CKEDITOR.env.opera || ( CKEDITOR.env.gecko && CKEDITOR.env.mac ) )
    481                                         dialogElement.removeListener( 'keypress', focusKeyPressHandler );
     498                                        dialogElement.removeListener( 'keypress', keyPressHandler );
    482499
    483500                                // Reset fields state when closing dialog.
    484501                                iterContents( function( item ) { resetField.apply( item ); } );
     
    486503                this.on( 'iframeAdded', function( evt )
    487504                        {
    488505                                var doc = new CKEDITOR.dom.document( evt.data.iframe.$.contentWindow.document );
    489                                 doc.on( 'keydown', focusKeydownHandler, this, null, 0 );
     506                                doc.on( 'keydown', keydownHandler, this, null, 0 );
    490507                        } );
    491508
    492509                // Auto-focus logic in dialog.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy