source: trunk/library/tiny_mce/plugins/visualchars/editor_plugin_src.js @ 4829

Revision 4829, 2.1 KB checked in by airton, 13 years ago (diff)

Ticket #2146 - Implementacao da funcionalidade de multiplas assinaturas - Adicao da biblioteca TinyMCE

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