X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fcontextmenu%2Fplugin.js;h=1c83546cad690c43846d4033f0910274325c08eb;hb=c6e377a02b54abc07129d72b632763c727476a15;hp=6cbc3e764cabf03df978ea092bbb5df744d75ea5;hpb=7cd80714081a8ffdf4a1a8d2c72f120ed5ef3d6d;p=ckeditor.git diff --git a/_source/plugins/contextmenu/plugin.js b/_source/plugins/contextmenu/plugin.js index 6cbc3e7..1c83546 100644 --- a/_source/plugins/contextmenu/plugin.js +++ b/_source/plugins/contextmenu/plugin.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -54,26 +54,18 @@ CKEDITOR.plugins.contextMenu = CKEDITOR.tools.createClass( menu = this._.menu = new CKEDITOR.menu( editor ); menu.onClick = CKEDITOR.tools.bind( function( item ) { - var noUnlock = true; menu.hide(); - if ( CKEDITOR.env.ie ) - menu.onEscape(); - if ( item.onClick ) item.onClick(); else if ( item.command ) editor.execCommand( item.command ); - noUnlock = false; }, this ); menu.onEscape = function() { editor.focus(); - - if ( CKEDITOR.env.ie ) - editor.getSelection().unlock( true ); }; } @@ -83,17 +75,15 @@ CKEDITOR.plugins.contextMenu = CKEDITOR.tools.createClass( var selection = this.editor.getSelection(), element = selection && selection.getStartElement(); - // Lock the selection in IE, so it can be restored when closing the - // menu. - if ( CKEDITOR.env.ie ) - selection.lock(); - menu.onHide = CKEDITOR.tools.bind( function() { menu.onHide = null; if ( CKEDITOR.env.ie ) - editor.getSelection().unlock(); + { + var selection = editor.getSelection(); + selection && selection.unlock(); + } this.onHide && this.onHide(); }, @@ -140,7 +130,7 @@ CKEDITOR.plugins.contextMenu = CKEDITOR.tools.createClass( element.on( 'mousedown', function( evt ) { evt = evt.data; - if( evt.$.button != 2 ) + if ( evt.$.button != 2 ) { if ( evt.getKeystroke() == CKEDITOR.CTRL + 1 ) element.fire( 'contextmenu', evt ); @@ -153,7 +143,7 @@ CKEDITOR.plugins.contextMenu = CKEDITOR.tools.createClass( var target = evt.getTarget(); - if( !contextMenuOverrideButton ) + if ( !contextMenuOverrideButton ) { var ownerDoc = target.getDocument(); contextMenuOverrideButton = ownerDoc.createElement( 'input' ) ; @@ -189,6 +179,14 @@ CKEDITOR.plugins.contextMenu = CKEDITOR.tools.createClass( ( CKEDITOR.env.webkit ? holdCtrlKey : domEvent.$.ctrlKey || domEvent.$.metaKey ) ) return; + // Selection will be unavailable after context menu shows up + // in IE, lock it now. + if ( CKEDITOR.env.ie ) + { + var selection = this.editor.getSelection(); + selection && selection.lock(); + } + // Cancel the browser context menu. domEvent.preventDefault(); @@ -204,7 +202,7 @@ CKEDITOR.plugins.contextMenu = CKEDITOR.tools.createClass( }, this ); - if( CKEDITOR.env.webkit ) + if ( CKEDITOR.env.webkit ) { var holdCtrlKey, onKeyDown = function( event )