PageRenderTime 51ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/BlogEngine/BlogEngine.NET/editors/tiny_mce_3_4_3_1/plugins/xhtmlxtras/js/attributes.js

#
JavaScript | 111 lines | 83 code | 16 blank | 12 comment | 9 complexity | e75f23fae888b9febb57a29f2eb5a86c MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0, BSD-3-Clause
  1. /**
  2. * attributes.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 init() {
  11. tinyMCEPopup.resizeToInnerSize();
  12. var inst = tinyMCEPopup.editor;
  13. var dom = inst.dom;
  14. var elm = inst.selection.getNode();
  15. var f = document.forms[0];
  16. var onclick = dom.getAttrib(elm, 'onclick');
  17. setFormValue('title', dom.getAttrib(elm, 'title'));
  18. setFormValue('id', dom.getAttrib(elm, 'id'));
  19. setFormValue('style', dom.getAttrib(elm, "style"));
  20. setFormValue('dir', dom.getAttrib(elm, 'dir'));
  21. setFormValue('lang', dom.getAttrib(elm, 'lang'));
  22. setFormValue('tabindex', dom.getAttrib(elm, 'tabindex', typeof(elm.tabindex) != "undefined" ? elm.tabindex : ""));
  23. setFormValue('accesskey', dom.getAttrib(elm, 'accesskey', typeof(elm.accesskey) != "undefined" ? elm.accesskey : ""));
  24. setFormValue('onfocus', dom.getAttrib(elm, 'onfocus'));
  25. setFormValue('onblur', dom.getAttrib(elm, 'onblur'));
  26. setFormValue('onclick', onclick);
  27. setFormValue('ondblclick', dom.getAttrib(elm, 'ondblclick'));
  28. setFormValue('onmousedown', dom.getAttrib(elm, 'onmousedown'));
  29. setFormValue('onmouseup', dom.getAttrib(elm, 'onmouseup'));
  30. setFormValue('onmouseover', dom.getAttrib(elm, 'onmouseover'));
  31. setFormValue('onmousemove', dom.getAttrib(elm, 'onmousemove'));
  32. setFormValue('onmouseout', dom.getAttrib(elm, 'onmouseout'));
  33. setFormValue('onkeypress', dom.getAttrib(elm, 'onkeypress'));
  34. setFormValue('onkeydown', dom.getAttrib(elm, 'onkeydown'));
  35. setFormValue('onkeyup', dom.getAttrib(elm, 'onkeyup'));
  36. className = dom.getAttrib(elm, 'class');
  37. addClassesToList('classlist', 'advlink_styles');
  38. selectByValue(f, 'classlist', className, true);
  39. TinyMCE_EditableSelects.init();
  40. }
  41. function setFormValue(name, value) {
  42. if(value && document.forms[0].elements[name]){
  43. document.forms[0].elements[name].value = value;
  44. }
  45. }
  46. function insertAction() {
  47. var inst = tinyMCEPopup.editor;
  48. var elm = inst.selection.getNode();
  49. setAllAttribs(elm);
  50. tinyMCEPopup.execCommand("mceEndUndoLevel");
  51. tinyMCEPopup.close();
  52. }
  53. function setAttrib(elm, attrib, value) {
  54. var formObj = document.forms[0];
  55. var valueElm = formObj.elements[attrib.toLowerCase()];
  56. var inst = tinyMCEPopup.editor;
  57. var dom = inst.dom;
  58. if (typeof(value) == "undefined" || value == null) {
  59. value = "";
  60. if (valueElm)
  61. value = valueElm.value;
  62. }
  63. dom.setAttrib(elm, attrib.toLowerCase(), value);
  64. }
  65. function setAllAttribs(elm) {
  66. var f = document.forms[0];
  67. setAttrib(elm, 'title');
  68. setAttrib(elm, 'id');
  69. setAttrib(elm, 'style');
  70. setAttrib(elm, 'class', getSelectValue(f, 'classlist'));
  71. setAttrib(elm, 'dir');
  72. setAttrib(elm, 'lang');
  73. setAttrib(elm, 'tabindex');
  74. setAttrib(elm, 'accesskey');
  75. setAttrib(elm, 'onfocus');
  76. setAttrib(elm, 'onblur');
  77. setAttrib(elm, 'onclick');
  78. setAttrib(elm, 'ondblclick');
  79. setAttrib(elm, 'onmousedown');
  80. setAttrib(elm, 'onmouseup');
  81. setAttrib(elm, 'onmouseover');
  82. setAttrib(elm, 'onmousemove');
  83. setAttrib(elm, 'onmouseout');
  84. setAttrib(elm, 'onkeypress');
  85. setAttrib(elm, 'onkeydown');
  86. setAttrib(elm, 'onkeyup');
  87. // Refresh in old MSIE
  88. // if (tinyMCE.isMSIE5)
  89. // elm.outerHTML = elm.outerHTML;
  90. }
  91. function insertAttribute() {
  92. tinyMCEPopup.close();
  93. }
  94. tinyMCEPopup.onInit.add(init);
  95. tinyMCEPopup.requireLangPack();