annotate WebContent/jscripts/tiny_mce/plugins/template/js/template.js @ 6:5bb7cc86069c

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