1 tinyMCEPopup.requireLangPack();
\r
3 var TemplateDialog = {
\r
4 preInit : function() {
\r
5 var url = tinyMCEPopup.getParam("template_external_list_url");
\r
8 document.write('<sc'+'ript language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></sc'+'ript>');
\r
12 var ed = tinyMCEPopup.editor, tsrc, sel, x, u;
\r
14 tsrc = ed.getParam("template_templates", false);
\r
15 sel = document.getElementById('tpath');
\r
17 // Setup external template list
\r
18 if (!tsrc && typeof(tinyMCETemplateList) != 'undefined') {
\r
19 for (x=0, tsrc = []; x<tinyMCETemplateList.length; x++)
\r
20 tsrc.push({title : tinyMCETemplateList[x][0], src : tinyMCETemplateList[x][1], description : tinyMCETemplateList[x][2]});
\r
23 for (x=0; x<tsrc.length; x++)
\r
24 sel.options[sel.options.length] = new Option(tsrc[x].title, tinyMCEPopup.editor.documentBaseURI.toAbsolute(tsrc[x].src));
\r
30 resize : function() {
\r
33 if (!self.innerWidth) {
\r
34 w = document.body.clientWidth - 50;
\r
35 h = document.body.clientHeight - 160;
\r
37 w = self.innerWidth - 50;
\r
38 h = self.innerHeight - 170;
\r
41 e = document.getElementById('templatesrc');
\r
44 e.style.height = Math.abs(h) + 'px';
\r
45 e.style.width = Math.abs(w - 5) + 'px';
\r
49 loadCSSFiles : function(d) {
\r
50 var ed = tinyMCEPopup.editor;
\r
52 tinymce.each(ed.getParam("content_css", '').split(','), function(u) {
\r
53 d.write('<link href="' + ed.documentBaseURI.toAbsolute(u) + '" rel="stylesheet" type="text/css" />');
\r
57 selectTemplate : function(u, ti) {
\r
58 var d = window.frames['templatesrc'].document, x, tsrc = this.tsrc;
\r
63 d.body.innerHTML = this.templateHTML = this.getFileContents(u);
\r
65 for (x=0; x<tsrc.length; x++) {
\r
66 if (tsrc[x].title == ti)
\r
67 document.getElementById('tmpldesc').innerHTML = tsrc[x].description || '';
\r
71 insert : function() {
\r
72 tinyMCEPopup.execCommand('mceInsertTemplate', false, {
\r
73 content : this.templateHTML,
\r
74 selection : tinyMCEPopup.editor.selection.getContent()
\r
77 tinyMCEPopup.close();
\r
80 getFileContents : function(u) {
\r
81 var x, d, t = 'text/plain';
\r
87 x = new ActiveXObject(s);
\r
94 x = window.ActiveXObject ? g('Msxml2.XMLHTTP') || g('Microsoft.XMLHTTP') : new XMLHttpRequest();
\r
96 // Synchronous AJAX load file
\r
97 x.overrideMimeType && x.overrideMimeType(t);
\r
98 x.open("GET", u, false);
\r
101 return x.responseText;
\r
105 TemplateDialog.preInit();
\r
106 tinyMCEPopup.onInit.add(TemplateDialog.init, TemplateDialog);
\r