annotate static/js/tiny_mce/plugins/noneditable/editor_plugin_src.js @ 683:c83d330cb65f

For Django 1.5: LOGIN_* related settings take url names now.
author Brian Neal <bgneal@gmail.com>
date Fri, 23 Aug 2013 19:02:45 -0500
parents 6c182ceb7147
children
rev   line source
bgneal@312 1 /**
bgneal@312 2 * editor_plugin_src.js
bgneal@312 3 *
bgneal@312 4 * Copyright 2009, Moxiecode Systems AB
bgneal@312 5 * Released under LGPL License.
bgneal@312 6 *
bgneal@312 7 * License: http://tinymce.moxiecode.com/license
bgneal@312 8 * Contributing: http://tinymce.moxiecode.com/contributing
bgneal@312 9 */
bgneal@312 10
bgneal@312 11 (function() {
bgneal@312 12 var Event = tinymce.dom.Event;
bgneal@312 13
bgneal@312 14 tinymce.create('tinymce.plugins.NonEditablePlugin', {
bgneal@312 15 init : function(ed, url) {
bgneal@312 16 var t = this, editClass, nonEditClass;
bgneal@312 17
bgneal@312 18 t.editor = ed;
bgneal@312 19 editClass = ed.getParam("noneditable_editable_class", "mceEditable");
bgneal@312 20 nonEditClass = ed.getParam("noneditable_noneditable_class", "mceNonEditable");
bgneal@312 21
bgneal@312 22 ed.onNodeChange.addToTop(function(ed, cm, n) {
bgneal@312 23 var sc, ec;
bgneal@312 24
bgneal@312 25 // Block if start or end is inside a non editable element
bgneal@312 26 sc = ed.dom.getParent(ed.selection.getStart(), function(n) {
bgneal@312 27 return ed.dom.hasClass(n, nonEditClass);
bgneal@312 28 });
bgneal@312 29
bgneal@312 30 ec = ed.dom.getParent(ed.selection.getEnd(), function(n) {
bgneal@312 31 return ed.dom.hasClass(n, nonEditClass);
bgneal@312 32 });
bgneal@312 33
bgneal@312 34 // Block or unblock
bgneal@312 35 if (sc || ec) {
bgneal@312 36 t._setDisabled(1);
bgneal@312 37 return false;
bgneal@312 38 } else
bgneal@312 39 t._setDisabled(0);
bgneal@312 40 });
bgneal@312 41 },
bgneal@312 42
bgneal@312 43 getInfo : function() {
bgneal@312 44 return {
bgneal@312 45 longname : 'Non editable elements',
bgneal@312 46 author : 'Moxiecode Systems AB',
bgneal@312 47 authorurl : 'http://tinymce.moxiecode.com',
bgneal@312 48 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/noneditable',
bgneal@312 49 version : tinymce.majorVersion + "." + tinymce.minorVersion
bgneal@312 50 };
bgneal@312 51 },
bgneal@312 52
bgneal@312 53 _block : function(ed, e) {
bgneal@312 54 var k = e.keyCode;
bgneal@312 55
bgneal@312 56 // Don't block arrow keys, pg up/down, and F1-F12
bgneal@312 57 if ((k > 32 && k < 41) || (k > 111 && k < 124))
bgneal@312 58 return;
bgneal@312 59
bgneal@312 60 return Event.cancel(e);
bgneal@312 61 },
bgneal@312 62
bgneal@312 63 _setDisabled : function(s) {
bgneal@312 64 var t = this, ed = t.editor;
bgneal@312 65
bgneal@312 66 tinymce.each(ed.controlManager.controls, function(c) {
bgneal@312 67 c.setDisabled(s);
bgneal@312 68 });
bgneal@312 69
bgneal@312 70 if (s !== t.disabled) {
bgneal@312 71 if (s) {
bgneal@312 72 ed.onKeyDown.addToTop(t._block);
bgneal@312 73 ed.onKeyPress.addToTop(t._block);
bgneal@312 74 ed.onKeyUp.addToTop(t._block);
bgneal@312 75 ed.onPaste.addToTop(t._block);
bgneal@442 76 ed.onContextMenu.addToTop(t._block);
bgneal@312 77 } else {
bgneal@312 78 ed.onKeyDown.remove(t._block);
bgneal@312 79 ed.onKeyPress.remove(t._block);
bgneal@312 80 ed.onKeyUp.remove(t._block);
bgneal@312 81 ed.onPaste.remove(t._block);
bgneal@442 82 ed.onContextMenu.remove(t._block);
bgneal@312 83 }
bgneal@312 84
bgneal@312 85 t.disabled = s;
bgneal@312 86 }
bgneal@312 87 }
bgneal@312 88 });
bgneal@312 89
bgneal@312 90 // Register plugin
bgneal@312 91 tinymce.PluginManager.add('noneditable', tinymce.plugins.NonEditablePlugin);
bgneal@312 92 })();