text: tinymce.PluginManager.add("link",function(e){function t(){function t(){o||0!==a.text.length||this.parent().parent().find("#text")[0].value(this.value())}var n,i,o,a={},r=e.selection,l=e.dom;n=r.getNode(),i=l.getParent(n,"a[href]"),i&&r.select(i),a.text=o=r.getContent({format:"text"}),a.href=i?l.getAttrib(i,"href"):"",a.target=i?l.getAttrib(i,"target"):"","IMG"==n.nodeName&&(a.text=o=" "),e.windowManager.open({title:"Insert link",data:a,body:[{name:"text",type:"textbox",size:40,label:"Text to display",onchange:function(){o=this.value()}},{name:"href",type:"filepicker",filetype:"file",size:40,autofocus:!0,label:"Url",onchange:t,onkeyup:t},{name:"target",type:"listbox",label:"Target",values:[{text:"None",value:""},{text:"New window",value:"_blank"}]}],onSubmit:function(t){var n=t.data;return n.href?(n.text!=o?i?(e.focus(),i.innerHTML=n.text,l.setAttribs(i,{href:n.href,target:n.target}),r.select(i)):e.insertContent(l.createHTML("a",{href:n.href,target:n.target},n.text)):e.execCommand("mceInsertLink",!1,{href:n.href,target:n.target}),void 0):(e.execCommand("unlink"),void 0)}})}e.addButton("link",{icon:"link",tooltip:"Insert/edit link",shortcut:"Ctrl+K",onclick:t,stateSelector:"a[href]"}),e.addButton("unlink",{icon:"unlink",tooltip:"Remove link(s)",cmd:"unlink",stateSelector:"a[href]"}),e.addShortcut("Ctrl+K","",t),this.showDialog=t,e.addMenuItem("link",{icon:"link",text:"Insert link",shortcut:"Ctrl+K",onclick:t,stateSelector:"a[href]",context:"insert",prependToContext:!0})});