(function(){var e=tinymce.dom.Event,f=tinymce.each,d=tinymce.DOM;tinymce.create("tinymce.plugins.ContextMenu",{init:function(k){var b=this,j,l,a;b.editor=k;l=k.settings.contextmenu_never_use_native;b.onContextMenu=new tinymce.util.Dispatcher(this);j=k.onContextMenu.add(function(h,g){if((a!==0?a:g.ctrlKey)&&!l){return}e.cancel(g);if(g.target.nodeName=="IMG"){h.selection.select(g.target)}b._getMenu(h).showMenu(g.clientX||g.pageX,g.clientY||g.pageX);e.add(h.getDoc(),"click",function(i){c(h,i)});h.nodeChanged()});k.onRemove.add(function(){if(b._menu){b._menu.removeAll()}});function c(h,g){a=0;if(g&&g.button==2){a=g.ctrlKey;return}if(b._menu){b._menu.removeAll();b._menu.destroy();e.remove(h.getDoc(),"click",c)}}k.onMouseDown.add(c);k.onKeyDown.add(c);k.onKeyDown.add(function(h,g){if(g.shiftKey&&!g.ctrlKey&&!g.altKey&&g.keyCode===121){e.cancel(g);j(h,g)}})},getInfo:function(){return{longname:"Contextmenu",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/contextmenu",version:tinymce.majorVersion+"."+tinymce.minorVersion}},_getMenu:function(n){var a=this,p=a._menu,m=n.selection,q=m.isCollapsed(),r=m.getNode()||n.getBody(),o,b,c;if(p){p.removeAll();p.destroy()}b=d.getPos(n.getContentAreaContainer());c=d.getPos(n.getContainer());p=n.controlManager.createDropMenu("contextmenu",{offset_x:b.x+n.getParam("contextmenu_offset_x",0),offset_y:b.y+n.getParam("contextmenu_offset_y",0),constrain:1,keyboard_focus:true});a._menu=p;p.add({title:"advanced.cut_desc",icon:"cut",cmd:"Cut"}).setDisabled(q);p.add({title:"advanced.copy_desc",icon:"copy",cmd:"Copy"}).setDisabled(q);p.add({title:"advanced.paste_desc",icon:"paste",cmd:"Paste"});if((r.nodeName=="A"&&!n.dom.getAttrib(r,"name"))||!q){p.addSeparator();p.add({title:"advanced.link_desc",icon:"link",cmd:n.plugins.advlink?"mceAdvLink":"mceLink",ui:true});p.add({title:"advanced.unlink_desc",icon:"unlink",cmd:"UnLink"})}p.addSeparator();p.add({title:"advanced.image_desc",icon:"image",cmd:n.plugins.advimage?"mceAdvImage":"mceImage",ui:true});p.addSeparator();o=p.addMenu({title:"contextmenu.align"});o.add({title:"contextmenu.left",icon:"justifyleft",cmd:"JustifyLeft"});o.add({title:"contextmenu.center",icon:"justifycenter",cmd:"JustifyCenter"});o.add({title:"contextmenu.right",icon:"justifyright",cmd:"JustifyRight"});o.add({title:"contextmenu.full",icon:"justifyfull",cmd:"JustifyFull"});a.onContextMenu.dispatch(a,p,r,q);return p}});tinymce.PluginManager.add("contextmenu",tinymce.plugins.ContextMenu)})();