Subversion Repositories Sites.tela-botanica.org

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
420 florian 1
/**
2
 * $Id: editor_plugin_src.js 42 2006-08-08 14:32:24Z spocke $
3
 *
4
 * @author Moxiecode
5
 * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
6
 */
7
 
8
tinyMCE.importPluginLanguagePack('devkit');
9
 
10
var TinyMCE_DevKitPlugin = {
11
	_logFilter : '\\[(importCSS|execCommand|execInstanceCommand|debug)\\]',
12
	_logPadding : '',
13
	_startTime : null,
14
	_benchMark : false,
15
	_winLoaded : false,
16
	_isDebugEvents : false,
17
 
18
	getInfo : function() {
19
		return {
20
			longname : 'Development Kit',
21
			author : 'Moxiecode Systems AB',
22
			authorurl : 'http://tinymce.moxiecode.com',
23
			infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/devkit',
24
			version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
25
		};
26
	},
27
 
28
	initInstance : function(inst) {
29
		this._setup();
30
	},
31
 
32
	_setup : function() {
33
		if (this._loaded)
34
			return;
35
 
36
		this._loaded = true;
37
 
38
		// Register a document reference for more easy access in the FF DOM inspector
39
		document.___TinyMCE = tinyMCE;
40
 
41
		// Setup devkit by settings
42
		this._logFilter = tinyMCE.getParam('devkit_log_filter', this._logFilter);
43
		this._benchMark = tinyMCE.getParam('devkit_bench_mark', false);
44
 
45
		var ifr = document.createElement('iframe');
46
 
47
		ifr.setAttribute("id", "devkit");
48
		ifr.setAttribute("frameBorder", "0");
49
		ifr.setAttribute("src", tinyMCE.baseURL + '/plugins/devkit/devkit.htm');
50
 
51
		document.body.appendChild(ifr);
52
 
53
		// Workaround for strange IE reload bug
54
		//if (tinyMCE.isRealIE)
55
		//	document.getElementById('devkit').outerHTML = document.getElementById('devkit').outerHTML;
56
 
57
		tinyMCE.importCSS(document, tinyMCE.baseURL + '/plugins/devkit/css/devkit_ui.css');
58
	},
59
 
60
	_start : function() {
61
		this._logPadding += '\u00a0';
62
 
63
		return new Date().getTime();
64
	},
65
 
66
	_end : function(st) {
67
		if (this._logPadding.length > 0)
68
			this._logPadding = this._logPadding.substring(0, this._logPadding.length - 1);
69
 
70
		if (this._benchMark)
71
			this._log("benchmark", "Execution time: " + (new Date().getTime() - st));
72
	},
73
 
74
	_log : function(t) {
75
		var m, a, i, e = document.getElementById('devkit'), now = new Date().getTime();
76
 
77
		if (!this._startTime)
78
			this._startTime = now;
79
 
80
		m = (this._logPadding.length > 1 ? this._logPadding : '') + '[' + (now - this._startTime) + '] [' + t + '] ';
81
 
82
		a = this._log.arguments;
83
		for (i=1; i<a.length; i++) {
84
			if (typeof(a[i]) == 'undefined')
85
				continue;
86
 
87
			if (i > 1)
88
				m += ', ';
89
 
90
			m += a[i];
91
		}
92
 
93
		if (!new RegExp(this._logFilter, 'gi').test(m)) {
94
			if (this._logPadding.length > 0)
95
				this._logPadding = this._logPadding.substring(0, this._logPadding.length - 1);
96
 
97
			return;
98
		}
99
 
100
		if (!this._winLoaded)
101
			tinyMCE.log[tinyMCE.log.length] = m;
102
		else
103
			e.contentWindow.debug(m);
104
	},
105
 
106
	_debugEvents : function(s) {
107
		var i, ld, inst, n, ev = ['CheckboxStateChange','DOMAttrModified','DOMMenuItemActive',
108
				'DOMMenuItemInactive','DOMMouseScroll','DOMNodeInserted','DOMNodeRemoved',
109
				'RadioStateChange','blur','broadcast','change','click','close','command',
110
				'commandupdate','contextmenu','dblclick','dragdrop','dragenter','dragexit',
111
				'draggesture','dragover','focus','input','keydown','keypress','keyup','load',
112
				'mousedown','mouseout','mouseover','mouseup','overflow','overflowchanged','popuphidden',
113
				'popuphiding','popupshowing','popupshown','select','syncfrompreference','synctopreference',
114
				'underflow','unload','abort','activate','afterprint','afterupdate','beforeactivate',
115
				'beforecopy','beforecut','beforedeactivate','beforeeditfocus','beforepaste','beforeprint',
116
				'beforeunload','beforeupdate','bounce','cellchange','controlselect','copy','cut',
117
				'dataavailable','datasetchanged','datasetcomplete','deactivate','dragend','dragleave',
118
				'dragstart','drop','error','errorupdate','filterchange','finish','focusin','focusout',
119
				'help','layoutcomplete','losecapture','mouseenter','mouseleave','mousewheel',
120
				'move','moveend','movestart','paste','propertychange','readystatechange','reset','resize',
121
				'resizeend','resizestart','rowenter','rowexit','rowsdelete','rowsinserted','scroll',
122
				'selectionchange','selectstart','start','stop','submit'];
123
		// mousemove
124
 
125
		if (TinyMCE_DevKitPlugin._isDebugEvents == s)
126
			return;
127
 
128
		TinyMCE_DevKitPlugin._isDebugEvents = s;
129
 
130
		for (n in tinyMCE.instances) {
131
			inst = tinyMCE.instances[n];
132
 
133
			if (!tinyMCE.isInstance(inst) || inst.getDoc() == ld)
134
				continue;
135
 
136
			ld = inst.getDoc();
137
 
138
			for (i=0; i<ev.length; i++) {
139
				if (s)
140
					tinyMCE.addEvent(ld, ev[i], TinyMCE_DevKitPlugin._debugEvent);
141
				else
142
					tinyMCE.removeEvent(ld, ev[i], TinyMCE_DevKitPlugin._debugEvent);
143
			}
144
		}
145
	},
146
 
147
	_debugEvent : function(e) {
148
		var t;
149
 
150
		e = e ? e : tinyMCE.selectedInstance.getWin().event;
151
		t = e.srcElement ? e.srcElement : e.target;
152
 
153
		tinyMCE.debug(e.type, t ? t.nodeName : '');
154
	},
155
 
156
	_serialize : function(o) {
157
		var i, v, s = TinyMCE_DevKitPlugin._serialize;
158
 
159
		if (o == null)
160
			return 'null';
161
 
162
		switch (typeof o) {
163
			case 'string':
164
				v = '\bb\tt\nn\ff\rr\""\'\'\\\\';
165
 
166
				return '"' + o.replace(new RegExp('([\u0080-\uFFFF\\x00-\\x1f\\"])', 'g'), function(a, b) {
167
					i = v.indexOf(b);
168
 
169
					if (i+1)
170
						return '\\' + v.charAt(i + 1);
171
 
172
					a = b.charCodeAt().toString(16);
173
 
174
					return '\\u' + '0000'.substring(a.length) + a;
175
				}) + '"';
176
 
177
			case 'object':
178
				if (o instanceof Array) {
179
					for (i=0, v = '['; i<o.length; i++)
180
						v += (i > 0 ? ',' : '') + s(o[i]);
181
 
182
					return v + ']';
183
				}
184
 
185
				v = '{';
186
 
187
				for (i in o)
188
					v += typeof o[i] != 'function' ? (v.length > 1 ? ',"' : '"') + i + '":' + s(o[i]) : '';
189
 
190
				return v + '}';
191
		}
192
 
193
		return '' + o;
194
	}
195
};
196
 
197
// Patch and piggy back functions
198
tinyMCE.__debug = tinyMCE.debug;
199
tinyMCE.debug = function() {
200
	var a, i, m = '', now = new Date().getTime(), start = TinyMCE_DevKitPlugin._startTime;
201
 
202
	if (!start)
203
		TinyMCE_DevKitPlugin._startTime = start = now;
204
 
205
	a = this.debug.arguments;
206
	for (i=0; i<a.length; i++) {
207
		if (typeof(a[i]) == 'undefined')
208
			continue;
209
 
210
		if (i > 0)
211
			m += ', ';
212
 
213
		m += a[i];
214
	}
215
 
216
	TinyMCE_DevKitPlugin._log('debug', m);
217
};
218
 
219
tinyMCE.dump = function(o) {
220
	tinyMCE.debug(TinyMCE_DevKitPlugin._serialize(o));
221
};
222
 
223
tinyMCE.sleep = function(t) {
224
	var s = new Date().getTime(), b;
225
 
226
	while (new Date().getTime() - s < t) b=1;
227
};
228
 
229
tinyMCE.__execCommand = tinyMCE.execCommand;
230
tinyMCE.execCommand = function(command, user_interface, value) {
231
	var r, st, dk = TinyMCE_DevKitPlugin;
232
 
233
	st = dk._start();
234
	dk._log('execCommand', command, user_interface, value);
235
	r = tinyMCE.__execCommand(command, user_interface, value);
236
	dk._end(st);
237
 
238
	return r;
239
};
240
 
241
tinyMCE.__execInstanceCommand = tinyMCE.execInstanceCommand;
242
tinyMCE.execInstanceCommand = function(editor_id, command, user_interface, value, focus) {
243
	var r, st, dk = TinyMCE_DevKitPlugin;
244
 
245
	st = dk._start();
246
	dk._log('execInstanceCommand', editor_id, command, user_interface, value);
247
	r = tinyMCE.__execInstanceCommand(editor_id, command, user_interface, value);
248
	dk._end(st);
249
 
250
	return r;
251
};
252
 
253
TinyMCE_Engine.prototype.__handleEvent = TinyMCE_Engine.prototype.handleEvent;
254
TinyMCE_Engine.prototype.handleEvent = function(e) {
255
	var r, st, dk = TinyMCE_DevKitPlugin;
256
 
257
	st = dk._start();
258
	dk._log('handleEvent', e.type);
259
	r = tinyMCE.__handleEvent(e);
260
	dk._end(st);
261
 
262
	return r;
263
};
264
 
265
tinyMCE.__importCSS = tinyMCE.importCSS;
266
tinyMCE.importCSS = function(doc, css) {
267
	var r, st, dk = TinyMCE_DevKitPlugin;
268
 
269
	st = dk._start();
270
	dk._log('importCSS', doc, css);
271
	r = tinyMCE.__importCSS(doc, css);
272
	dk._end(st);
273
 
274
	return r;
275
};
276
 
277
tinyMCE.__triggerNodeChange = tinyMCE.triggerNodeChange;
278
tinyMCE.triggerNodeChange = function(focus, setup_content) {
279
	var r, st, dk = TinyMCE_DevKitPlugin;
280
 
281
	st = dk._start();
282
	dk._log('triggerNodeChange', focus, setup_content);
283
	r = tinyMCE.__triggerNodeChange(focus, setup_content);
284
	dk._end(st);
285
 
286
	return r;
287
};
288
 
289
tinyMCE.__dispatchCallback = tinyMCE.dispatchCallback;
290
tinyMCE.dispatchCallback = function(i, p, n) {
291
	var r, st, dk = TinyMCE_DevKitPlugin;
292
 
293
	st = dk._start();
294
	dk._log('dispatchCallback', i, p, n);
295
	r = tinyMCE.__dispatchCallback(i, p, n);
296
	dk._end(st);
297
 
298
	return r;
299
};
300
 
301
tinyMCE.__executeCallback = tinyMCE.executeCallback;
302
tinyMCE.executeCallback = function(i, p, n) {
303
	var r, st, dk = TinyMCE_DevKitPlugin;
304
 
305
	st = dk._start();
306
	dk._log('executeCallback', i, p, n);
307
	r = tinyMCE.__executeCallback(i, p, n);
308
	dk._end(st);
309
 
310
	return r;
311
};
312
 
313
tinyMCE.__execCommandCallback = tinyMCE.execCommandCallback;
314
tinyMCE.execCommandCallback = function(i, p, n) {
315
	var r, st, dk = TinyMCE_DevKitPlugin;
316
 
317
	st = dk._start();
318
	dk._log('execCommandCallback', i, p, n);
319
	r = tinyMCE.__execCommandCallback(i, p, n);
320
	dk._end(st);
321
 
322
	return r;
323
};
324
 
325
tinyMCE.addPlugin("devkit", TinyMCE_DevKitPlugin);