Files
sean 0e8a8b3028
Some checks are pending
deploy-testing / deploy (push) Waiting to run
Initial testing snapshot
2026-11-17 16:15:01 -05:00

1 line
3.4 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
tinymce.PluginManager.add("template",function(g){function d(){function i(l){var a=l.control.value();a.url?tinymce.util.XHR.send({url:a.url,success:function(m){e=m,k.find("iframe")[0].html(m)}}):(e=a.content,k.find("iframe")[0].html(a.content)),k.find("#description")[0].text(l.control.value().description)}var k,e,j=[];return g.settings.templates?(tinymce.each(g.settings.templates,function(a){j.push({selected:!j.length,text:a.title,value:{url:a.url,content:a.content,description:a.description}})}),k=g.windowManager.open({title:"Insert template",body:[{type:"listbox",name:"template",flex:0,label:"Templates",values:j,onselect:i},{type:"label",name:"description",label:"Description",text:" "},{type:"iframe",minWidth:600,minHeight:400,border:1}],onsubmit:function(){c(!1,e)}}),k.find("listbox")[0].fire("select"),void 0):(g.windowManager.alert("No templates defined"),void 0)}function h(m,s){function j(i,a){if(i=""+i,i.length<a){for(var l=0;l<a-i.length;l++){i="0"+i}}return i}var k="Sun Mon Tue Wed Thu Fri Sat Sun".split(" "),p="Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday".split(" "),q="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),e="January February March April May June July August September October November December".split(" ");return s=s||new Date,m=m.replace("%D","%m/%d/%Y"),m=m.replace("%r","%I:%M:%S %p"),m=m.replace("%Y",""+s.getFullYear()),m=m.replace("%y",""+s.getYear()),m=m.replace("%m",j(s.getMonth()+1,2)),m=m.replace("%d",j(s.getDate(),2)),m=m.replace("%H",""+j(s.getHours(),2)),m=m.replace("%M",""+j(s.getMinutes(),2)),m=m.replace("%S",""+j(s.getSeconds(),2)),m=m.replace("%I",""+((s.getHours()+11)%12+1)),m=m.replace("%p",""+(s.getHours()<12?"AM":"PM")),m=m.replace("%B",""+g.translate(e[s.getMonth()])),m=m.replace("%b",""+g.translate(q[s.getMonth()])),m=m.replace("%A",""+g.translate(p[s.getDay()])),m=m.replace("%a",""+g.translate(k[s.getDay()])),m=m.replace("%%","%")}function b(i){var j=g.dom,e=g.getParam("template_replace_values");f(j.select("*",i),function(a){f(e,function(l,k){j.hasClass(a,k)&&"function"==typeof e[k]&&e[k](a)})})}function c(j,e){function n(l,i){return new RegExp("\\b"+i+"\\b","g").test(l.className)}var a,p,k=g.dom,m=g.selection.getContent();f(g.getParam("template_replace_values"),function(l,i){"function"!=typeof l&&(e=e.replace(new RegExp("\\{\\$"+i+"\\}","g"),l))}),a=k.create("div",null,e),p=k.select(".mceTmpl",a),p&&p.length>0&&(a=k.create("div",null),a.appendChild(p[0].cloneNode(!0))),f(k.select("*",a),function(i){n(i,g.getParam("template_cdate_classes","cdate").replace(/\s+/g,"|"))&&(i.innerHTML=h(g.getParam("template_cdate_format",g.getLang("template.cdate_format")))),n(i,g.getParam("template_mdate_classes","mdate").replace(/\s+/g,"|"))&&(i.innerHTML=h(g.getParam("template_mdate_format",g.getLang("template.mdate_format")))),n(i,g.getParam("template_selected_content_classes","selcontent").replace(/\s+/g,"|"))&&(i.innerHTML=m)}),b(a),g.execCommand("mceInsertContent",!1,a.innerHTML),g.addVisual()}var f=tinymce.each;g.addCommand("mceInsertTemplate",c),g.addButton("template",{title:"Insert template",onclick:d}),g.addMenuItem("template",{text:"Insert template",onclick:d,context:"insert"}),g.on("PreProcess",function(e){var a=g.dom;f(a.select("div",e.node),function(i){a.hasClass(i,"mceTmpl")&&(f(a.select("*",i),function(j){a.hasClass(j,g.getParam("template_mdate_classes","mdate").replace(/\s+/g,"|"))&&(j.innerHTML=h(g.getParam("template_mdate_format",g.getLang("template.mdate_format"))))}),b(i))})})});