text: ﻿CKEDITOR.dialog.add("anchor",function(e){function t(e,t){return e.createFakeElement(e.document.createElement("a",{attributes:t}),"cke_anchor","anchor")}function n(e){var t=e.getRanges()[0],n=e.getSelectedElement();if(t.shrink(CKEDITOR.SHRINK_ELEMENT),(n=t.getEnclosedNode())&&n.type===CKEDITOR.NODE_ELEMENT&&("anchor"===n.data("cke-real-element-type")||n.is("a")))return n}var a=function(e){this._.selectedElement=e;var t=e.data("cke-saved-name");this.setValueOf("info","txtName",t||"")};return{title:e.lang.link.anchor.title,minWidth:300,minHeight:60,onOk:function(){var n=CKEDITOR.tools.trim(this.getValueOf("info","txtName")),a={id:n,name:n,"data-cke-saved-name":n};if(this._.selectedElement)if(this._.selectedElement.data("cke-realelement")){var l=t(e,a);l.replace(this._.selectedElement),CKEDITOR.env.ie&&e.getSelection().selectElement(l)}else this._.selectedElement.setAttributes(a);else{var i=e.getSelection(),c=i&&i.getRanges()[0];if(c.collapsed){var s=t(e,a);c.insertNode(s)}else{CKEDITOR.env.ie&&CKEDITOR.env.version<9&&(a.class="cke_anchor");var r=new CKEDITOR.style({element:"a",attributes:a});r.type=CKEDITOR.STYLE_INLINE,r.applyToRange(c)}}},onHide:function(){delete this._.selectedElement},onShow:function(){var t=e.getSelection(),l=n(t),i=l&&l.data("cke-realelement"),c=i?CKEDITOR.plugins.link.tryRestoreFakeAnchor(e,l):CKEDITOR.plugins.link.getSelectedLink(e);c&&(a.call(this,c),!i&&t.selectElement(c),l&&(this._.selectedElement=l)),this.getContentElement("info","txtName").focus()},contents:[{id:"info",label:e.lang.link.anchor.title,accessKey:"I",elements:[{type:"text",id:"txtName",label:e.lang.link.anchor.name,required:!0,validate:function(){return!!this.getValue()||(alert(e.lang.link.anchor.errorName),!1)}}]}]}});