annotate media/js/tiny_mce/plugins/noneditable/editor_plugin_src.js @ 52:127ba8b24b52

Controlling the avatars directory in order to get the default avatar.
author Brian Neal <bgneal@gmail.com>
date Sun, 21 Jun 2009 22:13:57 +0000
parents a5b4c5ce0658
children 149c3567fec1
rev   line source
bgneal@45 1 /**
bgneal@45 2 * $Id: editor_plugin_src.js 743 2008-03-23 17:47:33Z spocke $
bgneal@45 3 *
bgneal@45 4 * @author Moxiecode
bgneal@45 5 * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
bgneal@45 6 */
bgneal@45 7
bgneal@45 8 (function() {
bgneal@45 9 var Event = tinymce.dom.Event;
bgneal@45 10
bgneal@45 11 tinymce.create('tinymce.plugins.NonEditablePlugin', {
bgneal@45 12 init : function(ed, url) {
bgneal@45 13 var t = this, editClass, nonEditClass;
bgneal@45 14
bgneal@45 15 t.editor = ed;
bgneal@45 16 editClass = ed.getParam("noneditable_editable_class", "mceEditable");
bgneal@45 17 nonEditClass = ed.getParam("noneditable_noneditable_class", "mceNonEditable");
bgneal@45 18
bgneal@45 19 ed.onNodeChange.addToTop(function(ed, cm, n) {
bgneal@45 20 var sc, ec;
bgneal@45 21
bgneal@45 22 // Block if start or end is inside a non editable element
bgneal@45 23 sc = ed.dom.getParent(ed.selection.getStart(), function(n) {
bgneal@45 24 return ed.dom.hasClass(n, nonEditClass);
bgneal@45 25 });
bgneal@45 26
bgneal@45 27 ec = ed.dom.getParent(ed.selection.getEnd(), function(n) {
bgneal@45 28 return ed.dom.hasClass(n, nonEditClass);
bgneal@45 29 });
bgneal@45 30
bgneal@45 31 // Block or unblock
bgneal@45 32 if (sc || ec) {
bgneal@45 33 t._setDisabled(1);
bgneal@45 34 return false;
bgneal@45 35 } else
bgneal@45 36 t._setDisabled(0);
bgneal@45 37 });
bgneal@45 38 },
bgneal@45 39
bgneal@45 40 getInfo : function() {
bgneal@45 41 return {
bgneal@45 42 longname : 'Non editable elements',
bgneal@45 43 author : 'Moxiecode Systems AB',
bgneal@45 44 authorurl : 'http://tinymce.moxiecode.com',
bgneal@45 45 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/noneditable',
bgneal@45 46 version : tinymce.majorVersion + "." + tinymce.minorVersion
bgneal@45 47 };
bgneal@45 48 },
bgneal@45 49
bgneal@45 50 _block : function(ed, e) {
bgneal@45 51 var k = e.keyCode;
bgneal@45 52
bgneal@45 53 // Don't block arrow keys, pg up/down, and F1-F12
bgneal@45 54 if ((k > 32 && k < 41) || (k > 111 && k < 124))
bgneal@45 55 return;
bgneal@45 56
bgneal@45 57 return Event.cancel(e);
bgneal@45 58 },
bgneal@45 59
bgneal@45 60 _setDisabled : function(s) {
bgneal@45 61 var t = this, ed = t.editor;
bgneal@45 62
bgneal@45 63 tinymce.each(ed.controlManager.controls, function(c) {
bgneal@45 64 c.setDisabled(s);
bgneal@45 65 });
bgneal@45 66
bgneal@45 67 if (s !== t.disabled) {
bgneal@45 68 if (s) {
bgneal@45 69 ed.onKeyDown.addToTop(t._block);
bgneal@45 70 ed.onKeyPress.addToTop(t._block);
bgneal@45 71 ed.onKeyUp.addToTop(t._block);
bgneal@45 72 ed.onPaste.addToTop(t._block);
bgneal@45 73 } else {
bgneal@45 74 ed.onKeyDown.remove(t._block);
bgneal@45 75 ed.onKeyPress.remove(t._block);
bgneal@45 76 ed.onKeyUp.remove(t._block);
bgneal@45 77 ed.onPaste.remove(t._block);
bgneal@45 78 }
bgneal@45 79
bgneal@45 80 t.disabled = s;
bgneal@45 81 }
bgneal@45 82 }
bgneal@45 83 });
bgneal@45 84
bgneal@45 85 // Register plugin
bgneal@45 86 tinymce.PluginManager.add('noneditable', tinymce.plugins.NonEditablePlugin);
bgneal@45 87 })();