source_editor.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. tinyMCEPopup.requireLangPack();
  2. tinyMCEPopup.onInit.add(onLoadInit);
  3. function saveContent() {
  4. tinyMCEPopup.editor.setContent(document.getElementById('htmlSource').value, {source_view : true});
  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({source_view : true});
  13. if (tinyMCEPopup.editor.getParam("theme_advanced_source_editor_wrap", true)) {
  14. turnWrapOn();
  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 setWhiteSpaceCss(value) {
  31. var el = document.getElementById('htmlSource');
  32. tinymce.DOM.setStyle(el, 'white-space', value);
  33. }
  34. function turnWrapOff() {
  35. if (tinymce.isWebKit) {
  36. setWhiteSpaceCss('pre');
  37. } else {
  38. setWrap('off');
  39. }
  40. }
  41. function turnWrapOn() {
  42. if (tinymce.isWebKit) {
  43. setWhiteSpaceCss('pre-wrap');
  44. } else {
  45. setWrap('soft');
  46. }
  47. }
  48. function toggleWordWrap(elm) {
  49. if (elm.checked) {
  50. turnWrapOn();
  51. } else {
  52. turnWrapOff();
  53. }
  54. }
  55. function resizeInputs() {
  56. var vp = tinyMCEPopup.dom.getViewPort(window), el;
  57. el = document.getElementById('htmlSource');
  58. if (el) {
  59. el.style.width = (vp.w - 20) + 'px';
  60. el.style.height = (vp.h - 65) + 'px';
  61. }
  62. }