PageRenderTime 40ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/BlogEngine/BlogEngine.NET/editors/tiny_mce_3_4_3_1/plugins/noneditable/editor_plugin_src.js

#
JavaScript | 92 lines | 63 code | 16 blank | 13 comment | 9 complexity | e1f112ed96b2786186c8afa663c79439 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0, BSD-3-Clause
  1. /**
  2. * editor_plugin_src.js
  3. *
  4. * Copyright 2009, Moxiecode Systems AB
  5. * Released under LGPL License.
  6. *
  7. * License: http://tinymce.moxiecode.com/license
  8. * Contributing: http://tinymce.moxiecode.com/contributing
  9. */
  10. (function() {
  11. var Event = tinymce.dom.Event;
  12. tinymce.create('tinymce.plugins.NonEditablePlugin', {
  13. init : function(ed, url) {
  14. var t = this, editClass, nonEditClass;
  15. t.editor = ed;
  16. editClass = ed.getParam("noneditable_editable_class", "mceEditable");
  17. nonEditClass = ed.getParam("noneditable_noneditable_class", "mceNonEditable");
  18. ed.onNodeChange.addToTop(function(ed, cm, n) {
  19. var sc, ec;
  20. // Block if start or end is inside a non editable element
  21. sc = ed.dom.getParent(ed.selection.getStart(), function(n) {
  22. return ed.dom.hasClass(n, nonEditClass);
  23. });
  24. ec = ed.dom.getParent(ed.selection.getEnd(), function(n) {
  25. return ed.dom.hasClass(n, nonEditClass);
  26. });
  27. // Block or unblock
  28. if (sc || ec) {
  29. t._setDisabled(1);
  30. return false;
  31. } else
  32. t._setDisabled(0);
  33. });
  34. },
  35. getInfo : function() {
  36. return {
  37. longname : 'Non editable elements',
  38. author : 'Moxiecode Systems AB',
  39. authorurl : 'http://tinymce.moxiecode.com',
  40. infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/noneditable',
  41. version : tinymce.majorVersion + "." + tinymce.minorVersion
  42. };
  43. },
  44. _block : function(ed, e) {
  45. var k = e.keyCode;
  46. // Don't block arrow keys, pg up/down, and F1-F12
  47. if ((k > 32 && k < 41) || (k > 111 && k < 124))
  48. return;
  49. return Event.cancel(e);
  50. },
  51. _setDisabled : function(s) {
  52. var t = this, ed = t.editor;
  53. tinymce.each(ed.controlManager.controls, function(c) {
  54. c.setDisabled(s);
  55. });
  56. if (s !== t.disabled) {
  57. if (s) {
  58. ed.onKeyDown.addToTop(t._block);
  59. ed.onKeyPress.addToTop(t._block);
  60. ed.onKeyUp.addToTop(t._block);
  61. ed.onPaste.addToTop(t._block);
  62. ed.onContextMenu.addToTop(t._block);
  63. } else {
  64. ed.onKeyDown.remove(t._block);
  65. ed.onKeyPress.remove(t._block);
  66. ed.onKeyUp.remove(t._block);
  67. ed.onPaste.remove(t._block);
  68. ed.onContextMenu.remove(t._block);
  69. }
  70. t.disabled = s;
  71. }
  72. }
  73. });
  74. // Register plugin
  75. tinymce.PluginManager.add('noneditable', tinymce.plugins.NonEditablePlugin);
  76. })();