Ticket #3389: 3389_3.patch

File 3389_3.patch, 7.3 KB (added by Garry Yao, 15 years ago)
  • _source/plugins/menu/plugin.js

     
    7777                                        return;
    7878                                }
    7979
     80                                // Record the focused parent menu item first(#3389).
     81                                var block = this._.panel.getBlock( this.id );
     82                                block._.markItem( index );
     83
     84
    8085                                // Create the submenu, if not available, or clean the existing
    8186                                // one.
    8287                                if ( menu )
     
    8691                                        menu = this._.subMenu = new CKEDITOR.menu( this.editor, this._.level + 1 );
    8792                                        menu.parent = this;
    8893                                        menu.onClick = CKEDITOR.tools.bind( this.onClick, this );
     94                                        // Sub menu use their own scope for binding onEscape.
     95                                        menu.onEscape = this.onEscape;
    8996                                }
    9097
    9198                                // Add all submenu items to the menu.
     
    138145                                                },
    139146                                                this._.level);
    140147
    141                                         panel.onEscape = CKEDITOR.tools.bind( function()
     148                                        panel.onEscape = CKEDITOR.tools.bind( function( keystroke )
    142149                                        {
    143                                                 this.onEscape && this.onEscape();
    144                                                 this.hide();
     150                                                if ( this.onEscape && this.onEscape( keystroke ) === false )
     151                                                        return false;
    145152                                        },
    146153                                        this );
    147154
  • _source/core/dom/node.js

     
    2525        {
    2626                switch ( domNode.nodeType )
    2727                {
     28                        // Safari don't consider document as element node type(#3389).
     29                        case CKEDITOR.NODE_DOCUMENT :
     30                                return new CKEDITOR.dom.document( domNode );
     31
    2832                        case CKEDITOR.NODE_ELEMENT :
    2933                                return new CKEDITOR.dom.element( domNode );
    3034
     
    4953CKEDITOR.NODE_ELEMENT = 1;
    5054
    5155/**
     56 * Document node type.
     57 * @constant
     58 * @example
     59 */
     60CKEDITOR.NODE_DOCUMENT = 9;
     61
     62/**
    5263 * Text node type.
    5364 * @constant
    5465 * @example
  • _source/plugins/listblock/plugin.js

     
    1111        {
    1212                CKEDITOR.ui.panel.prototype.addListBlock = function( name, multiSelect )
    1313                {
    14                         return this.addBlock( name, new CKEDITOR.ui.listBlock( this.getHolderElement(), multiSelect ) );
     14                        return this.addBlock( name, new CKEDITOR.ui.listBlock( this, this.getHolderElement(), multiSelect ) );
    1515                };
    1616
    1717                CKEDITOR.ui.listBlock = CKEDITOR.tools.createClass(
    1818                        {
    1919                                base : CKEDITOR.ui.panel.block,
    2020
    21                                 $ : function( blockHolder, multiSelect )
     21                                $ : function( panel, blockHolder, multiSelect )
    2222                                {
    2323                                        // Call the base contructor.
    24                                         this.base( blockHolder );
     24                                        this.base( panel, blockHolder );
    2525
    2626                                        this.multiSelect = !!multiSelect;
    2727
  • _source/plugins/floatpanel/plugin.js

     
    153153
    154154                                        focused.on( 'blur', function( ev )
    155155                                                {
    156                                                         if ( CKEDITOR.env.ie && !this.allowBlur() )
     156                                                        if ( !this.allowBlur() )
    157157                                                                return;
    158158
    159159                                                        // As we are using capture to register the listener,
     
    163163                                                        var target = ev.data.getTarget(),
    164164                                                                targetWindow = target.getWindow && target.getWindow();
    165165
    166                                                         if ( targetWindow && targetWindow.equals( focused ) )
     166                                                        // Safari always report document as target when window blurred(#3389).
     167                                                        if ( ( !CKEDITOR.env.webkit || target.$.nodeType != CKEDITOR.NODE_DOCUMENT )
     168                                                                 && targetWindow && targetWindow.equals( focused ) )
    167169                                                                return;
    168170
    169171                                                        if ( this.visible && !this._.activeChild && !isShowing )
     
    184186                                        this._.blurSet = 1;
    185187                                }
    186188
    187                                 panel.onEscape = CKEDITOR.tools.bind( function()
     189                                panel.onEscape = CKEDITOR.tools.bind( function( keystroke )
    188190                                        {
    189                                                 this.onEscape && this.onEscape();
     191                                                if ( this.onEscape && this.onEscape( keystroke ) === false );
     192                                                        return false;
    190193                                        },
    191194                                        this );
    192195
  • _source/plugins/panel/plugin.js

     
    180180                                                        return;
    181181                                                }
    182182
    183                                                 if ( keystroke == 27 )          // ESC
    184                                                         this.onEscape && this.onEscape();
     183                                                if ( keystroke == 27 || keystroke == 37 )               // ESC/ARROW-LEFT
     184                                                        if ( this.onEscape && this.onEscape( keystroke ) === false );
     185                                                                evt.data.preventDefault();
    185186                                        },
    186187                                        this );
    187188
     
    198199
    199200        addBlock : function( name, block )
    200201        {
    201                 block = this._.blocks[ name ] = block || new CKEDITOR.ui.panel.block( this.getHolderElement() );
     202                block = this._.blocks[ name ] = block || new CKEDITOR.ui.panel.block( this, this.getHolderElement() );
    202203
    203204                if ( !this._.currentBlock )
    204205                        this.showBlock( name );
     
    235236
    236237CKEDITOR.ui.panel.block = CKEDITOR.tools.createClass(
    237238{
    238         $ : function( blockHolder )
     239        $ : function( panel, blockHolder )
    239240        {
    240241                this.element = blockHolder.append(
    241242                        blockHolder.getDocument().createElement( 'div',
     
    249250                                                display : 'none'
    250251                                        }
    251252                                }) );
    252 
     253                this._.panel = panel;
    253254                this.keys = {};
    254255
    255256                this._.focusIndex = -1;
     
    259260                        CKEDITOR.plugins.contextMenu.prototype.addDisabledTarget( this.element );
    260261        },
    261262
    262         _ : {},
    263 
     263        _ : {
     264               
     265                /**
     266                 * Mark the item specified by the index as current activated.
     267                 */
     268                markItem: function( index )
     269                {
     270                        if ( index == -1 )
     271                                return;
     272                        var links = this.element.getElementsByTag( 'a' );
     273                        var item = links.getItem( this._.focusIndex = index );
     274
     275                        // Safari need focus on the iframe window first(#3389), but we need
     276                        // lock the blur to avoid hiding the panel.
     277                        if ( CKEDITOR.env.webkit )
     278                        {
     279                                this._.panel.allowBlur = false;
     280                                item.getDocument().getWindow().focus();
     281                                this._.panel.allowBlur = true;
     282                        }
     283                        item.focus();
     284                }
     285        },
     286
    264287        proto :
    265288        {
    266289                show : function()
  • _source/plugins/contextmenu/plugin.js

     
    7575                                        noUnlock = false;
    7676                                }, this );
    7777
    78                                 menu.onEscape = function()
     78                                menu.onEscape = function( keystroke )
    7979                                {
    80                                         editor.focus();
    81 
    82                                         if ( CKEDITOR.env.ie )
    83                                                 editor.getSelection().unlock( true );
     80                                        var parent = this.parent;
     81                                        // 1. If it's sub-menu, restore the last focused item
     82                                        // of upper level menu.
     83                                        // 2. In case of a top-menu, close it.
     84                                        if( parent )
     85                                        {
     86                                                parent._.panel.hideChild();
     87                                                // Restore parent block item focus.
     88                                                var parentBlock = parent._.panel._.panel._.currentBlock,
     89                                                        parentFocusIndex =  parentBlock._.focusIndex;
     90                                                parentBlock._.markItem( parentFocusIndex );
     91                                        }
     92                                        else if ( keystroke == 27 )
     93                                        {
     94                                                this.hide();
     95                                                editor.focus();
     96       
     97                                                if ( CKEDITOR.env.ie )
     98                                                        editor.getSelection().unlock( true );
     99                                        }
     100                                        return false;
    84101                                };
    85102                        }
    86103
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy