/*
 Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
(function(){function u(c,q){var n=/^[A-Za-z]+[\w\-:.]*$/;return q&&!n.test(q)?(alert(Liferay.Util.sub(Liferay.Language.get("there-was-an-error-when-loading-the-x-field"),c)),!1):!0}function w(){var c=this.getDialog(),q=c._.editor,n=q.config.linkPhoneRegExp,r=q.config.linkPhoneMsg,q=CKEDITOR.dialog.validate.notEmpty(q.lang.link.noTel).apply(this);if(!c.getContentElement("info","linkType")||"tel"!=c.getValueOf("info","linkType"))return!0;if(!0!==q)return q;if(n)return CKEDITOR.dialog.validate.regex(n,
r).call(this)}CKEDITOR.dialog.add("link",function(c){function q(a,b){var c=a.createRange();c.setStartBefore(b);c.setEndAfter(b);return c}var n=CKEDITOR.plugins.link,r,v=function(){var a=this.getDialog(),b=a.getContentElement("target","popupFeatures"),a=a.getContentElement("target","linkTargetName"),t=this.getValue();if(b&&a)switch(b=b.getElement(),b.hide(),a.setValue(""),t){case "frame":a.setLabel(c.lang.link.targetFrameName);a.getElement().show();break;case "popup":b.show();a.setLabel(c.lang.link.targetPopupName);
a.getElement().show();break;default:a.setValue(t),a.getElement().hide()}},l=function(a){a.target&&this.setValue(a.target[this.id]||"")},k=function(a){a.advanced&&this.setValue(a.advanced[this.id]||"")},g=function(a){a.target||(a.target={});a.target[this.id]=this.getValue()||""},p=function(a){a.advanced||(a.advanced={});a.advanced[this.id]=this.getValue()||""},d=c.lang.common,b=c.lang.link,h;return{title:b.title,minWidth:"moono-lisa"==(CKEDITOR.skinName||c.config.skin)?450:350,minHeight:240,getModel:function(a){return n.getSelectedLink(a,
!0)[0]||null},contents:[{id:"info",label:b.info,title:b.info,elements:[{type:"text",id:"linkDisplayText",label:b.displayText,setup:function(){this.enable();this.setValue(c.getSelection().getSelectedText());r=this.getValue()},commit:function(a){a.linkText=this.isEnabled()?this.getValue():""}},{id:"linkType",type:"select",label:b.type,"default":"url",items:[[b.toUrl,"url"],[b.toAnchor,"anchor"],[b.toEmail,"email"],[b.toPhone,"tel"]],onChange:function(){var a=this.getDialog(),b=["urlOptions","anchorOptions",
"emailOptions","telOptions"],t=this.getValue(),e=a.definition.getContents("upload"),e=e&&e.hidden;"url"==t?(c.config.linkShowTargetTab&&a.showPage("target"),e||a.showPage("upload")):(a.hidePage("target"),e||a.hidePage("upload"));for(e=0;e<b.length;e++){var f=a.getContentElement("info",b[e]);f&&(f=f.getElement().getParent().getParent(),b[e]==t+"Options"?f.show():f.hide())}a.layout()},setup:function(a){this.setValue(a.type||"url")},commit:function(a){a.type=this.getValue()}},{type:"vbox",id:"urlOptions",
children:[{type:"hbox",widths:["25%","75%"],children:[{id:"protocol",type:"select",label:d.protocol,items:[["http://‎","http://"],["https://‎","https://"],["ftp://‎","ftp://"],["news://‎","news://"],[b.other,""]],"default":c.config.linkDefaultProtocol,setup:function(a){a.url&&this.setValue(a.url.protocol||"")},commit:function(a){a.url||(a.url={});a.url.protocol=this.getValue()}},{type:"text",id:"url",label:d.url,required:!0,onLoad:function(){this.allowOnChange=!0},onKeyUp:function(){this.allowOnChange=
!1;var a=this.getDialog().getContentElement("info","protocol"),b=this.getValue(),c=/^((javascript:)|[#\/\.\?])/i,e=/^(http|https|ftp|news):\/\/(?=.)/i.exec(b);e?(this.setValue(b.substr(e[0].length)),a.setValue(e[0].toLowerCase())):c.test(b)&&a.setValue("");this.allowOnChange=!0},onChange:function(){if(this.allowOnChange)this.onKeyUp()},validate:function(){var a=this.getDialog();return a.getContentElement("info","linkType")&&"url"!=a.getValueOf("info","linkType")?!0:!c.config.linkJavaScriptLinksAllowed&&
/javascript\:/.test(this.getValue())?(alert(d.invalidValue),!1):this.getDialog().fakeObj?!0:CKEDITOR.dialog.validate.notEmpty(b.noUrl).apply(this)},setup:function(a){this.allowOnChange=!1;a.url&&this.setValue(a.url.url);this.allowOnChange=!0},commit:function(a){this.onChange();a.url||(a.url={});a.url.url=this.getValue();this.allowOnChange=!1}}],setup:function(){this.getDialog().getContentElement("info","linkType")||this.getElement().show()}},{type:"button",id:"browse",hidden:"true",filebrowser:"info:url",
label:d.browseServer}]},{type:"vbox",id:"anchorOptions",width:260,align:"center",padding:0,children:[{type:"fieldset",id:"selectAnchorText",label:b.selectAnchor,setup:function(){h=n.getEditorAnchors(c);this.getElement()[h&&h.length?"show":"hide"]()},children:[{type:"hbox",id:"selectAnchor",children:[{type:"select",id:"anchorName","default":"",label:b.anchorName,style:"width: 100%;",items:[[""]],setup:function(a){this.clear();this.add("");if(h)for(var b=0;b<h.length;b++)h[b].name&&this.add(h[b].name);
a.anchor&&this.setValue(a.anchor.name);(a=this.getDialog().getContentElement("info","linkType"))&&"email"==a.getValue()&&this.focus()},commit:function(a){a.anchor||(a.anchor={});a.anchor.name=this.getValue()}},{type:"select",id:"anchorId","default":"",label:b.anchorId,style:"width: 100%;",items:[[""]],setup:function(a){this.clear();this.add("");if(h)for(var b=0;b<h.length;b++)h[b].id&&this.add(h[b].id);a.anchor&&this.setValue(a.anchor.id)},commit:function(a){a.anchor||(a.anchor={});a.anchor.id=this.getValue()}}],
setup:function(){this.getElement()[h&&h.length?"show":"hide"]()}}]},{type:"html",id:"noAnchors",style:"text-align: center;",html:'\x3cdiv role\x3d"note" tabIndex\x3d"-1"\x3e'+CKEDITOR.tools.htmlEncode(b.noAnchors)+"\x3c/div\x3e",focus:!0,setup:function(){this.getElement()[h&&h.length?"hide":"show"]()}}],setup:function(){this.getDialog().getContentElement("info","linkType")||this.getElement().hide()}},{type:"vbox",id:"emailOptions",padding:1,children:[{type:"text",id:"emailAddress",label:b.emailAddress,
required:!0,validate:function(){var a=this.getDialog();return a.getContentElement("info","linkType")&&"email"==a.getValueOf("info","linkType")?CKEDITOR.dialog.validate.notEmpty(b.noEmail).apply(this):!0},setup:function(a){a.email&&this.setValue(a.email.address);(a=this.getDialog().getContentElement("info","linkType"))&&"email"==a.getValue()&&this.select()},commit:function(a){a.email||(a.email={});a.email.address=this.getValue()}},{type:"text",id:"emailSubject",label:b.emailSubject,setup:function(a){a.email&&
this.setValue(a.email.subject)},commit:function(a){a.email||(a.email={});a.email.subject=this.getValue()}},{type:"textarea",id:"emailBody",label:b.emailBody,rows:3,"default":"",setup:function(a){a.email&&this.setValue(a.email.body)},commit:function(a){a.email||(a.email={});a.email.body=this.getValue()}}],setup:function(){this.getDialog().getContentElement("info","linkType")||this.getElement().hide()}},{type:"vbox",id:"telOptions",padding:1,children:[{type:"tel",id:"telNumber",label:b.phoneNumber,
required:!0,validate:w,setup:function(a){a.tel&&this.setValue(a.tel);(a=this.getDialog().getContentElement("info","linkType"))&&"tel"==a.getValue()&&this.select()},commit:function(a){a.tel=this.getValue()}}],setup:function(){this.getDialog().getContentElement("info","linkType")||this.getElement().hide()}}]},{id:"target",requiredContent:"a[target]",label:b.target,title:b.target,elements:[{type:"hbox",widths:["50%","50%"],children:[{type:"select",id:"linkTargetType",label:d.target,"default":"notSet",
style:"width : 100%;",items:[[d.notSet,"notSet"],[b.targetFrame,"frame"],[b.targetPopup,"popup"],[d.targetNew,"_blank"],[d.targetTop,"_top"],[d.targetSelf,"_self"],[d.targetParent,"_parent"]],onChange:v,setup:function(a){a.target&&this.setValue(a.target.type||"notSet");v.call(this)},commit:function(a){a.target||(a.target={});a.target.type=this.getValue()}},{type:"text",id:"linkTargetName",label:b.targetFrameName,"default":"",setup:function(a){a.target&&this.setValue(a.target.name)},commit:function(a){a.target||
(a.target={});a.target.name=this.getValue().replace(/([^\x00-\x7F]|\s)/gi,"")}}]},{type:"vbox",width:"100%",align:"center",padding:2,id:"popupFeatures",children:[{type:"fieldset",label:b.popupFeatures,children:[{type:"hbox",children:[{type:"checkbox",id:"resizable",label:b.popupResizable,setup:l,commit:g},{type:"checkbox",id:"status",label:b.popupStatusBar,setup:l,commit:g}]},{type:"hbox",children:[{type:"checkbox",id:"location",label:b.popupLocationBar,setup:l,commit:g},{type:"checkbox",id:"toolbar",
label:b.popupToolbar,setup:l,commit:g}]},{type:"hbox",children:[{type:"checkbox",id:"menubar",label:b.popupMenuBar,setup:l,commit:g},{type:"checkbox",id:"fullscreen",label:b.popupFullScreen,setup:l,commit:g}]},{type:"hbox",children:[{type:"checkbox",id:"scrollbars",label:b.popupScrollBars,setup:l,commit:g},{type:"checkbox",id:"dependent",label:b.popupDependent,setup:l,commit:g}]},{type:"hbox",children:[{type:"text",widths:["50%","50%"],labelLayout:"horizontal",label:d.width,id:"width",setup:l,commit:g},
{type:"text",labelLayout:"horizontal",widths:["50%","50%"],label:b.popupLeft,id:"left",setup:l,commit:g}]},{type:"hbox",children:[{type:"text",labelLayout:"horizontal",widths:["50%","50%"],label:d.height,id:"height",setup:l,commit:g},{type:"text",labelLayout:"horizontal",label:b.popupTop,widths:["50%","50%"],id:"top",setup:l,commit:g}]}]}]}]},{id:"upload",label:b.upload,title:b.upload,hidden:!0,filebrowser:"uploadButton",elements:[{type:"file",id:"upload",label:d.upload,style:"height:40px",size:29},
{type:"fileButton",id:"uploadButton",label:d.uploadSubmit,filebrowser:"info:url","for":["upload","upload"]}]},{id:"advanced",label:b.advanced,title:b.advanced,elements:[{type:"vbox",padding:1,children:[{type:"hbox",widths:["45%","35%","20%"],children:[{type:"text",id:"advId",requiredContent:"a[id]",label:b.id,setup:k,commit:p},{type:"select",id:"advLangDir",requiredContent:"a[dir]",label:b.langDir,"default":"",style:"width:110px",items:[[d.notSet,""],[b.langDirLTR,"ltr"],[b.langDirRTL,"rtl"]],setup:k,
commit:p},{type:"text",id:"advAccessKey",requiredContent:"a[accesskey]",width:"80px",label:b.acccessKey,maxLength:1,setup:k,commit:p}]},{type:"hbox",widths:["45%","35%","20%"],children:[{type:"text",label:b.name,id:"advName",requiredContent:"a[name]",setup:k,commit:p},{type:"text",label:b.langCode,id:"advLangCode",requiredContent:"a[lang]",width:"110px","default":"",setup:k,commit:p},{type:"text",label:b.tabIndex,id:"advTabIndex",requiredContent:"a[tabindex]",width:"80px",maxLength:5,setup:k,commit:p}]}]},
{type:"vbox",padding:1,children:[{type:"hbox",widths:["45%","55%"],children:[{type:"text",label:b.advisoryTitle,requiredContent:"a[title]","default":"",id:"advTitle",setup:k,commit:p},{type:"text",label:b.advisoryContentType,requiredContent:"a[type]","default":"",id:"advContentType",setup:k,commit:p}]},{type:"hbox",widths:["45%","55%"],children:[{type:"text",label:b.cssClasses,requiredContent:"a(cke-xyz)","default":"",id:"advCSSClasses",setup:k,commit:p},{type:"text",label:b.charset,requiredContent:"a[charset]",
"default":"",id:"advCharset",setup:k,commit:p}]},{type:"hbox",widths:["45%","55%"],children:[{type:"text",label:b.rel,requiredContent:"a[rel]","default":"",id:"advRel",setup:k,commit:p},{type:"text",label:b.styles,requiredContent:"a{cke-xyz}","default":"",id:"advStyles",validate:CKEDITOR.dialog.validate.inlineStyle(c.lang.common.invalidInlineStyle),setup:k,commit:p}]},{type:"hbox",widths:["45%","55%"],children:[{type:"checkbox",id:"download",requiredContent:"a[download]",label:b.download,setup:function(a){void 0!==
a.download&&this.setValue("checked","checked")},commit:function(a){this.getValue()&&(a.download=this.getValue())}}]}]}]}],onShow:function(){var a=this.getParentEditor(),b=a.getSelection(),c=this.getContentElement("info","linkDisplayText").getElement().getParent().getParent(),e=n.getSelectedLink(a,!0),f=e[0]||null;f&&f.hasAttribute("href")&&(b.getSelectedElement()||b.isInTable()||b.selectElement(f));b=n.parseLinkAttributes(a,f);1>=e.length&&n.showDisplayTextForElement(f,a)?c.show():c.hide();this._.selectedElements=
e;this.setupContent(b)},onOk:function(a){var b=this.getValueOf("advanced","advId"),d=this.getValueOf("advanced","advName");if(u("id",b)&&u("name",d))if(a={},this.commitContent(a),this._.selectedElements.length){var b=this._.selectedElements,d=n.getLinkAttributes(c,a),e=[],f,h,l,m,k,g;for(g=0;g<b.length;g++){m=b[g];h=m.data("cke-saved-href");f=a.linkText&&r!=a.linkText;l=h==r;h="email"==a.type&&h=="mailto:"+r;m.setAttributes(d.set);m.removeAttributes(d.removed);if(f)k=a.linkText;else if(l||h)k="email"==
a.type?a.email.address:d.set["data-cke-saved-href"];k&&m.setText(k);e.push(q(c,m))}c.getSelection().selectRanges(e);delete this._.selectedElements}else{k=n.getLinkAttributes(c,a);b=c.getSelection().getRanges();d=new CKEDITOR.style({element:"a",attributes:k.set});e=[];d.type=CKEDITOR.STYLE_INLINE;for(l=0;l<b.length;l++){f=b[l];f.collapsed?(m=new CKEDITOR.dom.text(a.linkText||("email"==a.type?a.email.address:k.set["data-cke-saved-href"]),c.document),f.insertNode(m),f.selectNodeContents(m)):r!==a.linkText&&
(m=new CKEDITOR.dom.text(a.linkText,c.document),f.shrink(CKEDITOR.SHRINK_TEXT),c.editable().extractHtmlFromRange(f),f.insertNode(m));m=f._find("a");for(g=0;g<m.length;g++)m[g].remove(!0);d.applyToRange(f,c);e.push(f)}c.getSelection().selectRanges(e)}else a.data.hide=!1},onLoad:function(){c.config.linkShowAdvancedTab||this.hidePage("advanced");c.config.linkShowTargetTab||this.hidePage("target")},onFocus:function(){var a=this.getContentElement("info","linkType");a&&"url"==a.getValue()&&(a=this.getContentElement("info",
"url"),a.select())}}})})();