1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/webtrees_ynh.git synced 2024-09-03 18:26:37 +02:00
webtrees_ynh/sources/packages/ckeditor-4.5.2-custom/plugins/templates/dialogs/templates.js

1 line
No EOL
2.7 KiB
JavaScript

(function(){CKEDITOR.dialog.add("templates",function(m){function i(g,f){var c=CKEDITOR.dom.element.createFromHtml('<a href="javascript:void(0)" tabIndex="-1" role="option" ><div class="cke_tpl_item"></div></a>'),h='<table style="width:350px;" class="cke_tpl_preview" role="presentation"><tr>';g.image&&f&&(h+='<td class="cke_tpl_preview_img"><img src="'+CKEDITOR.getUrl(f+g.image)+'"'+(CKEDITOR.env.ie6Compat?' onload="this.width=this.width"':"")+' alt="" title=""></td>');h+='<td style="white-space:normal;"><span class="cke_tpl_title">'+g.title+"</span><br/>";g.description&&(h+="<span>"+g.description+"</span>");c.getFirst().setHtml(h+"</td></tr></table>");c.on("click",function(){d(g.html)});return c}function d(f){var c=CKEDITOR.dialog.getCurrent();c.getValueOf("selectTpl","chkInsertOpt")?(m.fire("saveSnapshot"),m.setData(f,function(){c.hide();var g=m.createRange();g.moveToElementEditStart(m.editable());g.select();setTimeout(function(){m.fire("saveSnapshot")},0)})):(m.insertHtml(f),c.hide())}function a(h){var g=h.data.getTarget(),p=e.equals(g);if(p||e.contains(g)){var o=h.data.getKeystroke(),k=e.getElementsByTag("a"),n;if(k){if(p){n=k.getItem(0)}else{switch(o){case 40:n=g.getNext();break;case 38:n=g.getPrevious();break;case 13:case 32:g.fire("click")}}n&&(n.focus(),h.data.preventDefault())}}}var b=CKEDITOR.plugins.get("templates");CKEDITOR.document.appendStyleSheet(CKEDITOR.getUrl(b.path+"dialogs/templates.css"));var e,b="cke_tpl_list_label_"+CKEDITOR.tools.getNextNumber(),j=m.lang.templates,l=m.config;return{title:m.lang.templates.title,minWidth:CKEDITOR.env.ie?440:400,minHeight:340,contents:[{id:"selectTpl",label:j.title,elements:[{type:"vbox",padding:5,children:[{id:"selectTplText",type:"html",html:"<span>"+j.selectPromptMsg+"</span>"},{id:"templatesList",type:"html",focus:!0,html:'<div class="cke_tpl_list" tabIndex="-1" role="listbox" aria-labelledby="'+b+'"><div class="cke_tpl_loading"><span></span></div></div><span class="cke_voice_label" id="'+b+'">'+j.options+"</span>"},{id:"chkInsertOpt",type:"checkbox",label:j.insertOption,"default":l.templates_replaceContent}]}]}],buttons:[CKEDITOR.dialog.cancelButton],onShow:function(){var c=this.getContentElement("selectTpl","templatesList");e=c.getElement();CKEDITOR.loadTemplates(l.templates_files,function(){var v=(l.templates||"default").split(",");if(v.length){var u=e;u.setHtml("");for(var t=0,r=v.length;t<r;t++){for(var s=CKEDITOR.getTemplates(v[t]),o=s.imagesPath,s=s.templates,f=s.length,n=0;n<f;n++){var g=i(s[n],o);g.setAttribute("aria-posinset",n+1);g.setAttribute("aria-setsize",f);u.append(g)}}c.focus()}else{e.setHtml('<div class="cke_tpl_empty"><span>'+j.emptyListMsg+"</span></div>")}});this._.element.on("keydown",a)},onHide:function(){this._.element.removeListener("keydown",a)}}})})();