]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-includes/js/tinymce/themes/advanced/js/source_editor.js
Wordpress 3.5
[autoinstalls/wordpress.git] / wp-includes / js / tinymce / themes / advanced / js / source_editor.js
1 tinyMCEPopup.requireLangPack();
2 tinyMCEPopup.onInit.add(onLoadInit);
3
4 function saveContent() {
5         tinyMCEPopup.editor.setContent(document.getElementById('htmlSource').value, {source_view : true});
6         tinyMCEPopup.close();
7 }
8
9 function onLoadInit() {
10         tinyMCEPopup.resizeToInnerSize();
11
12         // Remove Gecko spellchecking
13         if (tinymce.isGecko)
14                 document.body.spellcheck = tinyMCEPopup.editor.getParam("gecko_spellcheck");
15
16         document.getElementById('htmlSource').value = tinyMCEPopup.editor.getContent({source_view : true});
17
18         if (tinyMCEPopup.editor.getParam("theme_advanced_source_editor_wrap", true)) {
19                 turnWrapOn();
20                 document.getElementById('wraped').checked = true;
21         }
22
23         resizeInputs();
24 }
25
26 function setWrap(val) {
27         var v, n, s = document.getElementById('htmlSource');
28
29         s.wrap = val;
30
31         if (!tinymce.isIE) {
32                 v = s.value;
33                 n = s.cloneNode(false);
34                 n.setAttribute("wrap", val);
35                 s.parentNode.replaceChild(n, s);
36                 n.value = v;
37         }
38 }
39
40 function setWhiteSpaceCss(value) {
41         var el = document.getElementById('htmlSource');
42         tinymce.DOM.setStyle(el, 'white-space', value);
43 }
44
45 function turnWrapOff() {
46         if (tinymce.isWebKit) {
47                 setWhiteSpaceCss('pre');
48         } else {
49                 setWrap('off');
50         }
51 }
52
53 function turnWrapOn() {
54         if (tinymce.isWebKit) {
55                 setWhiteSpaceCss('pre-wrap');
56         } else {
57                 setWrap('soft');
58         }
59 }
60
61 function toggleWordWrap(elm) {
62         if (elm.checked) {
63                 turnWrapOn();
64         } else {
65                 turnWrapOff();
66         }
67 }
68
69 function resizeInputs() {
70         var vp = tinyMCEPopup.dom.getViewPort(window), el;
71
72         el = document.getElementById('htmlSource');
73
74         if (el) {
75                 el.style.width = (vp.w - 20) + 'px';
76                 el.style.height = (vp.h - 65) + 'px';
77         }
78 }