tinymce.PluginManager.add("template",function(e){var t=tinymce.each;function a(t){return function(){var a=e.settings.templates;if(typeof a=="string"){tinymce.util.XHR.send({url:a,success:function(e){t(tinymce.util.JSON.parse(e))}})}else{t(a)}}}function n(t){var a,n=[],l;if(!t||t.length===0){e.windowManager.alert("No templates defined");return}tinymce.each(t,function(e){n.push({selected:!n.length,text:e.title,value:{url:e.url,content:e.content,description:e.description}})});function r(t){var n=t.control.value();function r(t){if(t.indexOf("")==-1){var n="";tinymce.each(e.contentCSS,function(t){n+=''});t=""+""+"
"+n+""+""+t+""+""}t=c(t,"template_preview_replace_values");var l=a.find("iframe")[0].getEl().contentWindow.document;l.open();l.write(t);l.close()}if(n.url){tinymce.util.XHR.send({url:n.url,success:function(e){l=e;r(l)}})}else{l=n.content;r(l)}a.find("#description")[0].text(t.control.value().description)}a=e.windowManager.open({title:"Insert template",layout:"flex",direction:"column",align:"stretch",padding:15,spacing:10,items:[{type:"form",flex:0,padding:0,items:[{type:"container",label:"Templates",items:{type:"listbox",label:"Templates",name:"template",values:n,onselect:r}}]},{type:"label",name:"description",label:"Description",text:" "},{type:"iframe",flex:1,border:1}],onsubmit:function(){i(false,l)},width:e.getParam("template_popup_width",600),height:e.getParam("template_popup_height",500)});a.find("listbox")[0].fire("select")}function l(t,a){var n="Sun Mon Tue Wed Thu Fri Sat Sun".split(" ");var l="Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday".split(" ");var r="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ");var c="January February March April May June July August September October November December".split(" ");function i(e,t){e=""+e;if(e.length