Ticket #6011: 6011_2.patch

File 6011_2.patch, 5.2 KB (added by Tobiasz Cudnik, 14 years ago)
  • _source/plugins/clipboard/plugin.js

     
    284284        // Register the plugin.
    285285        CKEDITOR.plugins.add( 'clipboard',
    286286                {
    287                         requires : [ 'dialog', 'htmldataprocessor' ],
     287                        requires : [ 'htmldataprocessor' ],
    288288                        init : function( editor )
    289289                        {
    290290                                // Inserts processed data into the editor at the end of the
     
    304304                                                setTimeout( function()
    305305                                                {
    306306                                                        // Open default paste dialog.
    307                                                         editor.openDialog( 'paste' );
     307                                                        editor.openDialog && editor.openDialog( 'paste' );
    308308                                                }, 0 );
    309309                                        });
    310310
     
    336336                                addButtonCommand( 'Copy', 'copy', new cutCopyCmd( 'copy' ), 4 );
    337337                                addButtonCommand( 'Paste', 'paste', pasteCmd, 8 );
    338338
    339                                 CKEDITOR.dialog.add( 'paste', CKEDITOR.getUrl( this.path + 'dialogs/paste.js' ) );
     339                                // Add dialog if plugin is available.
     340                                if ( CKEDITOR.dialog )
     341                                        CKEDITOR.dialog.add( 'paste', CKEDITOR.getUrl( this.path + 'dialogs/paste.js' ) );
    340342
    341343                                editor.on( 'key', onKey, editor );
    342344
  • _source/plugins/pastetext/plugin.js

     
    2727
    2828                        if ( !clipboardText )   // Clipboard access privilege is not granted.
    2929                        {
    30                                 editor.openDialog( 'pastetext' );
     30                                editor.openDialog && editor.openDialog( 'pastetext' );
    3131                                return false;
    3232                        }
    3333                        else
     
    6565                                        command : commandName
    6666                                });
    6767
    68                         CKEDITOR.dialog.add( commandName, CKEDITOR.getUrl( this.path + 'dialogs/pastetext.js' ) );
     68                        // Add dialog if plugin is available.
     69                        if ( CKEDITOR.dialog )
     70                                CKEDITOR.dialog.add( commandName, CKEDITOR.getUrl( this.path + 'dialogs/pastetext.js' ) );
    6971
    7072                        if ( editor.config.forcePasteAsPlainText )
    7173                        {
  • _source/plugins/contextmenu/plugin.js

     
    139139                        }
    140140
    141141                        // Don't show context menu with zero items.
    142                         menu.items.length && menu.show( offsetParent, corner || ( editor.lang.dir == 'rtl' ? 2 : 1 ), offsetX, offsetY );
    143142                }
    144143        },
    145144
  • _source/plugins/menubutton/plugin.js

     
    55
    66CKEDITOR.plugins.add( 'menubutton',
    77{
    8         requires : [ 'button', 'contextmenu' ],
     8        requires : [ 'button', 'menu' ],
    99        beforeInit : function( editor )
    1010        {
    1111                editor.ui.addHandler( CKEDITOR.UI_MENUBUTTON, CKEDITOR.ui.menuButton.handler );
     
    2323{
    2424        var clickFn = function( editor )
    2525        {
    26                 var _ = this._;
     26                var _ = this._,
     27                        selection;
    2728
    2829                // Do nothing if this button is disabled.
    2930                if ( _.state === CKEDITOR.TRISTATE_DISABLED )
     
    3334
    3435                // Check if we already have a menu for it, otherwise just create it.
    3536                var menu = _.menu;
    36                 if ( !menu )
     37               
     38                if ( menu )
    3739                {
    38                         menu = _.menu = new CKEDITOR.plugins.contextMenu( editor );
    39                         menu.definition.panel.attributes[ 'aria-label' ] = editor.lang.common.options;
     40                        menu.hide();
     41                        menu.removeAll();
     42                }
     43                else
     44                {
     45                        menu = _.menu = new CKEDITOR.menu( editor,
     46                        {
     47                                panel:
     48                                {
     49                                        className : editor.skinClass,
     50                                        attributes : { 'aria-label' : editor.lang.common.options }
     51                                }
     52                        });
    4053
    4154                        menu.onHide = CKEDITOR.tools.bind( function()
    4255                                {
     56                                        menu.onHide = null;
     57
     58                                        if ( CKEDITOR.env.ie )
     59                                        {
     60                                                var selection = editor.getSelection();
     61                                                selection && selection.unlock();
     62                                        }
     63                                       
    4364                                        this.setState( _.previousState );
    4465                                },
    4566                                this );
    4667
    47                         // Initialize the menu items at this point.
    48                         if ( this.onMenu )
    49                         {
    50                                 menu.addListener( this.onMenu );
    51                         }
    52                 }
     68                        menu.onEscape = function( keystroke )
     69                        {
     70                                if ( keystroke == 27 )
     71                                {
     72                                        this.hide();
     73                                        editor.focus();
     74                                }
     75                                return false;
     76                        };
     77
     78                        menu.onClick = CKEDITOR.tools.bind( function( item )
     79                        {
     80                                menu.hide();
     81
     82                                if ( item.onClick )
     83                                        item.onClick();
     84                                else if ( item.command )
     85                                        editor.execCommand( item.command );
     86
     87                        }, this );
     88                }
     89
     90                // Initialize the menu items at this point.
     91                if ( this.onMenu )
     92                {
     93                        var element = selection && selection.getStartElement();
     94                        selection = editor.getSelection();
     95
     96                        var listenerItems = this.onMenu( element, selection );
     97
     98                        if ( listenerItems )
     99                        {
     100                                for ( var itemName in listenerItems )
     101                                {
     102                                        var item = editor.getMenuItem( itemName );
     103
     104                                        if ( item )
     105                                        {
     106                                                item.state = listenerItems[ itemName ];
     107                                                menu.add( item );
     108                                        }
     109                                }
     110                        }
     111                }
    53112
    54113                if ( _.on )
    55114                {
     
    59118
    60119                this.setState( CKEDITOR.TRISTATE_ON );
    61120
     121                // Selection will be unavailable after context menu shows up
     122                // in IE, lock it now.
     123                if ( CKEDITOR.env.ie )
     124                {
     125                        selection = editor.getSelection();
     126                        selection && selection.lock();
     127                }
     128               
    62129                menu.show( CKEDITOR.document.getById( this._.id ), 4 );
    63130        };
    64131
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy