summaryrefslogtreecommitdiffstats
path: root/extensions/tinymce/jscripts/tiny_mce/plugins/template
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/tinymce/jscripts/tiny_mce/plugins/template')
-rw-r--r--extensions/tinymce/jscripts/tiny_mce/plugins/template/blank.htm12
-rw-r--r--extensions/tinymce/jscripts/tiny_mce/plugins/template/css/template.css23
-rw-r--r--extensions/tinymce/jscripts/tiny_mce/plugins/template/editor_plugin.js1
-rw-r--r--extensions/tinymce/jscripts/tiny_mce/plugins/template/editor_plugin_src.js156
-rw-r--r--extensions/tinymce/jscripts/tiny_mce/plugins/template/js/template.js106
-rw-r--r--extensions/tinymce/jscripts/tiny_mce/plugins/template/langs/en_dlg.js15
-rw-r--r--extensions/tinymce/jscripts/tiny_mce/plugins/template/template.htm39
7 files changed, 352 insertions, 0 deletions
diff --git a/extensions/tinymce/jscripts/tiny_mce/plugins/template/blank.htm b/extensions/tinymce/jscripts/tiny_mce/plugins/template/blank.htm
new file mode 100644
index 0000000..ecde53f
--- /dev/null
+++ b/extensions/tinymce/jscripts/tiny_mce/plugins/template/blank.htm
@@ -0,0 +1,12 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>blank_page</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <script type="text/javascript">
+ parent.TemplateDialog.loadCSSFiles(document);
+ </script>
+</head>
+<body id="mceTemplatePreview" class="mceContentBody">
+
+</body>
+</html>
diff --git a/extensions/tinymce/jscripts/tiny_mce/plugins/template/css/template.css b/extensions/tinymce/jscripts/tiny_mce/plugins/template/css/template.css
new file mode 100644
index 0000000..2d23a49
--- /dev/null
+++ b/extensions/tinymce/jscripts/tiny_mce/plugins/template/css/template.css
@@ -0,0 +1,23 @@
+#frmbody {
+ padding: 10px;
+ background-color: #FFF;
+ border: 1px solid #CCC;
+}
+
+.frmRow {
+ margin-bottom: 10px;
+}
+
+#templatesrc {
+ border: none;
+ width: 320px;
+ height: 240px;
+}
+
+.title {
+ padding-bottom: 5px;
+}
+
+.mceActionPanel {
+ padding-top: 5px;
+}
diff --git a/extensions/tinymce/jscripts/tiny_mce/plugins/template/editor_plugin.js b/extensions/tinymce/jscripts/tiny_mce/plugins/template/editor_plugin.js
new file mode 100644
index 0000000..0f7fb01
--- /dev/null
+++ b/extensions/tinymce/jscripts/tiny_mce/plugins/template/editor_plugin.js
@@ -0,0 +1 @@
+(function(){var each=tinymce.each;tinymce.create('tinymce.plugins.TemplatePlugin',{init:function(ed,url){var t=this;t.editor=ed;ed.addCommand('mceTemplate',function(ui){ed.windowManager.open({file:url+'/template.htm',width:ed.getParam('template_popup_width',750),height:ed.getParam('template_popup_height',600),inline:1},{plugin_url:url});});ed.addCommand('mceInsertTemplate',t._insertTemplate,t);ed.addButton('template',{title:'template.desc',cmd:'mceTemplate'});ed.onPreProcess.add(function(ed,o){var dom=ed.dom;each(dom.select('div',o.node),function(e){if(dom.hasClass(e,'mceTmpl')){each(dom.select('*',e),function(e){if(dom.hasClass(e,ed.getParam('template_mdate_classes','mdate').replace(/\s+/g,'|')))e.innerHTML=t._getDateTime(new Date(),ed.getParam("template_mdate_format",ed.getLang("template.mdate_format")));});t._replaceVals(e);}});});},getInfo:function(){return{longname:'Template plugin',author:'Moxiecode Systems AB',authorurl:'http://www.moxiecode.com',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/template',version:tinymce.majorVersion+"."+tinymce.minorVersion};},_insertTemplate:function(ui,v){var t=this,ed=t.editor,h,el,dom=ed.dom,sel=ed.selection.getContent();h=v.content;each(t.editor.getParam('template_replace_values'),function(v,k){if(typeof(v)!='function')h=h.replace(new RegExp('\\{\\$'+k+'\\}','g'),v);});el=dom.create('div',null,h);n=dom.select('.mceTmpl',el);if(n&&n.length>0){el=dom.create('div',null);el.appendChild(n[0].cloneNode(true));}function hasClass(n,c){return new RegExp('\\b'+c+'\\b','g').test(n.className);};each(dom.select('*',el),function(n){if(hasClass(n,ed.getParam('template_cdate_classes','cdate').replace(/\s+/g,'|')))n.innerHTML=t._getDateTime(new Date(),ed.getParam("template_cdate_format",ed.getLang("template.cdate_format")));if(hasClass(n,ed.getParam('template_mdate_classes','mdate').replace(/\s+/g,'|')))n.innerHTML=t._getDateTime(new Date(),ed.getParam("template_mdate_format",ed.getLang("template.mdate_format")));if(hasClass(n,ed.getParam('template_selected_content_classes','selcontent').replace(/\s+/g,'|')))n.innerHTML=sel;});t._replaceVals(el);ed.execCommand('mceInsertContent',false,el.innerHTML);ed.addVisual();},_replaceVals:function(e){var dom=this.editor.dom,vl=this.editor.getParam('template_replace_values');each(dom.select('*',e),function(e){each(vl,function(v,k){if(dom.hasClass(e,k)){if(typeof(vl[k])=='function')vl[k](e);}});});},_getDateTime:function(d,fmt){if(!fmt)return"";function addZeros(value,len){var i;value=""+value;if(value.length<len){for(i=0;i<(len-value.length);i++)value="0"+value;}return value;}fmt=fmt.replace("%D","%m/%d/%y");fmt=fmt.replace("%r","%I:%M:%S %p");fmt=fmt.replace("%Y",""+d.getFullYear());fmt=fmt.replace("%y",""+d.getYear());fmt=fmt.replace("%m",addZeros(d.getMonth()+1,2));fmt=fmt.replace("%d",addZeros(d.getDate(),2));fmt=fmt.replace("%H",""+addZeros(d.getHours(),2));fmt=fmt.replace("%M",""+addZeros(d.getMinutes(),2));fmt=fmt.replace("%S",""+addZeros(d.getSeconds(),2));fmt=fmt.replace("%I",""+((d.getHours()+11)%12+1));fmt=fmt.replace("%p",""+(d.getHours()<12?"AM":"PM"));fmt=fmt.replace("%B",""+tinyMCE.getLang("template_months_long").split(',')[d.getMonth()]);fmt=fmt.replace("%b",""+tinyMCE.getLang("template_months_short").split(',')[d.getMonth()]);fmt=fmt.replace("%A",""+tinyMCE.getLang("template_day_long").split(',')[d.getDay()]);fmt=fmt.replace("%a",""+tinyMCE.getLang("template_day_short").split(',')[d.getDay()]);fmt=fmt.replace("%%","%");return fmt;}});tinymce.PluginManager.add('template',tinymce.plugins.TemplatePlugin);})(); \ No newline at end of file
diff --git a/extensions/tinymce/jscripts/tiny_mce/plugins/template/editor_plugin_src.js b/extensions/tinymce/jscripts/tiny_mce/plugins/template/editor_plugin_src.js
new file mode 100644
index 0000000..73ab39e
--- /dev/null
+++ b/extensions/tinymce/jscripts/tiny_mce/plugins/template/editor_plugin_src.js
@@ -0,0 +1,156 @@
+/**
+ * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
+ *
+ * @author Moxiecode
+ * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
+ */
+
+(function() {
+ var each = tinymce.each;
+
+ tinymce.create('tinymce.plugins.TemplatePlugin', {
+ init : function(ed, url) {
+ var t = this;
+
+ t.editor = ed;
+
+ // Register commands
+ ed.addCommand('mceTemplate', function(ui) {
+ ed.windowManager.open({
+ file : url + '/template.htm',
+ width : ed.getParam('template_popup_width', 750),
+ height : ed.getParam('template_popup_height', 600),
+ inline : 1
+ }, {
+ plugin_url : url
+ });
+ });
+
+ ed.addCommand('mceInsertTemplate', t._insertTemplate, t);
+
+ // Register buttons
+ ed.addButton('template', {title : 'template.desc', cmd : 'mceTemplate'});
+
+ ed.onPreProcess.add(function(ed, o) {
+ var dom = ed.dom;
+
+ each(dom.select('div', o.node), function(e) {
+ if (dom.hasClass(e, 'mceTmpl')) {
+ each(dom.select('*', e), function(e) {
+ if (dom.hasClass(e, ed.getParam('template_mdate_classes', 'mdate').replace(/\s+/g, '|')))
+ e.innerHTML = t._getDateTime(new Date(), ed.getParam("template_mdate_format", ed.getLang("template.mdate_format")));
+ });
+
+ t._replaceVals(e);
+ }
+ });
+ });
+ },
+
+ getInfo : function() {
+ return {
+ longname : 'Template plugin',
+ author : 'Moxiecode Systems AB',
+ authorurl : 'http://www.moxiecode.com',
+ infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/template',
+ version : tinymce.majorVersion + "." + tinymce.minorVersion
+ };
+ },
+
+ _insertTemplate : function(ui, v) {
+ var t = this, ed = t.editor, h, el, dom = ed.dom, sel = ed.selection.getContent();
+
+ h = v.content;
+
+ each(t.editor.getParam('template_replace_values'), function(v, k) {
+ if (typeof(v) != 'function')
+ h = h.replace(new RegExp('\\{\\$' + k + '\\}', 'g'), v);
+ });
+
+ el = dom.create('div', null, h);
+
+ // Find template element within div
+ n = dom.select('.mceTmpl', el);
+ if (n && n.length > 0) {
+ el = dom.create('div', null);
+ el.appendChild(n[0].cloneNode(true));
+ }
+
+ function hasClass(n, c) {
+ return new RegExp('\\b' + c + '\\b', 'g').test(n.className);
+ };
+
+ each(dom.select('*', el), function(n) {
+ // Replace cdate
+ if (hasClass(n, ed.getParam('template_cdate_classes', 'cdate').replace(/\s+/g, '|')))
+ n.innerHTML = t._getDateTime(new Date(), ed.getParam("template_cdate_format", ed.getLang("template.cdate_format")));
+
+ // Replace mdate
+ if (hasClass(n, ed.getParam('template_mdate_classes', 'mdate').replace(/\s+/g, '|')))
+ n.innerHTML = t._getDateTime(new Date(), ed.getParam("template_mdate_format", ed.getLang("template.mdate_format")));
+
+ // Replace selection
+ if (hasClass(n, ed.getParam('template_selected_content_classes', 'selcontent').replace(/\s+/g, '|')))
+ n.innerHTML = sel;
+ });
+
+ t._replaceVals(el);
+
+ ed.execCommand('mceInsertContent', false, el.innerHTML);
+ ed.addVisual();
+ },
+
+ _replaceVals : function(e) {
+ var dom = this.editor.dom, vl = this.editor.getParam('template_replace_values');
+
+ each(dom.select('*', e), function(e) {
+ each(vl, function(v, k) {
+ if (dom.hasClass(e, k)) {
+ if (typeof(vl[k]) == 'function')
+ vl[k](e);
+ }
+ });
+ });
+ },
+
+ _getDateTime : function(d, fmt) {
+ if (!fmt)
+ return "";
+
+ function addZeros(value, len) {
+ var i;
+
+ value = "" + value;
+
+ if (value.length < len) {
+ for (i=0; i<(len-value.length); i++)
+ value = "0" + value;
+ }
+
+ return value;
+ }
+
+ fmt = fmt.replace("%D", "%m/%d/%y");
+ fmt = fmt.replace("%r", "%I:%M:%S %p");
+ fmt = fmt.replace("%Y", "" + d.getFullYear());
+ fmt = fmt.replace("%y", "" + d.getYear());
+ fmt = fmt.replace("%m", addZeros(d.getMonth()+1, 2));
+ fmt = fmt.replace("%d", addZeros(d.getDate(), 2));
+ fmt = fmt.replace("%H", "" + addZeros(d.getHours(), 2));
+ fmt = fmt.replace("%M", "" + addZeros(d.getMinutes(), 2));
+ fmt = fmt.replace("%S", "" + addZeros(d.getSeconds(), 2));
+ fmt = fmt.replace("%I", "" + ((d.getHours() + 11) % 12 + 1));
+ fmt = fmt.replace("%p", "" + (d.getHours() < 12 ? "AM" : "PM"));
+ fmt = fmt.replace("%B", "" + tinyMCE.getLang("template_months_long").split(',')[d.getMonth()]);
+ fmt = fmt.replace("%b", "" + tinyMCE.getLang("template_months_short").split(',')[d.getMonth()]);
+ fmt = fmt.replace("%A", "" + tinyMCE.getLang("template_day_long").split(',')[d.getDay()]);
+ fmt = fmt.replace("%a", "" + tinyMCE.getLang("template_day_short").split(',')[d.getDay()]);
+ fmt = fmt.replace("%%", "%");
+
+ return fmt;
+ }
+ });
+
+ // Register plugin
+ tinymce.PluginManager.add('template', tinymce.plugins.TemplatePlugin);
+})(); \ No newline at end of file
diff --git a/extensions/tinymce/jscripts/tiny_mce/plugins/template/js/template.js b/extensions/tinymce/jscripts/tiny_mce/plugins/template/js/template.js
new file mode 100644
index 0000000..24045d7
--- /dev/null
+++ b/extensions/tinymce/jscripts/tiny_mce/plugins/template/js/template.js
@@ -0,0 +1,106 @@
+tinyMCEPopup.requireLangPack();
+
+var TemplateDialog = {
+ preInit : function() {
+ var url = tinyMCEPopup.getParam("template_external_list_url");
+
+ if (url != null)
+ document.write('<sc'+'ript language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></sc'+'ript>');
+ },
+
+ init : function() {
+ var ed = tinyMCEPopup.editor, tsrc, sel, x, u;
+
+ tsrc = ed.getParam("template_templates", false);
+ sel = document.getElementById('tpath');
+
+ // Setup external template list
+ if (!tsrc && typeof(tinyMCETemplateList) != 'undefined') {
+ for (x=0, tsrc = []; x<tinyMCETemplateList.length; x++)
+ tsrc.push({title : tinyMCETemplateList[x][0], src : tinyMCETemplateList[x][1], description : tinyMCETemplateList[x][2]});
+ }
+
+ for (x=0; x<tsrc.length; x++)
+ sel.options[sel.options.length] = new Option(tsrc[x].title, tinyMCEPopup.editor.documentBaseURI.toAbsolute(tsrc[x].src));
+
+ this.resize();
+ this.tsrc = tsrc;
+ },
+
+ resize : function() {
+ var w, h, e;
+
+ if (!self.innerWidth) {
+ w = document.body.clientWidth - 50;
+ h = document.body.clientHeight - 160;
+ } else {
+ w = self.innerWidth - 50;
+ h = self.innerHeight - 170;
+ }
+
+ e = document.getElementById('templatesrc');
+
+ if (e) {
+ e.style.height = Math.abs(h) + 'px';
+ e.style.width = Math.abs(w - 5) + 'px';
+ }
+ },
+
+ loadCSSFiles : function(d) {
+ var ed = tinyMCEPopup.editor;
+
+ tinymce.each(ed.getParam("content_css", '').split(','), function(u) {
+ d.write('<link href="' + ed.documentBaseURI.toAbsolute(u) + '" rel="stylesheet" type="text/css" />');
+ });
+ },
+
+ selectTemplate : function(u, ti) {
+ var d = window.frames['templatesrc'].document, x, tsrc = this.tsrc;
+
+ if (!u)
+ return;
+
+ d.body.innerHTML = this.templateHTML = this.getFileContents(u);
+
+ for (x=0; x<tsrc.length; x++) {
+ if (tsrc[x].title == ti)
+ document.getElementById('tmpldesc').innerHTML = tsrc[x].description || '';
+ }
+ },
+
+ insert : function() {
+ tinyMCEPopup.execCommand('mceInsertTemplate', false, {
+ content : this.templateHTML,
+ selection : tinyMCEPopup.editor.selection.getContent()
+ });
+
+ tinyMCEPopup.close();
+ },
+
+ getFileContents : function(u) {
+ var x, d, t = 'text/plain';
+
+ function g(s) {
+ x = 0;
+
+ try {
+ x = new ActiveXObject(s);
+ } catch (s) {
+ }
+
+ return x;
+ };
+
+ x = window.ActiveXObject ? g('Msxml2.XMLHTTP') || g('Microsoft.XMLHTTP') : new XMLHttpRequest();
+
+ // Synchronous AJAX load file
+ x.overrideMimeType && x.overrideMimeType(t);
+ x.open("GET", u, false);
+ x.send(null);
+
+ return x.responseText;
+ }
+};
+
+TemplateDialog.preInit();
+tinyMCEPopup.onInit.add(TemplateDialog.init, TemplateDialog);
diff --git a/extensions/tinymce/jscripts/tiny_mce/plugins/template/langs/en_dlg.js b/extensions/tinymce/jscripts/tiny_mce/plugins/template/langs/en_dlg.js
new file mode 100644
index 0000000..2471c3f
--- /dev/null
+++ b/extensions/tinymce/jscripts/tiny_mce/plugins/template/langs/en_dlg.js
@@ -0,0 +1,15 @@
+tinyMCE.addI18n('en.template_dlg',{
+title:"Templates",
+label:"Template",
+desc_label:"Description",
+desc:"Insert predefined template content",
+select:"Select a template",
+preview:"Preview",
+warning:"Warning: Updating a template with a different one may cause data loss.",
+mdate_format:"%Y-%m-%d %H:%M:%S",
+cdate_format:"%Y-%m-%d %H:%M:%S",
+months_long:"January,February,March,April,May,June,July,August,September,October,November,December",
+months_short:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec",
+day_long:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday",
+day_short:"Sun,Mon,Tue,Wed,Thu,Fri,Sat,Sun"
+}); \ No newline at end of file
diff --git a/extensions/tinymce/jscripts/tiny_mce/plugins/template/template.htm b/extensions/tinymce/jscripts/tiny_mce/plugins/template/template.htm
new file mode 100644
index 0000000..2b71c6e
--- /dev/null
+++ b/extensions/tinymce/jscripts/tiny_mce/plugins/template/template.htm
@@ -0,0 +1,39 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>{#template_dlg.title}</title>
+ <script type="text/javascript" src="../../tiny_mce_popup.js"></script>
+ <script type="text/javascript" src="js/template.js"></script>
+ <link href="css/template.css" rel="stylesheet" type="text/css" />
+ <base target="_self" />
+</head>
+<body onresize="TemplateDialog.resize();">
+ <form onsubmit="TemplateDialog.insert();return false;">
+ <div id="frmbody">
+ <div class="title">{#template_dlg.desc}</div>
+ <div class="frmRow"><label for="tpath" title="{#template_dlg.select}">{#template_dlg.label}:</label>
+ <select id="tpath" name="tpath" onchange="TemplateDialog.selectTemplate(this.options[this.selectedIndex].value, this.options[this.selectedIndex].text);" class="mceFocus">
+ <option value="">{#template_dlg.select}...</option>
+ </select>
+ <span id="warning"></span></div>
+ <div class="frmRow"><label for="tdesc">{#template_dlg.desc_label}:</label>
+ <span id="tmpldesc"></span></div>
+ <fieldset>
+ <legend>{#template_dlg.preview}</legend>
+ <iframe id="templatesrc" name="templatesrc" src="blank.htm" width="690" height="400" frameborder="0"></iframe>
+ </fieldset>
+ </div>
+
+ <div class="mceActionPanel">
+ <div style="float: left">
+ <input type="submit" id="insert" name="insert" value="{#insert}" />
+ </div>
+
+ <div style="float: right">
+ <input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
+ </div>
+
+ <br style="clear:both" />
+ </div>
+ </form>
+</body>
+</html>