!function(){var e=tinymce.dom.Event,t=(tinymce.each,tinymce.DOM);tinymce.create("tinymce.plugins.ContextMenu",{init:function(t){var n,i,o,c,d=this;function a(t,n){o=0,n&&2==n.button?o=n.ctrlKey:d._menu&&(d._menu.removeAll(),d._menu.destroy(),e.remove(t.getDoc(),"click",c),d._menu=null)}d.editor=t,i=t.settings.contextmenu_never_use_native,d.onContextMenu=new tinymce.util.Dispatcher(this),c=function(e){a(t,e)},n=t.onContextMenu.add((function(t,n){(0!==o?o:n.ctrlKey)&&!i||(e.cancel(n),"IMG"==n.target.nodeName&&t.selection.select(n.target),d._getMenu(t).showMenu(n.clientX||n.pageX,n.clientY||n.pageY),e.add(t.getDoc(),"click",c),t.nodeChanged())})),t.onRemove.add((function(){d._menu&&d._menu.removeAll()})),t.onMouseDown.add(a),t.onKeyDown.add(a),t.onKeyDown.add((function(t,i){!i.shiftKey||i.ctrlKey||i.altKey||121!==i.keyCode||(e.cancel(i),n(t,i))}))},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(e){var n,i,o=this,c=o._menu,d=e.selection,a=d.isCollapsed(),u=d.getNode()||e.getBody();return c&&(c.removeAll(),c.destroy()),i=t.getPos(e.getContentAreaContainer()),c=e.controlManager.createDropMenu("contextmenu",{offset_x:i.x+e.getParam("contextmenu_offset_x",0),offset_y:i.y+e.getParam("contextmenu_offset_y",0),constrain:1,keyboard_focus:!0}),o._menu=c,c.add({title:"advanced.cut_desc",icon:"cut",cmd:"Cut"}).setDisabled(a),c.add({title:"advanced.copy_desc",icon:"copy",cmd:"Copy"}).setDisabled(a),c.add({title:"advanced.paste_desc",icon:"paste",cmd:"Paste"}),("A"!=u.nodeName||e.dom.getAttrib(u,"name"))&&a||(c.addSeparator(),c.add({title:"advanced.link_desc",icon:"link",cmd:e.plugins.advlink?"mceAdvLink":"mceLink",ui:!0}),c.add({title:"advanced.unlink_desc",icon:"unlink",cmd:"UnLink"})),c.addSeparator(),c.add({title:"advanced.image_desc",icon:"image",cmd:e.plugins.advimage?"mceAdvImage":"mceImage",ui:!0}),c.addSeparator(),(n=c.addMenu({title:"contextmenu.align"})).add({title:"contextmenu.left",icon:"justifyleft",cmd:"JustifyLeft"}),n.add({title:"contextmenu.center",icon:"justifycenter",cmd:"JustifyCenter"}),n.add({title:"contextmenu.right",icon:"justifyright",cmd:"JustifyRight"}),n.add({title:"contextmenu.full",icon:"justifyfull",cmd:"JustifyFull"}),o.onContextMenu.dispatch(o,c,u,a),c}}),tinymce.PluginManager.add("contextmenu",tinymce.plugins.ContextMenu)}();
