(function(){var e=tinymce.dom.Event,f=tinymce.each,d=tinymce.DOM;tinymce.create("tinymce.plugins.ContextMenu",{init:function(h){var b=this,a;b.editor=h;b.onContextMenu=new tinymce.util.Dispatcher(this);h.onContextMenu.add(function(j,g){if(!g.ctrlKey){if(a){j.selection.setRng(a)}b._getMenu(j).showMenu(g.clientX,g.clientY);e.add(j.getDoc(),"click",function(i){c(j,i)});e.cancel(g)}});h.onRemove.add(function(){if(b._menu){b._menu.removeAll()}});function c(j,g){a=null;if(g&&g.button==2){a=j.selection.getRng();return}if(b._menu){b._menu.removeAll();b._menu.destroy();e.remove(j.getDoc(),"click",c)}}h.onMouseDown.add(c);h.onKeyDown.add(c)},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});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)})();