diff options
author | Alvin Li <liweitianux@gmail.com> | 2013-08-13 14:13:24 +0800 |
---|---|---|
committer | Alvin Li <liweitianux@gmail.com> | 2013-08-13 14:13:24 +0800 |
commit | 9636d4a6767f49384d5c386bc3f1142c88b90613 (patch) | |
tree | 3a70f6d9e4be1791d36c87cc7cbfd1d5aa2b39dd /97suifangqa/staticfiles/tinymce/js/tinymce/plugins/template/plugin.min.js | |
parent | 9383d9a8a5988d071766c3d08a5c946e9c5b02ae (diff) | |
download | 97dev-9636d4a6767f49384d5c386bc3f1142c88b90613.tar.bz2 |
cloned from 'bitbucket', 2013/08/13
Diffstat (limited to '97suifangqa/staticfiles/tinymce/js/tinymce/plugins/template/plugin.min.js')
-rw-r--r-- | 97suifangqa/staticfiles/tinymce/js/tinymce/plugins/template/plugin.min.js | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/97suifangqa/staticfiles/tinymce/js/tinymce/plugins/template/plugin.min.js b/97suifangqa/staticfiles/tinymce/js/tinymce/plugins/template/plugin.min.js new file mode 100644 index 0000000..33fb1ac --- /dev/null +++ b/97suifangqa/staticfiles/tinymce/js/tinymce/plugins/template/plugin.min.js @@ -0,0 +1 @@ +tinymce.PluginManager.add("template",function(e){function t(){function t(e){var t=e.control.value();t.url?tinymce.util.XHR.send({url:t.url,success:function(e){r=e,n.find("iframe")[0].html(e)}}):(r=t.content,n.find("iframe")[0].html(t.content)),n.find("#description")[0].text(e.control.value().description)}var n,r,o=[];return e.settings.templates?(tinymce.each(e.settings.templates,function(e){o.push({text:e.title,value:{url:e.url,content:e.content,description:e.description}})}),n=e.windowManager.open({title:"Insert template",body:[{type:"listbox",name:"template",flex:0,label:"Templates",values:o,onselect:t},{type:"label",name:"description",label:"Description",text:""},{type:"iframe",minWidth:600,minHeight:400,border:1}],onsubmit:function(){i(!1,r)}}),void 0):(e.windowManager.alert("No templates defined"),void 0)}function n(t,n){function r(e,t){if(e=""+e,t>e.length)for(var n=0;t-e.length>n;n++)e="0"+e;return e}var i="Sun Mon Tue Wed Thu Fri Sat Sun".split(" "),o="Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday".split(" "),a="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),s="January February March April May June July August September October November December".split(" ");return n=n||new Date,t=t.replace("%D","%m/%d/%Y"),t=t.replace("%r","%I:%M:%S %p"),t=t.replace("%Y",""+n.getFullYear()),t=t.replace("%y",""+n.getYear()),t=t.replace("%m",r(n.getMonth()+1,2)),t=t.replace("%d",r(n.getDate(),2)),t=t.replace("%H",""+r(n.getHours(),2)),t=t.replace("%M",""+r(n.getMinutes(),2)),t=t.replace("%S",""+r(n.getSeconds(),2)),t=t.replace("%I",""+((n.getHours()+11)%12+1)),t=t.replace("%p",""+(12>n.getHours()?"AM":"PM")),t=t.replace("%B",""+e.translate(s[n.getMonth()])),t=t.replace("%b",""+e.translate(a[n.getMonth()])),t=t.replace("%A",""+e.translate(o[n.getDay()])),t=t.replace("%a",""+e.translate(i[n.getDay()])),t=t.replace("%%","%")}function r(t){var n=e.dom,r=e.getParam("template_replace_values");o(n.select("*",t),function(e){o(r,function(t,i){n.hasClass(e,i)&&"function"==typeof r[i]&&r[i](e)})})}function i(t,i){function a(e,t){return RegExp("\\b"+t+"\\b","g").test(e.className)}var s,l,c=e.dom,u=e.selection.getContent();o(e.getParam("template_replace_values"),function(e,t){"function"!=typeof e&&(i=i.replace(RegExp("\\{\\$"+t+"\\}","g"),e))}),s=c.create("div",null,i),l=c.select(".mceTmpl",s),l&&l.length>0&&(s=c.create("div",null),s.appendChild(l[0].cloneNode(!0))),o(c.select("*",s),function(t){a(t,e.getParam("template_cdate_classes","cdate").replace(/\s+/g,"|"))&&(t.innerHTML=n(e.getParam("template_cdate_format",e.getLang("template.cdate_format")))),a(t,e.getParam("template_mdate_classes","mdate").replace(/\s+/g,"|"))&&(t.innerHTML=n(e.getParam("template_mdate_format",e.getLang("template.mdate_format")))),a(t,e.getParam("template_selected_content_classes","selcontent").replace(/\s+/g,"|"))&&(t.innerHTML=u)}),r(s),e.execCommand("mceInsertContent",!1,s.innerHTML),e.addVisual()}var o=tinymce.each;e.addCommand("mceInsertTemplate",i),e.addButton("template",{title:"Insert template",onclick:t}),e.addMenuItem("image",{text:"Insert template",onclick:t,context:"insert"}),e.on("PreProcess",function(t){var i=e.dom;o(i.select("div",t.node),function(t){i.hasClass(t,"mceTmpl")&&(o(i.select("*",t),function(t){i.hasClass(t,e.getParam("template_mdate_classes","mdate").replace(/\s+/g,"|"))&&(t.innerHTML=n(e.getParam("template_mdate_format",e.getLang("template.mdate_format"))))}),r(t))})})});
\ No newline at end of file |