Ticket #3085: 3085_5.patch

File 3085_5.patch, 6.0 KB (added by Frederico Caldeira Knabben, 15 years ago)
  • _source/plugins/contextmenu/plugin.js

     
    1010        beforeInit : function( editor )
    1111        {
    1212                editor.contextMenu = new CKEDITOR.plugins.contextMenu( editor );
     13
     14                editor.addCommand( 'contextMenu',
     15                        {
     16                                exec : function()
     17                                        {
     18                                                editor.contextMenu.show();
     19                                        }
     20                        });
    1321        }
    1422});
    1523
     
    3139
    3240        _ :
    3341        {
    34                 onMenu : function( domEvent )
     42                onMenu : function( offsetParent, offsetX, offsetY )
    3543                {
    36                         // Cancel the browser context menu.
    37                         domEvent.preventDefault();
    38 
    3944                        var menu = this._.menu,
    4045                                editor = this.editor;
    4146
     
    4752                        else
    4853                        {
    4954                                menu = this._.menu = new CKEDITOR.menu( editor );
    50                                 menu.onClick = function( item )
     55                                menu.onClick = CKEDITOR.tools.bind( function( item )
    5156                                {
    5257                                        menu.hide();
    5358                                        editor.focus();
     
    5560                                        if ( item.onClick )
    5661                                                item.onClick();
    5762                                        else if ( item.command )
     63                                        {
     64                                                if ( CKEDITOR.env.ie )
     65                                                        this.restoreSelection();
     66
    5867                                                editor.execCommand( item.command );
     68                                        }
     69                                }, this );
     70
     71                                menu.onEscape = function()
     72                                {
     73                                        editor.focus();
    5974                                };
    6075                        }
    6176
     
    85100                                }
    86101                        }
    87102
    88                         menu.show( domEvent.getTarget().getDocument().getDocumentElement(), 1, domEvent.$.clientX, domEvent.$.clientY );
     103                        if ( CKEDITOR.env.ie )
     104                                this.saveSelection();
     105
     106                        menu.show( offsetParent, 1, offsetX, offsetY );
    89107                }
    90108        },
    91109
     
    95113                {
    96114                        element.on( 'contextmenu', function( event )
    97115                                {
    98                                         return this._.onMenu( event.data );
     116                                        var domEvent = event.data;
     117
     118                                        // Cancel the browser context menu.
     119                                        domEvent.preventDefault();
     120
     121                                        var offsetParent = domEvent.getTarget().getDocument().getDocumentElement();
     122                                                offsetX = domEvent.$.clientX,
     123                                                offsetY = domEvent.$.clientY;
     124
     125                                        CKEDITOR.tools.setTimeout( function()
     126                                                {
     127                                                        this._.onMenu( offsetParent, offsetX, offsetY );
     128                                                },
     129                                                0, this );
    99130                                },
    100131                                this );
    101132                },
     
    103134                addListener : function( listenerFn )
    104135                {
    105136                        this._.listeners.push( listenerFn );
     137                },
     138
     139                show : function()
     140                {
     141                        this.editor.focus();
     142                        this._.onMenu( CKEDITOR.document.getDocumentElement(), 0, 0 );
     143                },
     144               
     145                /**
     146                 * Saves the current selection position in the editor.
     147                 */
     148                saveSelection : function()
     149                {
     150                        if ( this.editor.mode == 'wysiwyg' )
     151                        {
     152                                this.editor.focus();
     153
     154                                var selection = new CKEDITOR.dom.selection( this.editor.document );
     155                                this._.selectedRanges = selection.getRanges();
     156                        }
     157                        else
     158                                delete this._.selectedRanges;
     159                },
     160
     161                /**
     162                 * Restores the editor's selection from the previously saved position in this
     163                 * dialog.
     164                 */
     165                restoreSelection : function()
     166                {
     167                        if ( this.editor.mode == 'wysiwyg' && this._.selectedRanges )
     168                        {
     169                                this.editor.focus();
     170                                ( new CKEDITOR.dom.selection( this.editor.document ) ).selectRanges( this._.selectedRanges );
     171                        }
    106172                }
    107173        }
    108174});
  • _source/plugins/keystrokes/plugin.js

     
    172172        [ CKEDITOR.ALT + 121 /*F10*/, 'toolbarFocus' ],
    173173        [ CKEDITOR.ALT + 122 /*F11*/, 'elementsPathFocus' ],
    174174
     175        [ CKEDITOR.SHIFT + 121 /*F10*/, 'contextMenu' ],
     176
    175177        [ CKEDITOR.CTRL + 90 /*Z*/, 'undo' ],
    176178        [ CKEDITOR.CTRL + 89 /*Y*/, 'redo' ],
    177179        [ CKEDITOR.CTRL + CKEDITOR.SHIFT + 90 /*Z*/, 'redo' ],
  • _source/plugins/menu/plugin.js

     
    125125                                                },
    126126                                                this._.level);
    127127
     128                                        panel.onEscape = CKEDITOR.tools.bind( function()
     129                                        {
     130                                                this.hide();
     131                                                this.onEscape && this.onEscape();
     132                                        },
     133                                        this );
     134
    128135                                        // Create an autosize block inside the panel.
    129136                                        var block = panel.addBlock( this.id );
    130137                                        block.autoSize = true;
    131138
     139                                        var keys = block.keys;
     140                                        keys[ 40 ]      = 'next';                                       // ARROW-DOWN
     141                                        keys[ 9 ]       = 'next';                                       // TAB
     142                                        keys[ 38 ]      = 'prev';                                       // ARROW-UP
     143                                        keys[ CKEDITOR.SHIFT + 9 ]      = 'prev';       // SHIFT + TAB
     144                                        keys[ 32 ]      = 'click';                                      // SPACE
     145                                        keys[ 39 ]      = 'click';                                      // ARROW-RIGHT
     146
    132147                                        element = this._.element = block.element;
    133148                                        element.addClass( editor.skinClass );
    134149                                        element.getDocument().getBody().setStyle( 'overflow', 'hidden' );
     
    253268                                        ' class="', classes, '" href="javascript:void(\'', ( this.label || '' ).replace( "'", '' ), '\')"' +
    254269                                        ' title="', this.label, '"' +
    255270                                        ' tabindex="-1"' +
     271                                        '_cke_focus=1' +
    256272                                        ' hidefocus="true"' );
    257273
    258274                        // Some browsers don't cancel key events in the keydown but in the
  • _source/skins/default/menu.css

     
    1414}
    1515
    1616.cke_skin_default .cke_menuitem a:hover,
    17 .cke_skin_default .cke_menuitem a:focus
     17.cke_skin_default .cke_menuitem a:focus,
     18.cke_skin_default .cke_menuitem a:active
    1819{
    1920        background-color: #8f8f73;
    2021        display:block;
     
    4142}
    4243
    4344.cke_skin_default .cke_menuitem a:hover .cke_icon,
    44 .cke_skin_default .cke_menuitem a:focus .cke_icon
     45.cke_skin_default .cke_menuitem a:focus .cke_icon,
     46.cke_skin_default .cke_menuitem a:active .cke_icon
    4547{
    4648        background-color: #737357;
    4749        border: solid 4px #737357;
     
    6062}
    6163
    6264.cke_skin_default .cke_menuitem a:hover .cke_label,
    63 .cke_skin_default .cke_menuitem a:focus .cke_label
     65.cke_skin_default .cke_menuitem a:focus .cke_label,
     66.cke_skin_default .cke_menuitem a:active .cke_label
    6467{
    6568        color: #fff;
    6669        background-color: #8f8f73;
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy