/static/scripts/tiny_mce/themes/advanced/js/source_editor.js

http://n23.googlecode.com/ · JavaScript · 62 lines · 47 code · 14 blank · 1 comment · 6 complexity · 2fcdcb37221fc2123e08967deddce77f MD5 · raw file

  1. tinyMCEPopup.requireLangPack();
  2. tinyMCEPopup.onInit.add(onLoadInit);
  3. function saveContent() {
  4. tinyMCEPopup.editor.setContent(document.getElementById('htmlSource').value);
  5. tinyMCEPopup.close();
  6. }
  7. function onLoadInit() {
  8. tinyMCEPopup.resizeToInnerSize();
  9. // Remove Gecko spellchecking
  10. if (tinymce.isGecko)
  11. document.body.spellcheck = tinyMCEPopup.editor.getParam("gecko_spellcheck");
  12. document.getElementById('htmlSource').value = tinyMCEPopup.editor.getContent();
  13. if (tinyMCEPopup.editor.getParam("theme_advanced_source_editor_wrap", true)) {
  14. setWrap('soft');
  15. document.getElementById('wraped').checked = true;
  16. }
  17. resizeInputs();
  18. }
  19. function setWrap(val) {
  20. var v, n, s = document.getElementById('htmlSource');
  21. s.wrap = val;
  22. if (!tinymce.isIE) {
  23. v = s.value;
  24. n = s.cloneNode(false);
  25. n.setAttribute("wrap", val);
  26. s.parentNode.replaceChild(n, s);
  27. n.value = v;
  28. }
  29. }
  30. function toggleWordWrap(elm) {
  31. if (elm.checked)
  32. setWrap('soft');
  33. else
  34. setWrap('off');
  35. }
  36. var wHeight=0, wWidth=0, owHeight=0, owWidth=0;
  37. function resizeInputs() {
  38. var el = document.getElementById('htmlSource');
  39. if (!tinymce.isIE) {
  40. wHeight = self.innerHeight - 65;
  41. wWidth = self.innerWidth - 16;
  42. } else {
  43. wHeight = document.body.clientHeight - 70;
  44. wWidth = document.body.clientWidth - 16;
  45. }
  46. el.style.height = Math.abs(wHeight) + 'px';
  47. el.style.width = Math.abs(wWidth) + 'px';
  48. }