/*
Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
!function(){CKEDITOR.dialog.add("templates",function(e){function t(e,t){var l=CKEDITOR.dom.element.createFromHtml(''),s='
';return e.image&&t&&(s+='+') | '),s+=''+e.title+" ",e.description&&(s+=""+e.description+""),s+=" |
",l.getFirst().setHtml(s),l.on("click",function(){if(e.htmlFile){var t=CKEDITOR.dialog.getCurrent();t.setState(CKEDITOR.DIALOG_STATE_BUSY),CKEDITOR.ajax.loadText(e.htmlFile,function(e){a(e),t.setState(CKEDITOR.DIALOG_STATE_IDLE)})}else a(e.html)}),l}function a(t){var a=CKEDITOR.dialog.getCurrent();a.getValueOf("selectTpl","chkInsertOpt")?(e.fire("saveSnapshot"),e.setData(t,function(){a.hide();var t=e.createRange();t.moveToElementEditStart(e.editable()),t.select(),setTimeout(function(){e.fire("saveSnapshot")},0)})):(e.insertHtml(t),a.hide())}function l(e){var t=e.data.getTarget(),a=i.equals(t);if(a||i.contains(t)){var l,s=e.data.getKeystroke(),n=i.getElementsByTag("a");if(n){if(a)l=n.getItem(0);else switch(s){case 40:l=t.getNext();break;case 38:l=t.getPrevious();break;case 13:case 32:t.fire("click")}l&&(l.focus(),e.data.preventDefault())}}}var s=CKEDITOR.plugins.get("templates");CKEDITOR.document.appendStyleSheet(CKEDITOR.getUrl(s.path+"dialogs/templates.css"));var i,s="cke_tpl_list_label_"+CKEDITOR.tools.getNextNumber(),n=e.lang.templates,o=e.config;return{title:e.lang.templates.title,minWidth:CKEDITOR.env.ie?440:400,minHeight:340,contents:[{id:"selectTpl",label:n.title,elements:[{type:"vbox",padding:5,children:[{id:"chkInsertOpt",type:"checkbox",label:n.insertOption,"default":o.templates_replaceContent},{id:"selectTplText",type:"html",html:""+n.selectPromptMsg+""},{id:"templatesList",type:"html",focus:!0,html:''+n.options+""}]}]}],buttons:[CKEDITOR.dialog.cancelButton],onShow:function(){var e=this.getContentElement("selectTpl","templatesList");i=e.getElement(),CKEDITOR.loadTemplates(o.templates_files,function(){var a=(o.templates||"default").split(",");if(a.length){var l=i;l.setHtml("");for(var s=0,p=a.length;p>s;s++)for(var r=CKEDITOR.getTemplates(a[s]),c=r.imagesPath,r=r.templates,d=r.length,m=0;d>m;m++){var g=t(r[m],c);g.setAttribute("aria-posinset",m+1),g.setAttribute("aria-setsize",d),l.append(g)}e.focus()}else i.setHtml(''+n.emptyListMsg+"
")}),this._.element.on("keydown",l)},onHide:function(){this._.element.removeListener("keydown",l)}}})}();