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

Revision 4829, 2.3 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        var Event = tinymce.dom.Event;
13
14        tinymce.create('tinymce.plugins.NonEditablePlugin', {
15                init : function(ed, url) {
16                        var t = this, editClass, nonEditClass;
17
18                        t.editor = ed;
19                        editClass = ed.getParam("noneditable_editable_class", "mceEditable");
20                        nonEditClass = ed.getParam("noneditable_noneditable_class", "mceNonEditable");
21
22                        ed.onNodeChange.addToTop(function(ed, cm, n) {
23                                var sc, ec;
24
25                                // Block if start or end is inside a non editable element
26                                sc = ed.dom.getParent(ed.selection.getStart(), function(n) {
27                                        return ed.dom.hasClass(n, nonEditClass);
28                                });
29
30                                ec = ed.dom.getParent(ed.selection.getEnd(), function(n) {
31                                        return ed.dom.hasClass(n, nonEditClass);
32                                });
33
34                                // Block or unblock
35                                if (sc || ec) {
36                                        t._setDisabled(1);
37                                        return false;
38                                } else
39                                        t._setDisabled(0);
40                        });
41                },
42
43                getInfo : function() {
44                        return {
45                                longname : 'Non editable elements',
46                                author : 'Moxiecode Systems AB',
47                                authorurl : 'http://tinymce.moxiecode.com',
48                                infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/noneditable',
49                                version : tinymce.majorVersion + "." + tinymce.minorVersion
50                        };
51                },
52
53                _block : function(ed, e) {
54                        var k = e.keyCode;
55
56                        // Don't block arrow keys, pg up/down, and F1-F12
57                        if ((k > 32 && k < 41) || (k > 111 && k < 124))
58                                return;
59
60                        return Event.cancel(e);
61                },
62
63                _setDisabled : function(s) {
64                        var t = this, ed = t.editor;
65
66                        tinymce.each(ed.controlManager.controls, function(c) {
67                                c.setDisabled(s);
68                        });
69
70                        if (s !== t.disabled) {
71                                if (s) {
72                                        ed.onKeyDown.addToTop(t._block);
73                                        ed.onKeyPress.addToTop(t._block);
74                                        ed.onKeyUp.addToTop(t._block);
75                                        ed.onPaste.addToTop(t._block);
76                                        ed.onContextMenu.addToTop(t._block);
77                                } else {
78                                        ed.onKeyDown.remove(t._block);
79                                        ed.onKeyPress.remove(t._block);
80                                        ed.onKeyUp.remove(t._block);
81                                        ed.onPaste.remove(t._block);
82                                        ed.onContextMenu.remove(t._block);
83                                }
84
85                                t.disabled = s;
86                        }
87                }
88        });
89
90        // Register plugin
91        tinymce.PluginManager.add('noneditable', tinymce.plugins.NonEditablePlugin);
92})();
Note: See TracBrowser for help on using the repository browser.