This diff has been collapsed as it changes many lines, (630 lines changed) Show them Hide them | |||
@@ -23,352 +23,352 | |||
|
23 | 23 | /* Modified by JP LANG for textile formatting */ |
|
24 | 24 | |
|
25 | 25 | function jsToolBar(textarea) { |
|
26 |
|
|
|
27 | ||
|
28 |
|
|
|
29 | ||
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
|
33 | } | |
|
34 | ||
|
35 |
|
|
|
36 | ||
|
37 |
|
|
|
38 |
|
|
|
39 | ||
|
40 |
|
|
|
41 |
|
|
|
42 | ||
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
|
46 | ||
|
47 |
|
|
|
48 |
|
|
|
49 | { | |
|
50 |
|
|
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
|
60 | ||
|
61 |
|
|
|
62 | } | |
|
63 | ||
|
64 |
|
|
|
65 |
|
|
|
66 |
|
|
|
26 | if (!document.createElement) { return; } | |
|
27 | ||
|
28 | if (!textarea) { return; } | |
|
29 | ||
|
30 | if ((typeof(document["selection"]) == "undefined") | |
|
31 | && (typeof(textarea["setSelectionRange"]) == "undefined")) { | |
|
32 | return; | |
|
33 | } | |
|
34 | ||
|
35 | this.textarea = textarea; | |
|
36 | ||
|
37 | this.editor = document.createElement('div'); | |
|
38 | this.editor.className = 'jstEditor'; | |
|
39 | ||
|
40 | this.textarea.parentNode.insertBefore(this.editor,this.textarea); | |
|
41 | this.editor.appendChild(this.textarea); | |
|
42 | ||
|
43 | this.toolbar = document.createElement("div"); | |
|
44 | this.toolbar.className = 'jstElements'; | |
|
45 | this.editor.parentNode.insertBefore(this.toolbar,this.editor); | |
|
46 | ||
|
47 | // Dragable resizing | |
|
48 | if (this.editor.addEventListener && navigator.appVersion.match(/\bMSIE\b/)) | |
|
49 | { | |
|
50 | this.handle = document.createElement('div'); | |
|
51 | this.handle.className = 'jstHandle'; | |
|
52 | var dragStart = this.resizeDragStart; | |
|
53 | var This = this; | |
|
54 | this.handle.addEventListener('mousedown',function(event) { dragStart.call(This,event); },false); | |
|
55 | // fix memory leak in Firefox (bug #241518) | |
|
56 | window.addEventListener('unload',function() { | |
|
57 | var del = This.handle.parentNode.removeChild(This.handle); | |
|
58 | delete(This.handle); | |
|
59 | },false); | |
|
60 | ||
|
61 | this.editor.parentNode.insertBefore(this.handle,this.editor.nextSibling); | |
|
62 | } | |
|
63 | ||
|
64 | this.context = null; | |
|
65 | this.toolNodes = {}; // lorsque la toolbar est dessinΓ©e , cet objet est garni | |
|
66 | // de raccourcis vers les Γ©lΓ©ments DOM correspondants aux outils. | |
|
67 | 67 | } |
|
68 | 68 | |
|
69 | 69 | function jsButton(title, fn, scope, className) { |
|
70 |
|
|
|
71 |
|
|
|
72 |
|
|
|
70 | if(typeof jsToolBar.strings == 'undefined') { | |
|
71 | this.title = title || null; | |
|
72 | } else { | |
|
73 | 73 | this.title = jsToolBar.strings[title] || title || null; |
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
|
74 | } | |
|
75 | this.fn = fn || function(){}; | |
|
76 | this.scope = scope || null; | |
|
77 | this.className = className || null; | |
|
78 | 78 | } |
|
79 | 79 | jsButton.prototype.draw = function() { |
|
80 |
|
|
|
81 | ||
|
82 |
|
|
|
83 |
|
|
|
84 |
|
|
|
85 |
|
|
|
86 |
|
|
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
|
90 | ||
|
91 |
|
|
|
92 |
|
|
|
93 | } | |
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
|
97 | } | |
|
98 |
|
|
|
80 | if (!this.scope) return null; | |
|
81 | ||
|
82 | var button = document.createElement('button'); | |
|
83 | button.setAttribute('type','button'); | |
|
84 | button.tabIndex = 200; | |
|
85 | if (this.className) button.className = this.className; | |
|
86 | button.title = this.title; | |
|
87 | var span = document.createElement('span'); | |
|
88 | span.appendChild(document.createTextNode(this.title)); | |
|
89 | button.appendChild(span); | |
|
90 | ||
|
91 | if (this.icon != undefined) { | |
|
92 | button.style.backgroundImage = 'url('+this.icon+')'; | |
|
93 | } | |
|
94 | if (typeof(this.fn) == 'function') { | |
|
95 | var This = this; | |
|
96 | button.onclick = function() { try { This.fn.apply(This.scope, arguments) } catch (e) {} return false; }; | |
|
97 | } | |
|
98 | return button; | |
|
99 | 99 | } |
|
100 | 100 | |
|
101 | 101 | function jsSpace(id) { |
|
102 |
|
|
|
103 |
|
|
|
102 | this.id = id || null; | |
|
103 | this.width = null; | |
|
104 | 104 | } |
|
105 | 105 | jsSpace.prototype.draw = function() { |
|
106 |
|
|
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
|
110 |
|
|
|
111 | ||
|
112 |
|
|
|
106 | var span = document.createElement('span'); | |
|
107 | if (this.id) span.id = this.id; | |
|
108 | span.appendChild(document.createTextNode(String.fromCharCode(160))); | |
|
109 | span.className = 'jstSpacer'; | |
|
110 | if (this.width) span.style.marginRight = this.width+'px'; | |
|
111 | ||
|
112 | return span; | |
|
113 | 113 | } |
|
114 | 114 | |
|
115 | 115 | function jsCombo(title, options, scope, fn, className) { |
|
116 |
|
|
|
117 |
|
|
|
118 |
|
|
|
119 |
|
|
|
120 |
|
|
|
116 | this.title = title || null; | |
|
117 | this.options = options || null; | |
|
118 | this.scope = scope || null; | |
|
119 | this.fn = fn || function(){}; | |
|
120 | this.className = className || null; | |
|
121 | 121 | } |
|
122 | 122 | jsCombo.prototype.draw = function() { |
|
123 |
|
|
|
124 | ||
|
125 |
|
|
|
126 |
|
|
|
127 |
|
|
|
128 | ||
|
129 |
|
|
|
130 |
|
|
|
131 |
|
|
|
132 |
|
|
|
133 |
|
|
|
134 |
|
|
|
135 | } | |
|
136 | ||
|
137 |
|
|
|
138 |
|
|
|
139 |
|
|
|
140 |
|
|
|
141 |
|
|
|
142 | ||
|
143 |
|
|
|
144 | } | |
|
145 | ||
|
146 |
|
|
|
123 | if (!this.scope || !this.options) return null; | |
|
124 | ||
|
125 | var select = document.createElement('select'); | |
|
126 | if (this.className) select.className = className; | |
|
127 | select.title = this.title; | |
|
128 | ||
|
129 | for (var o in this.options) { | |
|
130 | //var opt = this.options[o]; | |
|
131 | var option = document.createElement('option'); | |
|
132 | option.value = o; | |
|
133 | option.appendChild(document.createTextNode(this.options[o])); | |
|
134 | select.appendChild(option); | |
|
135 | } | |
|
136 | ||
|
137 | var This = this; | |
|
138 | select.onchange = function() { | |
|
139 | try { | |
|
140 | This.fn.call(This.scope, this.value); | |
|
141 | } catch (e) { alert(e); } | |
|
142 | ||
|
143 | return false; | |
|
144 | } | |
|
145 | ||
|
146 | return select; | |
|
147 | 147 | } |
|
148 | 148 | |
|
149 | 149 | |
|
150 | 150 | jsToolBar.prototype = { |
|
151 |
|
|
|
152 |
|
|
|
153 |
|
|
|
154 |
|
|
|
155 | ||
|
156 |
|
|
|
157 |
|
|
|
158 | }, | |
|
159 | ||
|
160 |
|
|
|
161 |
|
|
|
162 | }, | |
|
163 | ||
|
164 |
|
|
|
165 |
|
|
|
166 |
|
|
|
167 | }, | |
|
168 | ||
|
169 |
|
|
|
170 |
|
|
|
171 | }, | |
|
172 | ||
|
173 |
|
|
|
174 |
|
|
|
175 |
|
|
|
176 |
|
|
|
177 |
|
|
|
178 |
|
|
|
179 | }, | |
|
180 |
|
|
|
181 |
|
|
|
182 |
|
|
|
183 |
|
|
|
184 |
|
|
|
185 | }, | |
|
186 |
|
|
|
187 |
|
|
|
188 |
|
|
|
189 | ||
|
190 |
|
|
|
191 |
|
|
|
192 |
|
|
|
193 |
|
|
|
194 |
|
|
|
195 |
|
|
|
196 |
|
|
|
197 | } | |
|
198 |
|
|
|
199 | } | |
|
200 | }, | |
|
201 |
|
|
|
202 |
|
|
|
203 | ||
|
204 |
|
|
|
205 |
|
|
|
206 |
|
|
|
207 | } | |
|
208 |
|
|
|
209 | ||
|
210 |
|
|
|
211 |
|
|
|
212 | ||
|
213 |
|
|
|
214 |
|
|
|
215 | ||
|
216 |
|
|
|
217 |
|
|
|
218 |
|
|
|
219 |
|
|
|
220 | ||
|
221 |
|
|
|
222 |
|
|
|
223 |
|
|
|
224 |
|
|
|
225 |
|
|
|
226 |
|
|
|
227 | } | |
|
228 | } | |
|
229 | } | |
|
230 | }, | |
|
231 | ||
|
232 |
|
|
|
233 |
|
|
|
234 |
|
|
|
235 | ||
|
236 |
|
|
|
237 | ||
|
238 |
|
|
|
239 | }, | |
|
240 | ||
|
241 |
|
|
|
242 |
|
|
|
243 | ||
|
244 |
|
|
|
245 |
|
|
|
246 | ||
|
247 |
|
|
|
248 | ||
|
249 |
|
|
|
250 |
|
|
|
251 |
|
|
|
252 |
|
|
|
253 |
|
|
|
254 |
|
|
|
255 |
|
|
|
256 |
|
|
|
257 |
|
|
|
258 |
|
|
|
259 |
|
|
|
260 | } | |
|
261 | ||
|
262 |
|
|
|
263 |
|
|
|
264 |
|
|
|
265 | } | |
|
266 | ||
|
267 |
|
|
|
268 |
|
|
|
269 |
|
|
|
270 |
|
|
|
271 | } | |
|
272 | ||
|
273 |
|
|
|
274 | ||
|
275 |
|
|
|
276 |
|
|
|
277 |
|
|
|
278 |
|
|
|
279 |
|
|
|
280 |
|
|
|
281 |
|
|
|
282 |
|
|
|
283 |
|
|
|
284 |
|
|
|
285 |
|
|
|
286 |
|
|
|
287 |
|
|
|
288 | } | |
|
289 |
|
|
|
290 | } | |
|
291 | }, | |
|
292 | ||
|
293 |
|
|
|
294 |
|
|
|
295 | ||
|
296 |
|
|
|
297 |
|
|
|
298 | ||
|
299 |
|
|
|
300 | ||
|
301 |
|
|
|
302 |
|
|
|
303 |
|
|
|
304 |
|
|
|
305 |
|
|
|
306 |
|
|
|
307 |
|
|
|
308 | } | |
|
309 | ||
|
310 |
|
|
|
311 |
|
|
|
312 |
|
|
|
313 | } | |
|
314 | ||
|
315 |
|
|
|
316 |
|
|
|
317 |
|
|
|
318 |
|
|
|
319 | } | |
|
320 | ||
|
321 |
|
|
|
322 | ||
|
323 |
|
|
|
324 |
|
|
|
325 |
|
|
|
326 |
|
|
|
327 |
|
|
|
328 |
|
|
|
329 |
// |
|
|
330 |
|
|
|
331 |
|
|
|
332 |
|
|
|
333 |
|
|
|
334 |
|
|
|
335 |
|
|
|
336 |
|
|
|
337 | } | |
|
338 |
|
|
|
339 | } | |
|
340 | }, | |
|
341 | ||
|
342 |
|
|
|
343 |
|
|
|
344 |
|
|
|
345 |
|
|
|
346 |
|
|
|
347 | } | |
|
348 | } | |
|
349 | ||
|
350 |
|
|
|
351 | } | |
|
151 | base_url: '', | |
|
152 | mode: 'wiki', | |
|
153 | elements: {}, | |
|
154 | help_link: '', | |
|
155 | ||
|
156 | getMode: function() { | |
|
157 | return this.mode; | |
|
158 | }, | |
|
159 | ||
|
160 | setMode: function(mode) { | |
|
161 | this.mode = mode || 'wiki'; | |
|
162 | }, | |
|
163 | ||
|
164 | switchMode: function(mode) { | |
|
165 | mode = mode || 'wiki'; | |
|
166 | this.draw(mode); | |
|
167 | }, | |
|
168 | ||
|
169 | setHelpLink: function(link) { | |
|
170 | this.help_link = link; | |
|
171 | }, | |
|
172 | ||
|
173 | button: function(toolName) { | |
|
174 | var tool = this.elements[toolName]; | |
|
175 | if (typeof tool.fn[this.mode] != 'function') return null; | |
|
176 | var b = new jsButton(tool.title, tool.fn[this.mode], this, 'jstb_'+toolName); | |
|
177 | if (tool.icon != undefined) b.icon = tool.icon; | |
|
178 | return b; | |
|
179 | }, | |
|
180 | space: function(toolName) { | |
|
181 | var tool = new jsSpace(toolName) | |
|
182 | if (this.elements[toolName].width !== undefined) | |
|
183 | tool.width = this.elements[toolName].width; | |
|
184 | return tool; | |
|
185 | }, | |
|
186 | combo: function(toolName) { | |
|
187 | var tool = this.elements[toolName]; | |
|
188 | var length = tool[this.mode].list.length; | |
|
189 | ||
|
190 | if (typeof tool[this.mode].fn != 'function' || length == 0) { | |
|
191 | return null; | |
|
192 | } else { | |
|
193 | var options = {}; | |
|
194 | for (var i=0; i < length; i++) { | |
|
195 | var opt = tool[this.mode].list[i]; | |
|
196 | options[opt] = tool.options[opt]; | |
|
197 | } | |
|
198 | return new jsCombo(tool.title, options, this, tool[this.mode].fn); | |
|
199 | } | |
|
200 | }, | |
|
201 | draw: function(mode) { | |
|
202 | this.setMode(mode); | |
|
203 | ||
|
204 | // Empty toolbar | |
|
205 | while (this.toolbar.hasChildNodes()) { | |
|
206 | this.toolbar.removeChild(this.toolbar.firstChild) | |
|
207 | } | |
|
208 | this.toolNodes = {}; // vide les raccourcis DOM/**/ | |
|
209 | ||
|
210 | // Draw toolbar elements | |
|
211 | var b, tool, newTool; | |
|
212 | ||
|
213 | for (var i in this.elements) { | |
|
214 | b = this.elements[i]; | |
|
215 | ||
|
216 | var disabled = | |
|
217 | b.type == undefined || b.type == '' | |
|
218 | || (b.disabled != undefined && b.disabled) | |
|
219 | || (b.context != undefined && b.context != null && b.context != this.context); | |
|
220 | ||
|
221 | if (!disabled && typeof this[b.type] == 'function') { | |
|
222 | tool = this[b.type](i); | |
|
223 | if (tool) newTool = tool.draw(); | |
|
224 | if (newTool) { | |
|
225 | this.toolNodes[i] = newTool; //mémorise l'accès DOM pour usage éventuel ultérieur | |
|
226 | this.toolbar.appendChild(newTool); | |
|
227 | } | |
|
228 | } | |
|
229 | } | |
|
230 | }, | |
|
231 | ||
|
232 | singleTag: function(stag,etag) { | |
|
233 | stag = stag || null; | |
|
234 | etag = etag || stag; | |
|
235 | ||
|
236 | if (!stag || !etag) { return; } | |
|
237 | ||
|
238 | this.encloseSelection(stag,etag); | |
|
239 | }, | |
|
240 | ||
|
241 | encloseLineSelection: function(prefix, suffix, fn) { | |
|
242 | this.textarea.focus(); | |
|
243 | ||
|
244 | prefix = prefix || ''; | |
|
245 | suffix = suffix || ''; | |
|
246 | ||
|
247 | var start, end, sel, scrollPos, subst, res; | |
|
248 | ||
|
249 | if (typeof(document["selection"]) != "undefined") { | |
|
250 | sel = document.selection.createRange().text; | |
|
251 | } else if (typeof(this.textarea["setSelectionRange"]) != "undefined") { | |
|
252 | start = this.textarea.selectionStart; | |
|
253 | end = this.textarea.selectionEnd; | |
|
254 | scrollPos = this.textarea.scrollTop; | |
|
255 | // go to the start of the line | |
|
256 | start = this.textarea.value.substring(0, start).replace(/[^\r\n]*$/g,'').length; | |
|
257 | // go to the end of the line | |
|
258 | end = this.textarea.value.length - this.textarea.value.substring(end, this.textarea.value.length).replace(/^[^\r\n]*/, '').length; | |
|
259 | sel = this.textarea.value.substring(start, end); | |
|
260 | } | |
|
261 | ||
|
262 | if (sel.match(/ $/)) { // exclude ending space char, if any | |
|
263 | sel = sel.substring(0, sel.length - 1); | |
|
264 | suffix = suffix + " "; | |
|
265 | } | |
|
266 | ||
|
267 | if (typeof(fn) == 'function') { | |
|
268 | res = (sel) ? fn.call(this,sel) : fn(''); | |
|
269 | } else { | |
|
270 | res = (sel) ? sel : ''; | |
|
271 | } | |
|
272 | ||
|
273 | subst = prefix + res + suffix; | |
|
274 | ||
|
275 | if (typeof(document["selection"]) != "undefined") { | |
|
276 | document.selection.createRange().text = subst; | |
|
277 | var range = this.textarea.createTextRange(); | |
|
278 | range.collapse(false); | |
|
279 | range.move('character', -suffix.length); | |
|
280 | range.select(); | |
|
281 | } else if (typeof(this.textarea["setSelectionRange"]) != "undefined") { | |
|
282 | this.textarea.value = this.textarea.value.substring(0, start) + subst + | |
|
283 | this.textarea.value.substring(end); | |
|
284 | if (sel) { | |
|
285 | this.textarea.setSelectionRange(start + subst.length, start + subst.length); | |
|
286 | } else { | |
|
287 | this.textarea.setSelectionRange(start + prefix.length, start + prefix.length); | |
|
288 | } | |
|
289 | this.textarea.scrollTop = scrollPos; | |
|
290 | } | |
|
291 | }, | |
|
292 | ||
|
293 | encloseSelection: function(prefix, suffix, fn) { | |
|
294 | this.textarea.focus(); | |
|
295 | ||
|
296 | prefix = prefix || ''; | |
|
297 | suffix = suffix || ''; | |
|
298 | ||
|
299 | var start, end, sel, scrollPos, subst, res; | |
|
300 | ||
|
301 | if (typeof(document["selection"]) != "undefined") { | |
|
302 | sel = document.selection.createRange().text; | |
|
303 | } else if (typeof(this.textarea["setSelectionRange"]) != "undefined") { | |
|
304 | start = this.textarea.selectionStart; | |
|
305 | end = this.textarea.selectionEnd; | |
|
306 | scrollPos = this.textarea.scrollTop; | |
|
307 | sel = this.textarea.value.substring(start, end); | |
|
308 | } | |
|
309 | ||
|
310 | if (sel.match(/ $/)) { // exclude ending space char, if any | |
|
311 | sel = sel.substring(0, sel.length - 1); | |
|
312 | suffix = suffix + " "; | |
|
313 | } | |
|
314 | ||
|
315 | if (typeof(fn) == 'function') { | |
|
316 | res = (sel) ? fn.call(this,sel) : fn(''); | |
|
317 | } else { | |
|
318 | res = (sel) ? sel : ''; | |
|
319 | } | |
|
320 | ||
|
321 | subst = prefix + res + suffix; | |
|
322 | ||
|
323 | if (typeof(document["selection"]) != "undefined") { | |
|
324 | document.selection.createRange().text = subst; | |
|
325 | var range = this.textarea.createTextRange(); | |
|
326 | range.collapse(false); | |
|
327 | range.move('character', -suffix.length); | |
|
328 | range.select(); | |
|
329 | // this.textarea.caretPos -= suffix.length; | |
|
330 | } else if (typeof(this.textarea["setSelectionRange"]) != "undefined") { | |
|
331 | this.textarea.value = this.textarea.value.substring(0, start) + subst + | |
|
332 | this.textarea.value.substring(end); | |
|
333 | if (sel) { | |
|
334 | this.textarea.setSelectionRange(start + subst.length, start + subst.length); | |
|
335 | } else { | |
|
336 | this.textarea.setSelectionRange(start + prefix.length, start + prefix.length); | |
|
337 | } | |
|
338 | this.textarea.scrollTop = scrollPos; | |
|
339 | } | |
|
340 | }, | |
|
341 | ||
|
342 | stripBaseURL: function(url) { | |
|
343 | if (this.base_url != '') { | |
|
344 | var pos = url.indexOf(this.base_url); | |
|
345 | if (pos == 0) { | |
|
346 | url = url.substr(this.base_url.length); | |
|
347 | } | |
|
348 | } | |
|
349 | ||
|
350 | return url; | |
|
351 | } | |
|
352 | 352 | }; |
|
353 | 353 | |
|
354 | 354 | /** Resizer |
|
355 | 355 | -------------------------------------------------------- */ |
|
356 | 356 | jsToolBar.prototype.resizeSetStartH = function() { |
|
357 |
|
|
|
357 | this.dragStartH = this.textarea.offsetHeight + 0; | |
|
358 | 358 | }; |
|
359 | 359 | jsToolBar.prototype.resizeDragStart = function(event) { |
|
360 |
|
|
|
361 |
|
|
|
362 |
|
|
|
363 |
|
|
|
364 |
|
|
|
360 | var This = this; | |
|
361 | this.dragStartY = event.clientY; | |
|
362 | this.resizeSetStartH(); | |
|
363 | document.addEventListener('mousemove', this.dragMoveHdlr=function(event){This.resizeDragMove(event);}, false); | |
|
364 | document.addEventListener('mouseup', this.dragStopHdlr=function(event){This.resizeDragStop(event);}, false); | |
|
365 | 365 | }; |
|
366 | 366 | |
|
367 | 367 | jsToolBar.prototype.resizeDragMove = function(event) { |
|
368 |
|
|
|
368 | this.textarea.style.height = (this.dragStartH+event.clientY-this.dragStartY)+'px'; | |
|
369 | 369 | }; |
|
370 | 370 | |
|
371 | 371 | jsToolBar.prototype.resizeDragStop = function(event) { |
|
372 |
|
|
|
373 |
|
|
|
372 | document.removeEventListener('mousemove', this.dragMoveHdlr, false); | |
|
373 | document.removeEventListener('mouseup', this.dragStopHdlr, false); | |
|
374 | 374 | }; |
@@ -24,38 +24,38 | |||
|
24 | 24 | |
|
25 | 25 | // strong |
|
26 | 26 | jsToolBar.prototype.elements.strong = { |
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
|
31 | } | |
|
27 | type: 'button', | |
|
28 | title: 'Strong', | |
|
29 | fn: { | |
|
30 | wiki: function() { this.singleTag('**') } | |
|
31 | } | |
|
32 | 32 | } |
|
33 | 33 | |
|
34 | 34 | // em |
|
35 | 35 | jsToolBar.prototype.elements.em = { |
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
|
40 | } | |
|
36 | type: 'button', | |
|
37 | title: 'Italic', | |
|
38 | fn: { | |
|
39 | wiki: function() { this.singleTag("*") } | |
|
40 | } | |
|
41 | 41 | } |
|
42 | 42 | |
|
43 | 43 | // del |
|
44 | 44 | jsToolBar.prototype.elements.del = { |
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
|
49 | } | |
|
45 | type: 'button', | |
|
46 | title: 'Deleted', | |
|
47 | fn: { | |
|
48 | wiki: function() { this.singleTag('~~') } | |
|
49 | } | |
|
50 | 50 | } |
|
51 | 51 | |
|
52 | 52 | // code |
|
53 | 53 | jsToolBar.prototype.elements.code = { |
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
|
58 | } | |
|
54 | type: 'button', | |
|
55 | title: 'Code', | |
|
56 | fn: { | |
|
57 | wiki: function() { this.singleTag('`') } | |
|
58 | } | |
|
59 | 59 | } |
|
60 | 60 | |
|
61 | 61 | // spacer |
@@ -63,40 +63,40 jsToolBar.prototype.elements.space1 = {type: 'space'} | |||
|
63 | 63 | |
|
64 | 64 | // headings |
|
65 | 65 | jsToolBar.prototype.elements.h1 = { |
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
|
69 |
|
|
|
70 |
|
|
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
|
74 | } | |
|
75 | } | |
|
66 | type: 'button', | |
|
67 | title: 'Heading 1', | |
|
68 | fn: { | |
|
69 | wiki: function() { | |
|
70 | this.encloseLineSelection('# ', '',function(str) { | |
|
71 | str = str.replace(/^#+\s+/, '') | |
|
72 | return str; | |
|
73 | }); | |
|
74 | } | |
|
75 | } | |
|
76 | 76 | } |
|
77 | 77 | jsToolBar.prototype.elements.h2 = { |
|
78 |
|
|
|
79 |
|
|
|
80 |
|
|
|
81 |
|
|
|
82 |
|
|
|
83 |
|
|
|
84 |
|
|
|
85 |
|
|
|
86 | } | |
|
87 | } | |
|
78 | type: 'button', | |
|
79 | title: 'Heading 2', | |
|
80 | fn: { | |
|
81 | wiki: function() { | |
|
82 | this.encloseLineSelection('## ', '',function(str) { | |
|
83 | str = str.replace(/^#+\s+/, '') | |
|
84 | return str; | |
|
85 | }); | |
|
86 | } | |
|
87 | } | |
|
88 | 88 | } |
|
89 | 89 | jsToolBar.prototype.elements.h3 = { |
|
90 |
|
|
|
91 |
|
|
|
92 |
|
|
|
93 |
|
|
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
|
97 |
|
|
|
98 | } | |
|
99 | } | |
|
90 | type: 'button', | |
|
91 | title: 'Heading 3', | |
|
92 | fn: { | |
|
93 | wiki: function() { | |
|
94 | this.encloseLineSelection('### ', '',function(str) { | |
|
95 | str = str.replace(/^#+\s+/, '') | |
|
96 | return str; | |
|
97 | }); | |
|
98 | } | |
|
99 | } | |
|
100 | 100 | } |
|
101 | 101 | |
|
102 | 102 | // spacer |
@@ -104,30 +104,30 jsToolBar.prototype.elements.space2 = {type: 'space'} | |||
|
104 | 104 | |
|
105 | 105 | // ul |
|
106 | 106 | jsToolBar.prototype.elements.ul = { |
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
|
114 | }); | |
|
115 | } | |
|
116 | } | |
|
107 | type: 'button', | |
|
108 | title: 'Unordered list', | |
|
109 | fn: { | |
|
110 | wiki: function() { | |
|
111 | this.encloseLineSelection('','',function(str) { | |
|
112 | str = str.replace(/\r/g,''); | |
|
113 | return str.replace(/(\n|^)[#-]?\s*/g,"$1* "); | |
|
114 | }); | |
|
115 | } | |
|
116 | } | |
|
117 | 117 | } |
|
118 | 118 | |
|
119 | 119 | // ol |
|
120 | 120 | jsToolBar.prototype.elements.ol = { |
|
121 |
|
|
|
122 |
|
|
|
123 |
|
|
|
124 |
|
|
|
125 |
|
|
|
126 |
|
|
|
127 |
|
|
|
128 | }); | |
|
129 | } | |
|
130 | } | |
|
121 | type: 'button', | |
|
122 | title: 'Ordered list', | |
|
123 | fn: { | |
|
124 | wiki: function() { | |
|
125 | this.encloseLineSelection('','',function(str) { | |
|
126 | str = str.replace(/\r/g,''); | |
|
127 | return str.replace(/(\n|^)[*-]?\s*/g,"$11. "); | |
|
128 | }); | |
|
129 | } | |
|
130 | } | |
|
131 | 131 | } |
|
132 | 132 | |
|
133 | 133 | // spacer |
@@ -135,39 +135,39 jsToolBar.prototype.elements.space3 = {type: 'space'} | |||
|
135 | 135 | |
|
136 | 136 | // bq |
|
137 | 137 | jsToolBar.prototype.elements.bq = { |
|
138 |
|
|
|
139 |
|
|
|
140 |
|
|
|
141 |
|
|
|
142 |
|
|
|
143 |
|
|
|
144 |
|
|
|
145 | }); | |
|
146 | } | |
|
147 | } | |
|
138 | type: 'button', | |
|
139 | title: 'Quote', | |
|
140 | fn: { | |
|
141 | wiki: function() { | |
|
142 | this.encloseLineSelection('','',function(str) { | |
|
143 | str = str.replace(/\r/g,''); | |
|
144 | return str.replace(/(\n|^) *([^\n]*)/g,"$1> $2"); | |
|
145 | }); | |
|
146 | } | |
|
147 | } | |
|
148 | 148 | } |
|
149 | 149 | |
|
150 | 150 | // unbq |
|
151 | 151 | jsToolBar.prototype.elements.unbq = { |
|
152 |
|
|
|
153 |
|
|
|
154 |
|
|
|
155 |
|
|
|
156 |
|
|
|
157 |
|
|
|
158 |
|
|
|
159 | }); | |
|
160 | } | |
|
161 | } | |
|
152 | type: 'button', | |
|
153 | title: 'Unquote', | |
|
154 | fn: { | |
|
155 | wiki: function() { | |
|
156 | this.encloseLineSelection('','',function(str) { | |
|
157 | str = str.replace(/\r/g,''); | |
|
158 | return str.replace(/(\n|^) *[>]? *([^\n]*)/g,"$1$2"); | |
|
159 | }); | |
|
160 | } | |
|
161 | } | |
|
162 | 162 | } |
|
163 | 163 | |
|
164 | 164 | // pre |
|
165 | 165 | jsToolBar.prototype.elements.pre = { |
|
166 |
|
|
|
167 |
|
|
|
168 |
|
|
|
169 |
|
|
|
170 | } | |
|
166 | type: 'button', | |
|
167 | title: 'Preformatted text', | |
|
168 | fn: { | |
|
169 | wiki: function() { this.encloseLineSelection('~~~\n', '\n~~~') } | |
|
170 | } | |
|
171 | 171 | } |
|
172 | 172 | |
|
173 | 173 | // spacer |
@@ -175,28 +175,28 jsToolBar.prototype.elements.space4 = {type: 'space'} | |||
|
175 | 175 | |
|
176 | 176 | // wiki page |
|
177 | 177 | jsToolBar.prototype.elements.link = { |
|
178 |
|
|
|
179 |
|
|
|
180 |
|
|
|
181 |
|
|
|
182 | } | |
|
178 | type: 'button', | |
|
179 | title: 'Wiki link', | |
|
180 | fn: { | |
|
181 | wiki: function() { this.encloseSelection("[[", "]]") } | |
|
182 | } | |
|
183 | 183 | } |
|
184 | 184 | // image |
|
185 | 185 | jsToolBar.prototype.elements.img = { |
|
186 |
|
|
|
187 |
|
|
|
188 |
|
|
|
189 |
|
|
|
190 | } | |
|
186 | type: 'button', | |
|
187 | title: 'Image', | |
|
188 | fn: { | |
|
189 | wiki: function() { this.encloseSelection("") } | |
|
190 | } | |
|
191 | 191 | } |
|
192 | 192 | |
|
193 | 193 | // spacer |
|
194 | 194 | jsToolBar.prototype.elements.space5 = {type: 'space'} |
|
195 | 195 | // help |
|
196 | 196 | jsToolBar.prototype.elements.help = { |
|
197 |
|
|
|
198 |
|
|
|
199 |
|
|
|
200 |
|
|
|
201 | } | |
|
197 | type: 'button', | |
|
198 | title: 'Help', | |
|
199 | fn: { | |
|
200 | wiki: function() { window.open(this.help_link, '', 'resizable=yes, location=no, width=300, height=640, menubar=no, status=no, scrollbars=yes') } | |
|
201 | } | |
|
202 | 202 | } |
@@ -24,47 +24,47 | |||
|
24 | 24 | |
|
25 | 25 | // strong |
|
26 | 26 | jsToolBar.prototype.elements.strong = { |
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
|
31 | } | |
|
27 | type: 'button', | |
|
28 | title: 'Strong', | |
|
29 | fn: { | |
|
30 | wiki: function() { this.singleTag('*') } | |
|
31 | } | |
|
32 | 32 | } |
|
33 | 33 | |
|
34 | 34 | // em |
|
35 | 35 | jsToolBar.prototype.elements.em = { |
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
|
40 | } | |
|
36 | type: 'button', | |
|
37 | title: 'Italic', | |
|
38 | fn: { | |
|
39 | wiki: function() { this.singleTag("_") } | |
|
40 | } | |
|
41 | 41 | } |
|
42 | 42 | |
|
43 | 43 | // ins |
|
44 | 44 | jsToolBar.prototype.elements.ins = { |
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
|
49 | } | |
|
45 | type: 'button', | |
|
46 | title: 'Underline', | |
|
47 | fn: { | |
|
48 | wiki: function() { this.singleTag('+') } | |
|
49 | } | |
|
50 | 50 | } |
|
51 | 51 | |
|
52 | 52 | // del |
|
53 | 53 | jsToolBar.prototype.elements.del = { |
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
|
58 | } | |
|
54 | type: 'button', | |
|
55 | title: 'Deleted', | |
|
56 | fn: { | |
|
57 | wiki: function() { this.singleTag('-') } | |
|
58 | } | |
|
59 | 59 | } |
|
60 | 60 | |
|
61 | 61 | // code |
|
62 | 62 | jsToolBar.prototype.elements.code = { |
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
|
66 |
|
|
|
67 | } | |
|
63 | type: 'button', | |
|
64 | title: 'Code', | |
|
65 | fn: { | |
|
66 | wiki: function() { this.singleTag('@') } | |
|
67 | } | |
|
68 | 68 | } |
|
69 | 69 | |
|
70 | 70 | // spacer |
@@ -72,40 +72,40 jsToolBar.prototype.elements.space1 = {type: 'space'} | |||
|
72 | 72 | |
|
73 | 73 | // headings |
|
74 | 74 | jsToolBar.prototype.elements.h1 = { |
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
|
80 |
|
|
|
81 |
|
|
|
82 |
|
|
|
83 | } | |
|
84 | } | |
|
75 | type: 'button', | |
|
76 | title: 'Heading 1', | |
|
77 | fn: { | |
|
78 | wiki: function() { | |
|
79 | this.encloseLineSelection('h1. ', '',function(str) { | |
|
80 | str = str.replace(/^h\d+\.\s+/, '') | |
|
81 | return str; | |
|
82 | }); | |
|
83 | } | |
|
84 | } | |
|
85 | 85 | } |
|
86 | 86 | jsToolBar.prototype.elements.h2 = { |
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
|
90 |
|
|
|
91 |
|
|
|
92 |
|
|
|
93 |
|
|
|
94 |
|
|
|
95 | } | |
|
96 | } | |
|
87 | type: 'button', | |
|
88 | title: 'Heading 2', | |
|
89 | fn: { | |
|
90 | wiki: function() { | |
|
91 | this.encloseLineSelection('h2. ', '',function(str) { | |
|
92 | str = str.replace(/^h\d+\.\s+/, '') | |
|
93 | return str; | |
|
94 | }); | |
|
95 | } | |
|
96 | } | |
|
97 | 97 | } |
|
98 | 98 | jsToolBar.prototype.elements.h3 = { |
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
|
105 |
|
|
|
106 |
|
|
|
107 | } | |
|
108 | } | |
|
99 | type: 'button', | |
|
100 | title: 'Heading 3', | |
|
101 | fn: { | |
|
102 | wiki: function() { | |
|
103 | this.encloseLineSelection('h3. ', '',function(str) { | |
|
104 | str = str.replace(/^h\d+\.\s+/, '') | |
|
105 | return str; | |
|
106 | }); | |
|
107 | } | |
|
108 | } | |
|
109 | 109 | } |
|
110 | 110 | |
|
111 | 111 | // spacer |
@@ -113,30 +113,30 jsToolBar.prototype.elements.space2 = {type: 'space'} | |||
|
113 | 113 | |
|
114 | 114 | // ul |
|
115 | 115 | jsToolBar.prototype.elements.ul = { |
|
116 |
|
|
|
117 |
|
|
|
118 |
|
|
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
|
122 |
|
|
|
123 | }); | |
|
124 | } | |
|
125 | } | |
|
116 | type: 'button', | |
|
117 | title: 'Unordered list', | |
|
118 | fn: { | |
|
119 | wiki: function() { | |
|
120 | this.encloseLineSelection('','',function(str) { | |
|
121 | str = str.replace(/\r/g,''); | |
|
122 | return str.replace(/(\n|^)[#-]?\s*/g,"$1* "); | |
|
123 | }); | |
|
124 | } | |
|
125 | } | |
|
126 | 126 | } |
|
127 | 127 | |
|
128 | 128 | // ol |
|
129 | 129 | jsToolBar.prototype.elements.ol = { |
|
130 |
|
|
|
131 |
|
|
|
132 |
|
|
|
133 |
|
|
|
134 |
|
|
|
135 |
|
|
|
136 |
|
|
|
137 | }); | |
|
138 | } | |
|
139 | } | |
|
130 | type: 'button', | |
|
131 | title: 'Ordered list', | |
|
132 | fn: { | |
|
133 | wiki: function() { | |
|
134 | this.encloseLineSelection('','',function(str) { | |
|
135 | str = str.replace(/\r/g,''); | |
|
136 | return str.replace(/(\n|^)[*-]?\s*/g,"$1# "); | |
|
137 | }); | |
|
138 | } | |
|
139 | } | |
|
140 | 140 | } |
|
141 | 141 | |
|
142 | 142 | // spacer |
@@ -144,39 +144,39 jsToolBar.prototype.elements.space3 = {type: 'space'} | |||
|
144 | 144 | |
|
145 | 145 | // bq |
|
146 | 146 | jsToolBar.prototype.elements.bq = { |
|
147 |
|
|
|
148 |
|
|
|
149 |
|
|
|
150 |
|
|
|
151 |
|
|
|
152 |
|
|
|
153 |
|
|
|
154 | }); | |
|
155 | } | |
|
156 | } | |
|
147 | type: 'button', | |
|
148 | title: 'Quote', | |
|
149 | fn: { | |
|
150 | wiki: function() { | |
|
151 | this.encloseLineSelection('','',function(str) { | |
|
152 | str = str.replace(/\r/g,''); | |
|
153 | return str.replace(/(\n|^) *([^\n]*)/g,"$1> $2"); | |
|
154 | }); | |
|
155 | } | |
|
156 | } | |
|
157 | 157 | } |
|
158 | 158 | |
|
159 | 159 | // unbq |
|
160 | 160 | jsToolBar.prototype.elements.unbq = { |
|
161 |
|
|
|
162 |
|
|
|
163 |
|
|
|
164 |
|
|
|
165 |
|
|
|
166 |
|
|
|
167 |
|
|
|
168 | }); | |
|
169 | } | |
|
170 | } | |
|
161 | type: 'button', | |
|
162 | title: 'Unquote', | |
|
163 | fn: { | |
|
164 | wiki: function() { | |
|
165 | this.encloseLineSelection('','',function(str) { | |
|
166 | str = str.replace(/\r/g,''); | |
|
167 | return str.replace(/(\n|^) *[>]? *([^\n]*)/g,"$1$2"); | |
|
168 | }); | |
|
169 | } | |
|
170 | } | |
|
171 | 171 | } |
|
172 | 172 | |
|
173 | 173 | // pre |
|
174 | 174 | jsToolBar.prototype.elements.pre = { |
|
175 |
|
|
|
176 |
|
|
|
177 |
|
|
|
178 |
|
|
|
179 | } | |
|
175 | type: 'button', | |
|
176 | title: 'Preformatted text', | |
|
177 | fn: { | |
|
178 | wiki: function() { this.encloseLineSelection('<pre>\n', '\n</pre>') } | |
|
179 | } | |
|
180 | 180 | } |
|
181 | 181 | |
|
182 | 182 | // spacer |
@@ -184,28 +184,28 jsToolBar.prototype.elements.space4 = {type: 'space'} | |||
|
184 | 184 | |
|
185 | 185 | // wiki page |
|
186 | 186 | jsToolBar.prototype.elements.link = { |
|
187 |
|
|
|
188 |
|
|
|
189 |
|
|
|
190 |
|
|
|
191 | } | |
|
187 | type: 'button', | |
|
188 | title: 'Wiki link', | |
|
189 | fn: { | |
|
190 | wiki: function() { this.encloseSelection("[[", "]]") } | |
|
191 | } | |
|
192 | 192 | } |
|
193 | 193 | // image |
|
194 | 194 | jsToolBar.prototype.elements.img = { |
|
195 |
|
|
|
196 |
|
|
|
197 |
|
|
|
198 |
|
|
|
199 | } | |
|
195 | type: 'button', | |
|
196 | title: 'Image', | |
|
197 | fn: { | |
|
198 | wiki: function() { this.encloseSelection("!", "!") } | |
|
199 | } | |
|
200 | 200 | } |
|
201 | 201 | |
|
202 | 202 | // spacer |
|
203 | 203 | jsToolBar.prototype.elements.space5 = {type: 'space'} |
|
204 | 204 | // help |
|
205 | 205 | jsToolBar.prototype.elements.help = { |
|
206 |
|
|
|
207 |
|
|
|
208 |
|
|
|
209 |
|
|
|
210 | } | |
|
206 | type: 'button', | |
|
207 | title: 'Help', | |
|
208 | fn: { | |
|
209 | wiki: function() { window.open(this.help_link, '', 'resizable=yes, location=no, width=300, height=640, menubar=no, status=no, scrollbars=yes') } | |
|
210 | } | |
|
211 | 211 | } |
General Comments 0
You need to be logged in to leave comments.
Login now