bgneal@45: /** bgneal@183: * editor_plugin_src.js bgneal@45: * bgneal@183: * Copyright 2009, Moxiecode Systems AB bgneal@183: * Released under LGPL License. bgneal@183: * bgneal@183: * License: http://tinymce.moxiecode.com/license bgneal@183: * Contributing: http://tinymce.moxiecode.com/contributing bgneal@45: */ bgneal@45: bgneal@45: (function() { bgneal@45: var Event = tinymce.dom.Event; bgneal@45: bgneal@45: tinymce.create('tinymce.plugins.NonEditablePlugin', { bgneal@45: init : function(ed, url) { bgneal@45: var t = this, editClass, nonEditClass; bgneal@45: bgneal@45: t.editor = ed; bgneal@45: editClass = ed.getParam("noneditable_editable_class", "mceEditable"); bgneal@45: nonEditClass = ed.getParam("noneditable_noneditable_class", "mceNonEditable"); bgneal@45: bgneal@45: ed.onNodeChange.addToTop(function(ed, cm, n) { bgneal@45: var sc, ec; bgneal@45: bgneal@45: // Block if start or end is inside a non editable element bgneal@45: sc = ed.dom.getParent(ed.selection.getStart(), function(n) { bgneal@45: return ed.dom.hasClass(n, nonEditClass); bgneal@45: }); bgneal@45: bgneal@45: ec = ed.dom.getParent(ed.selection.getEnd(), function(n) { bgneal@45: return ed.dom.hasClass(n, nonEditClass); bgneal@45: }); bgneal@45: bgneal@45: // Block or unblock bgneal@45: if (sc || ec) { bgneal@45: t._setDisabled(1); bgneal@45: return false; bgneal@45: } else bgneal@45: t._setDisabled(0); bgneal@45: }); bgneal@45: }, bgneal@45: bgneal@45: getInfo : function() { bgneal@45: return { bgneal@45: longname : 'Non editable elements', bgneal@45: author : 'Moxiecode Systems AB', bgneal@45: authorurl : 'http://tinymce.moxiecode.com', bgneal@45: infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/noneditable', bgneal@45: version : tinymce.majorVersion + "." + tinymce.minorVersion bgneal@45: }; bgneal@45: }, bgneal@45: bgneal@45: _block : function(ed, e) { bgneal@45: var k = e.keyCode; bgneal@45: bgneal@45: // Don't block arrow keys, pg up/down, and F1-F12 bgneal@45: if ((k > 32 && k < 41) || (k > 111 && k < 124)) bgneal@45: return; bgneal@45: bgneal@45: return Event.cancel(e); bgneal@45: }, bgneal@45: bgneal@45: _setDisabled : function(s) { bgneal@45: var t = this, ed = t.editor; bgneal@45: bgneal@45: tinymce.each(ed.controlManager.controls, function(c) { bgneal@45: c.setDisabled(s); bgneal@45: }); bgneal@45: bgneal@45: if (s !== t.disabled) { bgneal@45: if (s) { bgneal@45: ed.onKeyDown.addToTop(t._block); bgneal@45: ed.onKeyPress.addToTop(t._block); bgneal@45: ed.onKeyUp.addToTop(t._block); bgneal@45: ed.onPaste.addToTop(t._block); bgneal@45: } else { bgneal@45: ed.onKeyDown.remove(t._block); bgneal@45: ed.onKeyPress.remove(t._block); bgneal@45: ed.onKeyUp.remove(t._block); bgneal@45: ed.onPaste.remove(t._block); bgneal@45: } bgneal@45: bgneal@45: t.disabled = s; bgneal@45: } bgneal@45: } bgneal@45: }); bgneal@45: bgneal@45: // Register plugin bgneal@45: tinymce.PluginManager.add('noneditable', tinymce.plugins.NonEditablePlugin); bgneal@45: })();