2 * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
\r
5 * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
\r
9 tinymce.create('tinymce.plugins.VisualChars', {
\r
10 init : function(ed, url) {
\r
15 // Register commands
\r
16 ed.addCommand('mceVisualChars', t._toggleVisualChars, t);
\r
19 ed.addButton('visualchars', {title : 'visualchars.desc', cmd : 'mceVisualChars'});
\r
21 ed.onBeforeGetContent.add(function(ed, o) {
\r
24 t._toggleVisualChars();
\r
29 getInfo : function() {
\r
31 longname : 'Visual characters',
\r
32 author : 'Moxiecode Systems AB',
\r
33 authorurl : 'http://tinymce.moxiecode.com',
\r
34 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/visualchars',
\r
35 version : tinymce.majorVersion + "." + tinymce.minorVersion
\r
41 _toggleVisualChars : function() {
\r
42 var t = this, ed = t.editor, nl, i, h, d = ed.getDoc(), b = ed.getBody(), nv, s = ed.selection, bo;
\r
45 ed.controlManager.setActive('visualchars', t.state);
\r
49 tinymce.walk(b, function(n) {
\r
50 if (n.nodeType == 3 && n.nodeValue && n.nodeValue.indexOf('\u00a0') != -1)
\r
54 for (i=0; i<nl.length; i++) {
\r
55 nv = nl[i].nodeValue;
\r
56 nv = nv.replace(/(\u00a0+)/g, '<span class="mceItemHidden mceVisualNbsp">$1</span>');
\r
57 nv = nv.replace(/\u00a0/g, '\u00b7');
\r
58 ed.dom.setOuterHTML(nl[i], nv, d);
\r
61 nl = tinymce.grep(ed.dom.select('span', b), function(n) {
\r
62 return ed.dom.hasClass(n, 'mceVisualNbsp');
\r
65 for (i=0; i<nl.length; i++)
\r
66 ed.dom.setOuterHTML(nl[i], nl[i].innerHTML.replace(/(·|\u00b7)/g, ' '), d);
\r
72 tinymce.PluginManager.add('visualchars', tinymce.plugins.VisualChars);
\r