annotate WebContent/jscripts/tiny_mce/plugins/visualchars/editor_plugin_src.js @ 14:0f64de5fff5a

try to use javax.xml.bind.DatatypeConverter
author casties
date Wed, 21 Mar 2012 16:38:50 +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 /**
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2 * editor_plugin_src.js
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3 *
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4 * Copyright 2009, Moxiecode Systems AB
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5 * Released under LGPL License.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6 *
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
7 * License: http://tinymce.moxiecode.com/license
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
8 * Contributing: http://tinymce.moxiecode.com/contributing
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 (function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
12 tinymce.create('tinymce.plugins.VisualChars', {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
13 init : function(ed, url) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
14 var t = this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
15
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
16 t.editor = ed;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
17
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
18 // Register commands
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
19 ed.addCommand('mceVisualChars', t._toggleVisualChars, t);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
20
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
21 // Register buttons
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
22 ed.addButton('visualchars', {title : 'visualchars.desc', cmd : 'mceVisualChars'});
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
23
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
24 ed.onBeforeGetContent.add(function(ed, o) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
25 if (t.state && o.format != 'raw' && !o.draft) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
26 t.state = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
27 t._toggleVisualChars(false);
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 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
31
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
32 getInfo : function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
33 return {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
34 longname : 'Visual characters',
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
35 author : 'Moxiecode Systems AB',
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
36 authorurl : 'http://tinymce.moxiecode.com',
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
37 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/visualchars',
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
38 version : tinymce.majorVersion + "." + tinymce.minorVersion
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
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
42 // Private methods
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
43
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
44 _toggleVisualChars : function(bookmark) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
45 var t = this, ed = t.editor, nl, i, h, d = ed.getDoc(), b = ed.getBody(), nv, s = ed.selection, bo, div, bm;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
46
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
47 t.state = !t.state;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
48 ed.controlManager.setActive('visualchars', t.state);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
49
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
50 if (bookmark)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
51 bm = s.getBookmark();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
52
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
53 if (t.state) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
54 nl = [];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
55 tinymce.walk(b, function(n) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
56 if (n.nodeType == 3 && n.nodeValue && n.nodeValue.indexOf('\u00a0') != -1)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
57 nl.push(n);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
58 }, 'childNodes');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
59
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
60 for (i = 0; i < nl.length; i++) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
61 nv = nl[i].nodeValue;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
62 nv = nv.replace(/(\u00a0)/g, '<span data-mce-bogus="1" class="mceItemHidden mceItemNbsp">$1</span>');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
63
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
64 div = ed.dom.create('div', null, nv);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
65 while (node = div.lastChild)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
66 ed.dom.insertAfter(node, nl[i]);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
67
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
68 ed.dom.remove(nl[i]);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
69 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
70 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
71 nl = ed.dom.select('span.mceItemNbsp', b);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
72
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
73 for (i = nl.length - 1; i >= 0; i--)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
74 ed.dom.remove(nl[i], 1);
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 s.moveToBookmark(bm);
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
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
81 // Register plugin
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
82 tinymce.PluginManager.add('visualchars', tinymce.plugins.VisualChars);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
83 })();