Subversion Repositories Sites.tela-botanica.org

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
420 florian 1
var tinyMCE_GZ = {
2
	settings : {
3
		plugins : 'style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras',
4
		themes : 'simple,advanced',
5
		languages : 'en',
6
		disk_cache : true,
7
		page_name : 'tiny_mce_gzip.php',
8
		debug : false
9
	},
10
 
11
	init : function(s) {
12
		var n, d = document, nl, i, b = '', sr, db;
13
 
14
		this.isIE = (navigator.appName == "Microsoft Internet Explorer");
15
		this.isOpera = navigator.userAgent.indexOf('Opera') != -1;
16
 
17
		for (n in s)
18
			this.settings[n] = s[n];
19
 
20
		for (i=0, nl = d.getElementsByTagName('base'); i<nl.length; i++) {
21
			if (nl[i].href)
22
				b = nl[i].href;
23
		}
24
 
25
		for (i=0, nl = d.getElementsByTagName('script'); i<nl.length; i++) {
26
			if (nl[i].src && nl[i].src.indexOf('tiny_mce_gzip') != -1) {
27
				sr = nl[i].src;
28
				sr = sr.substring(0, sr.lastIndexOf('/'));
29
 
30
				if (b != '' && b.indexOf('://') == -1)
31
					b += sr;
32
				else
33
					b = sr;
34
			}
35
		}
36
 
37
		db = document.location.href;
38
 
39
		if (db.indexOf('?') != -1)
40
			db = db.substring(0, db.indexOf('?'));
41
 
42
		db = db.substring(0, db.lastIndexOf('/'));
43
 
44
		if (b.indexOf('://') == -1 && b.charAt(0) != '/')
45
			b = db + "/" + b;
46
 
47
		this.baseURL = b + '/';
48
		this.load(this.settings.page_name);
49
	},
50
 
51
	load : function(v) {
52
		var s = this.settings, h, d = document, sp2;
53
 
54
		v += '?js=true&plugins=' + escape(s.plugins);
55
		v += '&themes=' + escape(s.themes);
56
		v += '&languages=' + escape(s.languages);
57
		v += '&diskcache=' + (s.disk_cache ? 'true' : 'false');
58
		//v += this.checkCompress() ? '' : '&compress=false';
59
 
60
		this.loadFile(this.baseURL + v);
61
	},
62
 
63
	checkCompress : function() {
64
		var sp2, ver, na = navigator, ua = navigator.userAgent;
65
 
66
		// Non IE browsers are fine
67
		if (!this.isIE)
68
			return 1;
69
 
70
		sp2 = na.appMinorVersion.indexOf('SP2') != -1;
71
		ver = parseFloat(ua.match(/MSIE\s+([0-9\.]+)/)[1]);
72
 
73
		// IE 6.0+ with SP2 seems fine
74
		if (ver >= 6 && sp2)
75
			return 1;
76
 
77
		// IE 7.0+ seems fine
78
		if (ver >= 7)
79
			return 1;
80
 
81
		// All others might fail
82
		return 0;
83
	},
84
 
85
	loadFile : function(u) {
86
		var x, ex;
87
 
88
		if (this.settings['debug'])
89
			alert('JS: ' + u);
90
 
91
		if (this.isIE) {
92
			// Synchronous AJAX load gzip JS file
93
			try {
94
				x = new ActiveXObject("Microsoft.XMLHTTP");
95
			} catch (ex) {
96
				x = new ActiveXObject("Msxml2.XMLHTTP");
97
			}
98
 
99
			x.open("GET", u.replace(/%2C/g, ','), false);
100
			x.send(null);
101
 
102
			this.scriptData = x.responseText;
103
 
104
			document.write('<script type="text/javascript">eval(tinyMCE_GZ.scriptData);</script>');
105
		} else
106
			document.write('<script type="text/javascript" src="' + u + '"></script>');
107
	},
108
 
109
	start : function() {
110
		var s = this.settings, p = TinyMCE_Engine.prototype;
111
 
112
		p.__loadScript = p.loadScript;
113
		p.__importThemeLanguagePack = p.importThemeLanguagePack;
114
		p.__importPluginLanguagePack = p.importPluginLanguagePack;
115
		p.__loadNextScript = p.loadNextScript;
116
		p.loadScript = p.importThemeLanguagePack = p.importPluginLanguagePack = p.loadNextScript = function() {};
117
		tinyMCE.baseURL = this.baseURL.substring(0, this.baseURL.length - 1);
118
		tinyMCE.settings = {};
119
		tinyMCE.srcMode = '';
120
	},
121
 
122
	end : function() {
123
		var s = this.settings, l = tinyMCE.loadedFiles, la, i, p = TinyMCE_Engine.prototype;
124
 
125
		this.addFiles(s.plugins, 'plugins', 'editor_plugin.js');
126
		this.addFiles(s.themes, 'themes', 'editor_template.js');
127
 
128
		la = s.languages.replace(/\s+/, '').split(',')
129
		for (i=0; i<la.length; i++)
130
			l[l.length] = this.baseURL + 'langs/' + la[i] + '.js';
131
 
132
		p.loadScript = p.__loadScript;
133
		p.importThemeLanguagePack = p.__importThemeLanguagePack;
134
		p.importPluginLanguagePack = p.__importPluginLanguagePack;
135
		p.loadNextScript = p.__loadNextScript;
136
	},
137
 
138
	addFiles : function(f, c, e) {
139
		var i, a, s = this.settings, l = tinyMCE.loadedFiles, la, x;
140
 
141
		a = f.replace(/\s+/, '').split(',');
142
		for (i=0; i<a.length; i++) {
143
			if (a[i]) {
144
				l[l.length] = this.baseURL + c + '/' +  a[i] + '/' + e;
145
 
146
				la = s.languages.replace(/\s+/, '').split(',')
147
				for (x=0; x<la.length; x++)
148
					l[l.length] = this.baseURL + c + '/' +  a[i] + '/langs/' + la[x] + '.js';
149
			}
150
		}
151
	}
152
};