annotate media/js/tiny_mce/plugins/template/js/template.js @ 171:b1766b1bda45

Add rss news feed link on home page. Add rss news feed image and link on news home.
author Brian Neal <bgneal@gmail.com>
date Fri, 12 Feb 2010 04:24:47 +0000
parents a5b4c5ce0658
children
rev   line source
bgneal@45 1 tinyMCEPopup.requireLangPack();
bgneal@45 2
bgneal@45 3 var TemplateDialog = {
bgneal@45 4 preInit : function() {
bgneal@45 5 var url = tinyMCEPopup.getParam("template_external_list_url");
bgneal@45 6
bgneal@45 7 if (url != null)
bgneal@45 8 document.write('<sc'+'ript language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></sc'+'ript>');
bgneal@45 9 },
bgneal@45 10
bgneal@45 11 init : function() {
bgneal@45 12 var ed = tinyMCEPopup.editor, tsrc, sel, x, u;
bgneal@45 13
bgneal@45 14 tsrc = ed.getParam("template_templates", false);
bgneal@45 15 sel = document.getElementById('tpath');
bgneal@45 16
bgneal@45 17 // Setup external template list
bgneal@45 18 if (!tsrc && typeof(tinyMCETemplateList) != 'undefined') {
bgneal@45 19 for (x=0, tsrc = []; x<tinyMCETemplateList.length; x++)
bgneal@45 20 tsrc.push({title : tinyMCETemplateList[x][0], src : tinyMCETemplateList[x][1], description : tinyMCETemplateList[x][2]});
bgneal@45 21 }
bgneal@45 22
bgneal@45 23 for (x=0; x<tsrc.length; x++)
bgneal@45 24 sel.options[sel.options.length] = new Option(tsrc[x].title, tinyMCEPopup.editor.documentBaseURI.toAbsolute(tsrc[x].src));
bgneal@45 25
bgneal@45 26 this.resize();
bgneal@45 27 this.tsrc = tsrc;
bgneal@45 28 },
bgneal@45 29
bgneal@45 30 resize : function() {
bgneal@45 31 var w, h, e;
bgneal@45 32
bgneal@45 33 if (!self.innerWidth) {
bgneal@45 34 w = document.body.clientWidth - 50;
bgneal@45 35 h = document.body.clientHeight - 160;
bgneal@45 36 } else {
bgneal@45 37 w = self.innerWidth - 50;
bgneal@45 38 h = self.innerHeight - 170;
bgneal@45 39 }
bgneal@45 40
bgneal@45 41 e = document.getElementById('templatesrc');
bgneal@45 42
bgneal@45 43 if (e) {
bgneal@45 44 e.style.height = Math.abs(h) + 'px';
bgneal@45 45 e.style.width = Math.abs(w - 5) + 'px';
bgneal@45 46 }
bgneal@45 47 },
bgneal@45 48
bgneal@45 49 loadCSSFiles : function(d) {
bgneal@45 50 var ed = tinyMCEPopup.editor;
bgneal@45 51
bgneal@45 52 tinymce.each(ed.getParam("content_css", '').split(','), function(u) {
bgneal@45 53 d.write('<link href="' + ed.documentBaseURI.toAbsolute(u) + '" rel="stylesheet" type="text/css" />');
bgneal@45 54 });
bgneal@45 55 },
bgneal@45 56
bgneal@45 57 selectTemplate : function(u, ti) {
bgneal@45 58 var d = window.frames['templatesrc'].document, x, tsrc = this.tsrc;
bgneal@45 59
bgneal@45 60 if (!u)
bgneal@45 61 return;
bgneal@45 62
bgneal@45 63 d.body.innerHTML = this.templateHTML = this.getFileContents(u);
bgneal@45 64
bgneal@45 65 for (x=0; x<tsrc.length; x++) {
bgneal@45 66 if (tsrc[x].title == ti)
bgneal@45 67 document.getElementById('tmpldesc').innerHTML = tsrc[x].description || '';
bgneal@45 68 }
bgneal@45 69 },
bgneal@45 70
bgneal@45 71 insert : function() {
bgneal@45 72 tinyMCEPopup.execCommand('mceInsertTemplate', false, {
bgneal@45 73 content : this.templateHTML,
bgneal@45 74 selection : tinyMCEPopup.editor.selection.getContent()
bgneal@45 75 });
bgneal@45 76
bgneal@45 77 tinyMCEPopup.close();
bgneal@45 78 },
bgneal@45 79
bgneal@45 80 getFileContents : function(u) {
bgneal@45 81 var x, d, t = 'text/plain';
bgneal@45 82
bgneal@45 83 function g(s) {
bgneal@45 84 x = 0;
bgneal@45 85
bgneal@45 86 try {
bgneal@45 87 x = new ActiveXObject(s);
bgneal@45 88 } catch (s) {
bgneal@45 89 }
bgneal@45 90
bgneal@45 91 return x;
bgneal@45 92 };
bgneal@45 93
bgneal@45 94 x = window.ActiveXObject ? g('Msxml2.XMLHTTP') || g('Microsoft.XMLHTTP') : new XMLHttpRequest();
bgneal@45 95
bgneal@45 96 // Synchronous AJAX load file
bgneal@45 97 x.overrideMimeType && x.overrideMimeType(t);
bgneal@45 98 x.open("GET", u, false);
bgneal@45 99 x.send(null);
bgneal@45 100
bgneal@45 101 return x.responseText;
bgneal@45 102 }
bgneal@45 103 };
bgneal@45 104
bgneal@45 105 TemplateDialog.preInit();
bgneal@45 106 tinyMCEPopup.onInit.add(TemplateDialog.init, TemplateDialog);