summaryrefslogtreecommitdiffstats
path: root/extensions/tinymce/jscripts/tiny_mce/plugins/noneditable/editor_plugin_src.js
diff options
context:
space:
mode:
authorBret McMillan <bretm@redhat.com>2008-11-10 16:45:56 -0500
committerBret McMillan <bretm@redhat.com>2008-11-10 16:45:56 -0500
commit48e497b2b009e5b9d2137e2df8dab1639af1bb30 (patch)
treed054b3999f379b3881a9ab89b03723b44d86adc1 /extensions/tinymce/jscripts/tiny_mce/plugins/noneditable/editor_plugin_src.js
parentd2feb8c22a91df6bf306320f0bc14034c39c2789 (diff)
downloadmediawiki-stuff-48e497b2b009e5b9d2137e2df8dab1639af1bb30.tar.gz
mediawiki-stuff-48e497b2b009e5b9d2137e2df8dab1639af1bb30.tar.xz
mediawiki-stuff-48e497b2b009e5b9d2137e2df8dab1639af1bb30.zip
initial tinymce support for mediawiki
Diffstat (limited to 'extensions/tinymce/jscripts/tiny_mce/plugins/noneditable/editor_plugin_src.js')
-rw-r--r--extensions/tinymce/jscripts/tiny_mce/plugins/noneditable/editor_plugin_src.js87
1 files changed, 87 insertions, 0 deletions
diff --git a/extensions/tinymce/jscripts/tiny_mce/plugins/noneditable/editor_plugin_src.js b/extensions/tinymce/jscripts/tiny_mce/plugins/noneditable/editor_plugin_src.js
new file mode 100644
index 0000000..77db577
--- /dev/null
+++ b/extensions/tinymce/jscripts/tiny_mce/plugins/noneditable/editor_plugin_src.js
@@ -0,0 +1,87 @@
+/**
+ * $Id: editor_plugin_src.js 743 2008-03-23 17:47:33Z spocke $
+ *
+ * @author Moxiecode
+ * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
+ */
+
+(function() {
+ var Event = tinymce.dom.Event;
+
+ tinymce.create('tinymce.plugins.NonEditablePlugin', {
+ init : function(ed, url) {
+ var t = this, editClass, nonEditClass;
+
+ t.editor = ed;
+ editClass = ed.getParam("noneditable_editable_class", "mceEditable");
+ nonEditClass = ed.getParam("noneditable_noneditable_class", "mceNonEditable");
+
+ ed.onNodeChange.addToTop(function(ed, cm, n) {
+ var sc, ec;
+
+ // Block if start or end is inside a non editable element
+ sc = ed.dom.getParent(ed.selection.getStart(), function(n) {
+ return ed.dom.hasClass(n, nonEditClass);
+ });
+
+ ec = ed.dom.getParent(ed.selection.getEnd(), function(n) {
+ return ed.dom.hasClass(n, nonEditClass);
+ });
+
+ // Block or unblock
+ if (sc || ec) {
+ t._setDisabled(1);
+ return false;
+ } else
+ t._setDisabled(0);
+ });
+ },
+
+ getInfo : function() {
+ return {
+ longname : 'Non editable elements',
+ author : 'Moxiecode Systems AB',
+ authorurl : 'http://tinymce.moxiecode.com',
+ infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/noneditable',
+ version : tinymce.majorVersion + "." + tinymce.minorVersion
+ };
+ },
+
+ _block : function(ed, e) {
+ var k = e.keyCode;
+
+ // Don't block arrow keys, pg up/down, and F1-F12
+ if ((k > 32 && k < 41) || (k > 111 && k < 124))
+ return;
+
+ return Event.cancel(e);
+ },
+
+ _setDisabled : function(s) {
+ var t = this, ed = t.editor;
+
+ tinymce.each(ed.controlManager.controls, function(c) {
+ c.setDisabled(s);
+ });
+
+ if (s !== t.disabled) {
+ if (s) {
+ ed.onKeyDown.addToTop(t._block);
+ ed.onKeyPress.addToTop(t._block);
+ ed.onKeyUp.addToTop(t._block);
+ ed.onPaste.addToTop(t._block);
+ } else {
+ ed.onKeyDown.remove(t._block);
+ ed.onKeyPress.remove(t._block);
+ ed.onKeyUp.remove(t._block);
+ ed.onPaste.remove(t._block);
+ }
+
+ t.disabled = s;
+ }
+ }
+ });
+
+ // Register plugin
+ tinymce.PluginManager.add('noneditable', tinymce.plugins.NonEditablePlugin);
+})(); \ No newline at end of file