CKEDITOR.plugins.add('contextmenu',{requires:['menu'],onLoad:function(){CKEDITOR.plugins.contextMenu=CKEDITOR.tools.createClass({base:CKEDITOR.menu,$:function(a){this.base.call(this,a,{panel:{className:a.skinClass+' cke_contextmenu',attributes:{'aria-label':a.lang.contextmenu.options}}});},proto:{addTarget:function(a,b){if(CKEDITOR.env.opera&&!('oncontextmenu' in document.body)){var c;a.on('mousedown',function(g){g=g.data;if(g.$.button!=2){if(g.getKeystroke()==CKEDITOR.CTRL+1)a.fire('contextmenu',g);return;}if(b&&(CKEDITOR.env.mac?g.$.metaKey:g.$.ctrlKey))return;var h=g.getTarget();if(!c){var i=h.getDocument();c=i.createElement('input');c.$.type='button';i.getBody().append(c);}c.setAttribute('style','position:absolute;top:'+(g.$.clientY-2)+'px;left:'+(g.$.clientX-2)+'px;width:5px;height:5px;opacity:0.01');});a.on('mouseup',function(g){if(c){c.remove();c=undefined;a.fire('contextmenu',g.data);}});}a.on('contextmenu',function(g){var h=g.data;if(b&&(CKEDITOR.env.webkit?d:CKEDITOR.env.mac?h.$.metaKey:h.$.ctrlKey))return;h.preventDefault();var i=h.getTarget().getDocument().getDocumentElement(),j=h.$.clientX,k=h.$.clientY;CKEDITOR.tools.setTimeout(function(){this.open(i,null,j,k);},0,this);},this);if(CKEDITOR.env.opera)a.on('keypress',function(g){var h=g.data;if(h.$.keyCode===0)h.preventDefault();});if(CKEDITOR.env.webkit){var d,e=function(g){d=CKEDITOR.env.mac?g.data.$.metaKey:g.data.$.ctrlKey;},f=function(){d=0;};a.on('keydown',e);a.on('keyup',f);a.on('contextmenu',f);}},open:function(a,b,c,d){this.editor.focus();a=a||CKEDITOR.document.getDocumentElement();this.show(a,b,c,d);}}});},beforeInit:function(a){a.contextMenu=new CKEDITOR.plugins.contextMenu(a);a.addCommand('contextMenu',{exec:function(){a.contextMenu.open(a.document.getBody());}});}});
