4 * Copyright 2009, Moxiecode Systems AB
5 * Released under LGPL License.
7 * License: http://tinymce.moxiecode.com/license
8 * Contributing: http://tinymce.moxiecode.com/contributing
12 var Event = tinymce.dom.Event;
14 tinymce.create('tinymce.plugins.NonEditablePlugin', {
15 init : function(ed, url) {
16 var t = this, editClass, nonEditClass;
19 editClass = ed.getParam("noneditable_editable_class", "mceEditable");
20 nonEditClass = ed.getParam("noneditable_noneditable_class", "mceNonEditable");
22 ed.onNodeChange.addToTop(function(ed, cm, n) {
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);
30 ec = ed.dom.getParent(ed.selection.getEnd(), function(n) {
31 return ed.dom.hasClass(n, nonEditClass);
43 getInfo : function() {
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
53 _block : function(ed, e) {
56 // Don't block arrow keys, pg up/down, and F1-F12
57 if ((k > 32 && k < 41) || (k > 111 && k < 124))
60 return Event.cancel(e);
63 _setDisabled : function(s) {
64 var t = this, ed = t.editor;
66 tinymce.each(ed.controlManager.controls, function(c) {
70 if (s !== t.disabled) {
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);
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);
91 tinymce.PluginManager.add('noneditable', tinymce.plugins.NonEditablePlugin);