##// END OF EJS Templates
Wiki toolbar improvements (mainly for Firefox)....
Jean-Philippe Lang -
r1049:4e1e5985a1a6
parent child
Show More
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: file renamed from public/images/jstoolbar/bt_heading.png to public/images/jstoolbar/bt_img.png, binary diff hidden
NO CONTENT: file renamed from public/images/jstoolbar/bt_heading.png to public/images/jstoolbar/bt_img.png, binary diff hidden
@@ -1,468 +1,521
1 /* ***** BEGIN LICENSE BLOCK *****
1 /* ***** BEGIN LICENSE BLOCK *****
2 * This file is part of DotClear.
2 * This file is part of DotClear.
3 * Copyright (c) 2005 Nicolas Martin & Olivier Meunier and contributors. All
3 * Copyright (c) 2005 Nicolas Martin & Olivier Meunier and contributors. All
4 * rights reserved.
4 * rights reserved.
5 *
5 *
6 * DotClear is free software; you can redistribute it and/or modify
6 * DotClear is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
9 * (at your option) any later version.
10 *
10 *
11 * DotClear is distributed in the hope that it will be useful,
11 * DotClear is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
14 * GNU General Public License for more details.
15 *
15 *
16 * You should have received a copy of the GNU General Public License
16 * You should have received a copy of the GNU General Public License
17 * along with DotClear; if not, write to the Free Software
17 * along with DotClear; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
19 *
20 * ***** END LICENSE BLOCK *****
20 * ***** END LICENSE BLOCK *****
21 */
21 */
22
22
23 /* Modified by JP LANG for textile formatting */
23 /* Modified by JP LANG for textile formatting */
24
24
25 function jsToolBar(textarea) {
25 function jsToolBar(textarea) {
26 if (!document.createElement) { return; }
26 if (!document.createElement) { return; }
27
27
28 if (!textarea) { return; }
28 if (!textarea) { return; }
29
29
30 if ((typeof(document["selection"]) == "undefined")
30 if ((typeof(document["selection"]) == "undefined")
31 && (typeof(textarea["setSelectionRange"]) == "undefined")) {
31 && (typeof(textarea["setSelectionRange"]) == "undefined")) {
32 return;
32 return;
33 }
33 }
34
34
35 this.textarea = textarea;
35 this.textarea = textarea;
36
36
37 this.editor = document.createElement('div');
37 this.editor = document.createElement('div');
38 this.editor.className = 'jstEditor';
38 this.editor.className = 'jstEditor';
39
39
40 this.textarea.parentNode.insertBefore(this.editor,this.textarea);
40 this.textarea.parentNode.insertBefore(this.editor,this.textarea);
41 this.editor.appendChild(this.textarea);
41 this.editor.appendChild(this.textarea);
42
42
43 this.toolbar = document.createElement("div");
43 this.toolbar = document.createElement("div");
44 this.toolbar.className = 'jstElements';
44 this.toolbar.className = 'jstElements';
45 this.editor.parentNode.insertBefore(this.toolbar,this.editor);
45 this.editor.parentNode.insertBefore(this.toolbar,this.editor);
46
46
47 // Dragable resizing (only for gecko)
47 // Dragable resizing (only for gecko)
48 if (this.editor.addEventListener)
48 if (this.editor.addEventListener)
49 {
49 {
50 this.handle = document.createElement('div');
50 this.handle = document.createElement('div');
51 this.handle.className = 'jstHandle';
51 this.handle.className = 'jstHandle';
52 var dragStart = this.resizeDragStart;
52 var dragStart = this.resizeDragStart;
53 var This = this;
53 var This = this;
54 this.handle.addEventListener('mousedown',function(event) { dragStart.call(This,event); },false);
54 this.handle.addEventListener('mousedown',function(event) { dragStart.call(This,event); },false);
55 // fix memory leak in Firefox (bug #241518)
55 // fix memory leak in Firefox (bug #241518)
56 window.addEventListener('unload',function() {
56 window.addEventListener('unload',function() {
57 var del = This.handle.parentNode.removeChild(This.handle);
57 var del = This.handle.parentNode.removeChild(This.handle);
58 delete(This.handle);
58 delete(This.handle);
59 },false);
59 },false);
60
60
61 this.editor.parentNode.insertBefore(this.handle,this.editor.nextSibling);
61 this.editor.parentNode.insertBefore(this.handle,this.editor.nextSibling);
62 }
62 }
63
63
64 this.context = null;
64 this.context = null;
65 this.toolNodes = {}; // lorsque la toolbar est dessinée , cet objet est garni
65 this.toolNodes = {}; // lorsque la toolbar est dessinée , cet objet est garni
66 // de raccourcis vers les éléments DOM correspondants aux outils.
66 // de raccourcis vers les éléments DOM correspondants aux outils.
67 }
67 }
68
68
69 function jsButton(title, fn, scope, className) {
69 function jsButton(title, fn, scope, className) {
70 this.title = title || null;
70 this.title = title || null;
71 this.fn = fn || function(){};
71 this.fn = fn || function(){};
72 this.scope = scope || null;
72 this.scope = scope || null;
73 this.className = className || null;
73 this.className = className || null;
74 }
74 }
75 jsButton.prototype.draw = function() {
75 jsButton.prototype.draw = function() {
76 if (!this.scope) return null;
76 if (!this.scope) return null;
77
77
78 var button = document.createElement('button');
78 var button = document.createElement('button');
79 button.setAttribute('type','button');
79 button.setAttribute('type','button');
80 if (this.className) button.className = this.className;
80 if (this.className) button.className = this.className;
81 button.title = this.title;
81 button.title = this.title;
82 var span = document.createElement('span');
82 var span = document.createElement('span');
83 span.appendChild(document.createTextNode(this.title));
83 span.appendChild(document.createTextNode(this.title));
84 button.appendChild(span);
84 button.appendChild(span);
85
85
86 if (this.icon != undefined) {
86 if (this.icon != undefined) {
87 button.style.backgroundImage = 'url('+this.icon+')';
87 button.style.backgroundImage = 'url('+this.icon+')';
88 }
88 }
89 if (typeof(this.fn) == 'function') {
89 if (typeof(this.fn) == 'function') {
90 var This = this;
90 var This = this;
91 button.onclick = function() { try { This.fn.apply(This.scope, arguments) } catch (e) {} return false; };
91 button.onclick = function() { try { This.fn.apply(This.scope, arguments) } catch (e) {} return false; };
92 }
92 }
93 return button;
93 return button;
94 }
94 }
95
95
96 function jsSpace(id) {
96 function jsSpace(id) {
97 this.id = id || null;
97 this.id = id || null;
98 this.width = null;
98 this.width = null;
99 }
99 }
100 jsSpace.prototype.draw = function() {
100 jsSpace.prototype.draw = function() {
101 var span = document.createElement('span');
101 var span = document.createElement('span');
102 if (this.id) span.id = this.id;
102 if (this.id) span.id = this.id;
103 span.appendChild(document.createTextNode(String.fromCharCode(160)));
103 span.appendChild(document.createTextNode(String.fromCharCode(160)));
104 span.className = 'jstSpacer';
104 span.className = 'jstSpacer';
105 if (this.width) span.style.marginRight = this.width+'px';
105 if (this.width) span.style.marginRight = this.width+'px';
106
106
107 return span;
107 return span;
108 }
108 }
109
109
110 function jsCombo(title, options, scope, fn, className) {
110 function jsCombo(title, options, scope, fn, className) {
111 this.title = title || null;
111 this.title = title || null;
112 this.options = options || null;
112 this.options = options || null;
113 this.scope = scope || null;
113 this.scope = scope || null;
114 this.fn = fn || function(){};
114 this.fn = fn || function(){};
115 this.className = className || null;
115 this.className = className || null;
116 }
116 }
117 jsCombo.prototype.draw = function() {
117 jsCombo.prototype.draw = function() {
118 if (!this.scope || !this.options) return null;
118 if (!this.scope || !this.options) return null;
119
119
120 var select = document.createElement('select');
120 var select = document.createElement('select');
121 if (this.className) select.className = className;
121 if (this.className) select.className = className;
122 select.title = this.title;
122 select.title = this.title;
123
123
124 for (var o in this.options) {
124 for (var o in this.options) {
125 //var opt = this.options[o];
125 //var opt = this.options[o];
126 var option = document.createElement('option');
126 var option = document.createElement('option');
127 option.value = o;
127 option.value = o;
128 option.appendChild(document.createTextNode(this.options[o]));
128 option.appendChild(document.createTextNode(this.options[o]));
129 select.appendChild(option);
129 select.appendChild(option);
130 }
130 }
131
131
132 var This = this;
132 var This = this;
133 select.onchange = function() {
133 select.onchange = function() {
134 try {
134 try {
135 This.fn.call(This.scope, this.value);
135 This.fn.call(This.scope, this.value);
136 } catch (e) { alert(e); }
136 } catch (e) { alert(e); }
137
137
138 return false;
138 return false;
139 }
139 }
140
140
141 return select;
141 return select;
142 }
142 }
143
143
144
144
145 jsToolBar.prototype = {
145 jsToolBar.prototype = {
146 base_url: '',
146 base_url: '',
147 mode: 'wiki',
147 mode: 'wiki',
148 elements: {},
148 elements: {},
149
149
150 getMode: function() {
150 getMode: function() {
151 return this.mode;
151 return this.mode;
152 },
152 },
153
153
154 setMode: function(mode) {
154 setMode: function(mode) {
155 this.mode = mode || 'wiki';
155 this.mode = mode || 'wiki';
156 },
156 },
157
157
158 switchMode: function(mode) {
158 switchMode: function(mode) {
159 mode = mode || 'wiki';
159 mode = mode || 'wiki';
160 this.draw(mode);
160 this.draw(mode);
161 },
161 },
162
162
163 button: function(toolName) {
163 button: function(toolName) {
164 var tool = this.elements[toolName];
164 var tool = this.elements[toolName];
165 if (typeof tool.fn[this.mode] != 'function') return null;
165 if (typeof tool.fn[this.mode] != 'function') return null;
166 var b = new jsButton(tool.title, tool.fn[this.mode], this, 'jstb_'+toolName);
166 var b = new jsButton(tool.title, tool.fn[this.mode], this, 'jstb_'+toolName);
167 if (tool.icon != undefined) b.icon = tool.icon;
167 if (tool.icon != undefined) b.icon = tool.icon;
168 return b;
168 return b;
169 },
169 },
170 space: function(toolName) {
170 space: function(toolName) {
171 var tool = new jsSpace(toolName)
171 var tool = new jsSpace(toolName)
172 if (this.elements[toolName].width !== undefined)
172 if (this.elements[toolName].width !== undefined)
173 tool.width = this.elements[toolName].width;
173 tool.width = this.elements[toolName].width;
174 return tool;
174 return tool;
175 },
175 },
176 combo: function(toolName) {
176 combo: function(toolName) {
177 var tool = this.elements[toolName];
177 var tool = this.elements[toolName];
178 var length = tool[this.mode].list.length;
178 var length = tool[this.mode].list.length;
179
179
180 if (typeof tool[this.mode].fn != 'function' || length == 0) {
180 if (typeof tool[this.mode].fn != 'function' || length == 0) {
181 return null;
181 return null;
182 } else {
182 } else {
183 var options = {};
183 var options = {};
184 for (var i=0; i < length; i++) {
184 for (var i=0; i < length; i++) {
185 var opt = tool[this.mode].list[i];
185 var opt = tool[this.mode].list[i];
186 options[opt] = tool.options[opt];
186 options[opt] = tool.options[opt];
187 }
187 }
188 return new jsCombo(tool.title, options, this, tool[this.mode].fn);
188 return new jsCombo(tool.title, options, this, tool[this.mode].fn);
189 }
189 }
190 },
190 },
191 draw: function(mode) {
191 draw: function(mode) {
192 this.setMode(mode);
192 this.setMode(mode);
193
193
194 // Empty toolbar
194 // Empty toolbar
195 while (this.toolbar.hasChildNodes()) {
195 while (this.toolbar.hasChildNodes()) {
196 this.toolbar.removeChild(this.toolbar.firstChild)
196 this.toolbar.removeChild(this.toolbar.firstChild)
197 }
197 }
198 this.toolNodes = {}; // vide les raccourcis DOM/**/
198 this.toolNodes = {}; // vide les raccourcis DOM/**/
199
199
200 // Draw toolbar elements
200 // Draw toolbar elements
201 var b, tool, newTool;
201 var b, tool, newTool;
202
202
203 for (var i in this.elements) {
203 for (var i in this.elements) {
204 b = this.elements[i];
204 b = this.elements[i];
205
205
206 var disabled =
206 var disabled =
207 b.type == undefined || b.type == ''
207 b.type == undefined || b.type == ''
208 || (b.disabled != undefined && b.disabled)
208 || (b.disabled != undefined && b.disabled)
209 || (b.context != undefined && b.context != null && b.context != this.context);
209 || (b.context != undefined && b.context != null && b.context != this.context);
210
210
211 if (!disabled && typeof this[b.type] == 'function') {
211 if (!disabled && typeof this[b.type] == 'function') {
212 tool = this[b.type](i);
212 tool = this[b.type](i);
213 if (tool) newTool = tool.draw();
213 if (tool) newTool = tool.draw();
214 if (newTool) {
214 if (newTool) {
215 this.toolNodes[i] = newTool; //mémorise l'accès DOM pour usage éventuel ultérieur
215 this.toolNodes[i] = newTool; //mémorise l'accès DOM pour usage éventuel ultérieur
216 this.toolbar.appendChild(newTool);
216 this.toolbar.appendChild(newTool);
217 }
217 }
218 }
218 }
219 }
219 }
220 },
220 },
221
221
222 singleTag: function(stag,etag) {
222 singleTag: function(stag,etag) {
223 stag = stag || null;
223 stag = stag || null;
224 etag = etag || stag;
224 etag = etag || stag;
225
225
226 if (!stag || !etag) { return; }
226 if (!stag || !etag) { return; }
227
227
228 this.encloseSelection(stag,etag);
228 this.encloseSelection(stag,etag);
229 },
229 },
230
230
231 encloseLineSelection: function(prefix, suffix, fn) {
232 this.textarea.focus();
233
234 prefix = prefix || '';
235 suffix = suffix || '';
236
237 var start, end, sel, scrollPos, subst, res;
238
239 if (typeof(document["selection"]) != "undefined") {
240 sel = document.selection.createRange().text;
241 } else if (typeof(this.textarea["setSelectionRange"]) != "undefined") {
242 start = this.textarea.selectionStart;
243 end = this.textarea.selectionEnd;
244 scrollPos = this.textarea.scrollTop;
245 // go to the start of the line
246 start = this.textarea.value.substring(0, start).replace(/[^\r\n]*$/g,'').length;
247 // go to the end of the line
248 end = this.textarea.value.length - this.textarea.value.substring(end, this.textarea.value.length).replace(/^[^\r\n]*/, '').length;
249 sel = this.textarea.value.substring(start, end);
250 }
251
252 if (sel.match(/ $/)) { // exclude ending space char, if any
253 sel = sel.substring(0, sel.length - 1);
254 suffix = suffix + " ";
255 }
256
257 if (typeof(fn) == 'function') {
258 res = (sel) ? fn.call(this,sel) : fn('');
259 } else {
260 res = (sel) ? sel : '';
261 }
262
263 subst = prefix + res + suffix;
264
265 if (typeof(document["selection"]) != "undefined") {
266 document.selection.createRange().text = subst;
267 var range = this.textarea.createTextRange();
268 range.collapse(false);
269 range.move('character', -suffix.length);
270 range.select();
271 } else if (typeof(this.textarea["setSelectionRange"]) != "undefined") {
272 this.textarea.value = this.textarea.value.substring(0, start) + subst +
273 this.textarea.value.substring(end);
274 if (sel) {
275 this.textarea.setSelectionRange(start + subst.length, start + subst.length);
276 } else {
277 this.textarea.setSelectionRange(start + prefix.length, start + prefix.length);
278 }
279 this.textarea.scrollTop = scrollPos;
280 }
281 },
282
231 encloseSelection: function(prefix, suffix, fn) {
283 encloseSelection: function(prefix, suffix, fn) {
232 this.textarea.focus();
284 this.textarea.focus();
233
285
234 prefix = prefix || '';
286 prefix = prefix || '';
235 suffix = suffix || '';
287 suffix = suffix || '';
236
288
237 var start, end, sel, scrollPos, subst, res;
289 var start, end, sel, scrollPos, subst, res;
238
290
239 if (typeof(document["selection"]) != "undefined") {
291 if (typeof(document["selection"]) != "undefined") {
240 sel = document.selection.createRange().text;
292 sel = document.selection.createRange().text;
241 } else if (typeof(this.textarea["setSelectionRange"]) != "undefined") {
293 } else if (typeof(this.textarea["setSelectionRange"]) != "undefined") {
242 start = this.textarea.selectionStart;
294 start = this.textarea.selectionStart;
243 end = this.textarea.selectionEnd;
295 end = this.textarea.selectionEnd;
244 scrollPos = this.textarea.scrollTop;
296 scrollPos = this.textarea.scrollTop;
245 sel = this.textarea.value.substring(start, end);
297 sel = this.textarea.value.substring(start, end);
246 }
298 }
247
299
248 if (sel.match(/ $/)) { // exclude ending space char, if any
300 if (sel.match(/ $/)) { // exclude ending space char, if any
249 sel = sel.substring(0, sel.length - 1);
301 sel = sel.substring(0, sel.length - 1);
250 suffix = suffix + " ";
302 suffix = suffix + " ";
251 }
303 }
252
304
253 if (typeof(fn) == 'function') {
305 if (typeof(fn) == 'function') {
254 res = (sel) ? fn.call(this,sel) : fn('');
306 res = (sel) ? fn.call(this,sel) : fn('');
255 } else {
307 } else {
256 res = (sel) ? sel : '';
308 res = (sel) ? sel : '';
257 }
309 }
258
310
259 subst = prefix + res + suffix;
311 subst = prefix + res + suffix;
260
312
261 if (typeof(document["selection"]) != "undefined") {
313 if (typeof(document["selection"]) != "undefined") {
262 document.selection.createRange().text = subst;
314 document.selection.createRange().text = subst;
263 var range = this.textarea.createTextRange();
315 var range = this.textarea.createTextRange();
264 range.collapse(false);
316 range.collapse(false);
265 range.move('character', -suffix.length);
317 range.move('character', -suffix.length);
266 range.select();
318 range.select();
267 // this.textarea.caretPos -= suffix.length;
319 // this.textarea.caretPos -= suffix.length;
268 } else if (typeof(this.textarea["setSelectionRange"]) != "undefined") {
320 } else if (typeof(this.textarea["setSelectionRange"]) != "undefined") {
269 this.textarea.value = this.textarea.value.substring(0, start) + subst +
321 this.textarea.value = this.textarea.value.substring(0, start) + subst +
270 this.textarea.value.substring(end);
322 this.textarea.value.substring(end);
271 if (sel) {
323 if (sel) {
272 this.textarea.setSelectionRange(start + subst.length, start + subst.length);
324 this.textarea.setSelectionRange(start + subst.length, start + subst.length);
273 } else {
325 } else {
274 this.textarea.setSelectionRange(start + prefix.length, start + prefix.length);
326 this.textarea.setSelectionRange(start + prefix.length, start + prefix.length);
275 }
327 }
276 this.textarea.scrollTop = scrollPos;
328 this.textarea.scrollTop = scrollPos;
277 }
329 }
278 },
330 },
279
331
280 stripBaseURL: function(url) {
332 stripBaseURL: function(url) {
281 if (this.base_url != '') {
333 if (this.base_url != '') {
282 var pos = url.indexOf(this.base_url);
334 var pos = url.indexOf(this.base_url);
283 if (pos == 0) {
335 if (pos == 0) {
284 url = url.substr(this.base_url.length);
336 url = url.substr(this.base_url.length);
285 }
337 }
286 }
338 }
287
339
288 return url;
340 return url;
289 }
341 }
290 };
342 };
291
343
292 /** Resizer
344 /** Resizer
293 -------------------------------------------------------- */
345 -------------------------------------------------------- */
294 jsToolBar.prototype.resizeSetStartH = function() {
346 jsToolBar.prototype.resizeSetStartH = function() {
295 this.dragStartH = this.textarea.offsetHeight + 0;
347 this.dragStartH = this.textarea.offsetHeight + 0;
296 };
348 };
297 jsToolBar.prototype.resizeDragStart = function(event) {
349 jsToolBar.prototype.resizeDragStart = function(event) {
298 var This = this;
350 var This = this;
299 this.dragStartY = event.clientY;
351 this.dragStartY = event.clientY;
300 this.resizeSetStartH();
352 this.resizeSetStartH();
301 document.addEventListener('mousemove', this.dragMoveHdlr=function(event){This.resizeDragMove(event);}, false);
353 document.addEventListener('mousemove', this.dragMoveHdlr=function(event){This.resizeDragMove(event);}, false);
302 document.addEventListener('mouseup', this.dragStopHdlr=function(event){This.resizeDragStop(event);}, false);
354 document.addEventListener('mouseup', this.dragStopHdlr=function(event){This.resizeDragStop(event);}, false);
303 };
355 };
304
356
305 jsToolBar.prototype.resizeDragMove = function(event) {
357 jsToolBar.prototype.resizeDragMove = function(event) {
306 this.textarea.style.height = (this.dragStartH+event.clientY-this.dragStartY)+'px';
358 this.textarea.style.height = (this.dragStartH+event.clientY-this.dragStartY)+'px';
307 };
359 };
308
360
309 jsToolBar.prototype.resizeDragStop = function(event) {
361 jsToolBar.prototype.resizeDragStop = function(event) {
310 document.removeEventListener('mousemove', this.dragMoveHdlr, false);
362 document.removeEventListener('mousemove', this.dragMoveHdlr, false);
311 document.removeEventListener('mouseup', this.dragStopHdlr, false);
363 document.removeEventListener('mouseup', this.dragStopHdlr, false);
312 };
364 };
313
365
314 // Elements definition ------------------------------------
366 // Elements definition ------------------------------------
315
367
316 // strong
368 // strong
317 jsToolBar.prototype.elements.strong = {
369 jsToolBar.prototype.elements.strong = {
318 type: 'button',
370 type: 'button',
319 title: 'Strong emphasis',
371 title: 'Strong emphasis',
320 fn: {
372 fn: {
321 wiki: function() { this.singleTag('*') }
373 wiki: function() { this.singleTag('*') }
322 }
374 }
323 }
375 }
324
376
325 // em
377 // em
326 jsToolBar.prototype.elements.em = {
378 jsToolBar.prototype.elements.em = {
327 type: 'button',
379 type: 'button',
328 title: 'Emphasis',
380 title: 'Emphasis',
329 fn: {
381 fn: {
330 wiki: function() { this.singleTag("_") }
382 wiki: function() { this.singleTag("_") }
331 }
383 }
332 }
384 }
333
385
334 // ins
386 // ins
335 jsToolBar.prototype.elements.ins = {
387 jsToolBar.prototype.elements.ins = {
336 type: 'button',
388 type: 'button',
337 title: 'Inserted',
389 title: 'Inserted',
338 fn: {
390 fn: {
339 wiki: function() { this.singleTag('+') }
391 wiki: function() { this.singleTag('+') }
340 }
392 }
341 }
393 }
342
394
343 // del
395 // del
344 jsToolBar.prototype.elements.del = {
396 jsToolBar.prototype.elements.del = {
345 type: 'button',
397 type: 'button',
346 title: 'Deleted',
398 title: 'Deleted',
347 fn: {
399 fn: {
348 wiki: function() { this.singleTag('-') }
400 wiki: function() { this.singleTag('-') }
349 }
401 }
350 }
402 }
351
403
352 // quote
404 // quote
353 jsToolBar.prototype.elements.quote = {
405 jsToolBar.prototype.elements.quote = {
354 type: 'button',
406 type: 'button',
355 title: 'Inline quote',
407 title: 'Inline quote',
356 fn: {
408 fn: {
357 wiki: function() { this.singleTag('??') }
409 wiki: function() { this.singleTag('??') }
358 }
410 }
359 }
411 }
360
412
361 // code
413 // code
362 jsToolBar.prototype.elements.code = {
414 jsToolBar.prototype.elements.code = {
363 type: 'button',
415 type: 'button',
364 title: 'Code',
416 title: 'Code',
365 fn: {
417 fn: {
366 wiki: function() { this.singleTag('@') }
418 wiki: function() { this.singleTag('@') }
367 }
419 }
368 }
420 }
369
421
370 // spacer
422 // spacer
371 jsToolBar.prototype.elements.space1 = {type: 'space'}
423 jsToolBar.prototype.elements.space1 = {type: 'space'}
372
424
373 // heading
425 // headings
374 jsToolBar.prototype.elements.heading = {
426 jsToolBar.prototype.elements.h1 = {
375 type: 'button',
427 type: 'button',
376 title: 'Heading',
428 title: 'Heading 1',
377 fn: {
429 fn: {
378 wiki: function() {
430 wiki: function() {
379 this.encloseSelection('','',function(str) {
431 this.encloseLineSelection('h1. ', '',function(str) {
380 str = str.replace(/\r/g,'');
432 str = str.replace(/^h\d+\.\s+/, '')
381 return 'h2. '+str.replace(/\n/g,"\n* ");
433 return str;
382 });
434 });
435 }
436 }
437 }
438 jsToolBar.prototype.elements.h2 = {
439 type: 'button',
440 title: 'Heading 2',
441 fn: {
442 wiki: function() {
443 this.encloseLineSelection('h2. ', '',function(str) {
444 str = str.replace(/^h\d+\.\s+/, '')
445 return str;
446 });
447 }
448 }
449 }
450 jsToolBar.prototype.elements.h3 = {
451 type: 'button',
452 title: 'Heading 3',
453 fn: {
454 wiki: function() {
455 this.encloseLineSelection('h3. ', '',function(str) {
456 str = str.replace(/^h\d+\.\s+/, '')
457 return str;
458 });
383 }
459 }
384 }
460 }
385 }
461 }
386
387 // br
388 //jsToolBar.prototype.elements.br = {
389 // type: 'button',
390 // title: 'Line break',
391 // fn: {
392 // wiki: function() { this.encloseSelection("%%%\n",'') }
393 // }
394 //}
395
462
396 // spacer
463 // spacer
397 jsToolBar.prototype.elements.space2 = {type: 'space'}
464 jsToolBar.prototype.elements.space2 = {type: 'space'}
398
465
399 // ul
466 // ul
400 jsToolBar.prototype.elements.ul = {
467 jsToolBar.prototype.elements.ul = {
401 type: 'button',
468 type: 'button',
402 title: 'Unordered list',
469 title: 'Unordered list',
403 fn: {
470 fn: {
404 wiki: function() {
471 wiki: function() {
405 this.encloseSelection('','',function(str) {
472 this.encloseLineSelection('','',function(str) {
406 str = str.replace(/\r/g,'');
473 str = str.replace(/\r/g,'');
407 return '* '+str.replace(/\n/g,"\n* ");
474 return str.replace(/(\n|^)[#-]?\s*/g,"$1* ");
408 });
475 });
409 }
476 }
410 }
477 }
411 }
478 }
412
479
413 // ol
480 // ol
414 jsToolBar.prototype.elements.ol = {
481 jsToolBar.prototype.elements.ol = {
415 type: 'button',
482 type: 'button',
416 title: 'Ordered list',
483 title: 'Ordered list',
417 fn: {
484 fn: {
418 wiki: function() {
485 wiki: function() {
419 this.encloseSelection('','',function(str) {
486 this.encloseLineSelection('','',function(str) {
420 str = str.replace(/\r/g,'');
487 str = str.replace(/\r/g,'');
421 return '# '+str.replace(/\n/g,"\n# ");
488 return str.replace(/(\n|^)[*-]?\s*/g,"$1# ");
422 });
489 });
423 }
490 }
424 }
491 }
425 }
492 }
426
493
494 // pre
495 jsToolBar.prototype.elements.pre = {
496 type: 'button',
497 title: 'Preformatted text',
498 fn: {
499 wiki: function() { this.encloseLineSelection('<pre>\n', '\n</pre>') }
500 }
501 }
502
427 // spacer
503 // spacer
428 jsToolBar.prototype.elements.space3 = {type: 'space'}
504 jsToolBar.prototype.elements.space3 = {type: 'space'}
429
505
430 // link
506 // wiki page
431 /*
432 jsToolBar.prototype.elements.link = {
507 jsToolBar.prototype.elements.link = {
433 type: 'button',
508 type: 'button',
434 title: 'Link',
509 title: 'Wiki Page Link',
435 fn: {},
510 fn: {
436 href_prompt: 'Please give page URL:',
511 wiki: function() { this.encloseSelection("[[", "]]") }
437 hreflang_prompt: 'Language of this page:',
438 default_hreflang: '',
439 prompt: function(href,hreflang) {
440 href = href || '';
441 hreflang = hreflang || this.elements.link.default_hreflang;
442
443 href = window.prompt(this.elements.link.href_prompt,href);
444 if (!href) { return false; }
445
446 hreflang = ""
447
448 return { href: this.stripBaseURL(href), hreflang: hreflang };
449 }
512 }
450 }
513 }
451
514 // image
452 jsToolBar.prototype.elements.link.fn.wiki = function() {
515 jsToolBar.prototype.elements.img = {
453 var link = this.elements.link.prompt.call(this);
454 if (link) {
455 var stag = '"';
456 var etag = '":'+link.href;
457 this.encloseSelection(stag,etag);
458 }
459 };
460 */
461 // link or wiki page
462 jsToolBar.prototype.elements.link = {
463 type: 'button',
516 type: 'button',
464 title: 'Link',
517 title: 'Inline image',
465 fn: {
518 fn: {
466 wiki: function() { this.encloseSelection("[[", "]]") }
519 wiki: function() { this.encloseSelection("!", "!") }
467 }
520 }
468 }
521 }
@@ -1,81 +1,93
1 .jstEditor {
1 .jstEditor {
2 padding-left: 0px;
2 padding-left: 0px;
3 }
3 }
4 .jstEditor textarea, .jstEditor iframe {
4 .jstEditor textarea, .jstEditor iframe {
5 margin: 0;
5 margin: 0;
6 }
6 }
7
7
8 .jstHandle {
8 .jstHandle {
9 height: 10px;
9 height: 10px;
10 font-size: 0.1em;
10 font-size: 0.1em;
11 cursor: s-resize;
11 cursor: s-resize;
12 /*background: transparent url(img/resizer.png) no-repeat 45% 50%;*/
12 /*background: transparent url(img/resizer.png) no-repeat 45% 50%;*/
13 }
13 }
14
14
15 .jstElements {
15 .jstElements {
16 padding: 3px 3px;
16 padding: 3px 3px;
17 }
17 }
18
18
19 .jstElements button {
19 .jstElements button {
20 margin-right : 6px;
20 margin-right : 6px;
21 width : 24px;
21 width : 24px;
22 height: 24px;
22 height: 24px;
23 padding: 4px;
23 padding: 4px;
24 border-style: solid;
24 border-style: solid;
25 border-width: 1px;
25 border-width: 1px;
26 border-color: #ddd;
26 border-color: #ddd;
27 background-color : #f7f7f7;
27 background-color : #f7f7f7;
28 background-position : 50% 50%;
28 background-position : 50% 50%;
29 background-repeat: no-repeat;
29 background-repeat: no-repeat;
30 }
30 }
31 .jstElements button:hover {
31 .jstElements button:hover {
32 border-color : #000;
32 border-color : #000;
33 }
33 }
34 .jstElements button span {
34 .jstElements button span {
35 display : none;
35 display : none;
36 }
36 }
37 .jstElements span {
37 .jstElements span {
38 display : inline;
38 display : inline;
39 }
39 }
40
40
41 .jstSpacer {
41 .jstSpacer {
42 width : 0px;
42 width : 0px;
43 font-size: 1px;
43 font-size: 1px;
44 margin-right: 4px;
44 margin-right: 4px;
45 }
45 }
46
46
47 /* Buttons
47 /* Buttons
48 -------------------------------------------------------- */
48 -------------------------------------------------------- */
49 .jstb_strong {
49 .jstb_strong {
50 background-image: url(../images/jstoolbar/bt_strong.png);
50 background-image: url(../images/jstoolbar/bt_strong.png);
51 }
51 }
52 .jstb_em {
52 .jstb_em {
53 background-image: url(../images/jstoolbar/bt_em.png);
53 background-image: url(../images/jstoolbar/bt_em.png);
54 }
54 }
55 .jstb_ins {
55 .jstb_ins {
56 background-image: url(../images/jstoolbar/bt_ins.png);
56 background-image: url(../images/jstoolbar/bt_ins.png);
57 }
57 }
58 .jstb_del {
58 .jstb_del {
59 background-image: url(../images/jstoolbar/bt_del.png);
59 background-image: url(../images/jstoolbar/bt_del.png);
60 }
60 }
61 .jstb_quote {
61 .jstb_quote {
62 background-image: url(../images/jstoolbar/bt_quote.png);
62 background-image: url(../images/jstoolbar/bt_quote.png);
63 }
63 }
64 .jstb_code {
64 .jstb_code {
65 background-image: url(../images/jstoolbar/bt_code.png);
65 background-image: url(../images/jstoolbar/bt_code.png);
66 }
66 }
67 .jstb_br {
67 .jstb_br {
68 background-image: url(../images/jstoolbar/bt_br.png);
68 background-image: url(../images/jstoolbar/bt_br.png);
69 }
69 }
70 .jstb_heading {
70 .jstb_h1 {
71 background-image: url(../images/jstoolbar/bt_heading.png);
71 background-image: url(../images/jstoolbar/bt_h1.png);
72 }
73 .jstb_h2 {
74 background-image: url(../images/jstoolbar/bt_h2.png);
75 }
76 .jstb_h3 {
77 background-image: url(../images/jstoolbar/bt_h3.png);
72 }
78 }
73 .jstb_ul {
79 .jstb_ul {
74 background-image: url(../images/jstoolbar/bt_ul.png);
80 background-image: url(../images/jstoolbar/bt_ul.png);
75 }
81 }
76 .jstb_ol {
82 .jstb_ol {
77 background-image: url(../images/jstoolbar/bt_ol.png);
83 background-image: url(../images/jstoolbar/bt_ol.png);
78 }
84 }
85 .jstb_pre {
86 background-image: url(../images/jstoolbar/bt_pre.png);
87 }
79 .jstb_link {
88 .jstb_link {
80 background-image: url(../images/jstoolbar/bt_link.png);
89 background-image: url(../images/jstoolbar/bt_link.png);
81 }
90 }
91 .jstb_img {
92 background-image: url(../images/jstoolbar/bt_img.png);
93 }
General Comments 0
You need to be logged in to leave comments. Login now