PageRenderTime 42ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
JavaScript | 82 lines | 55 code | 16 blank | 11 comment | 9 complexity | f55b4200e9f8ffb2ffb7c7c17e19b30a 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. tinymce.create('tinymce.plugins.Directionality', {
  12. init : function(ed, url) {
  13. var t = this;
  14. t.editor = ed;
  15. ed.addCommand('mceDirectionLTR', function() {
  16. var e = ed.dom.getParent(ed.selection.getNode(), ed.dom.isBlock);
  17. if (e) {
  18. if (ed.dom.getAttrib(e, "dir") != "ltr")
  19. ed.dom.setAttrib(e, "dir", "ltr");
  20. else
  21. ed.dom.setAttrib(e, "dir", "");
  22. }
  23. ed.nodeChanged();
  24. });
  25. ed.addCommand('mceDirectionRTL', function() {
  26. var e = ed.dom.getParent(ed.selection.getNode(), ed.dom.isBlock);
  27. if (e) {
  28. if (ed.dom.getAttrib(e, "dir") != "rtl")
  29. ed.dom.setAttrib(e, "dir", "rtl");
  30. else
  31. ed.dom.setAttrib(e, "dir", "");
  32. }
  33. ed.nodeChanged();
  34. });
  35. ed.addButton('ltr', {title : 'directionality.ltr_desc', cmd : 'mceDirectionLTR'});
  36. ed.addButton('rtl', {title : 'directionality.rtl_desc', cmd : 'mceDirectionRTL'});
  37. ed.onNodeChange.add(t._nodeChange, t);
  38. },
  39. getInfo : function() {
  40. return {
  41. longname : 'Directionality',
  42. author : 'Moxiecode Systems AB',
  43. authorurl : 'http://tinymce.moxiecode.com',
  44. infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/directionality',
  45. version : tinymce.majorVersion + "." + tinymce.minorVersion
  46. };
  47. },
  48. // Private methods
  49. _nodeChange : function(ed, cm, n) {
  50. var dom = ed.dom, dir;
  51. n = dom.getParent(n, dom.isBlock);
  52. if (!n) {
  53. cm.setDisabled('ltr', 1);
  54. cm.setDisabled('rtl', 1);
  55. return;
  56. }
  57. dir = dom.getAttrib(n, 'dir');
  58. cm.setActive('ltr', dir == "ltr");
  59. cm.setDisabled('ltr', 0);
  60. cm.setActive('rtl', dir == "rtl");
  61. cm.setDisabled('rtl', 0);
  62. }
  63. });
  64. // Register plugin
  65. tinymce.PluginManager.add('directionality', tinymce.plugins.Directionality);
  66. })();