]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js
Wordpress 2.0.4-scripts
[autoinstalls/wordpress.git] / wp-includes / js / tinymce / themes / advanced / jscripts / source_editor.js
1 function saveContent() {
2         tinyMCE.setContent(document.getElementById('htmlSource').value);
3         tinyMCE.closeWindow(window);
4 }
5
6 // Fixes some charcode issues
7 function fixContent(html) {
8         // WP
9         return html;
10
11         html = html.replace(new RegExp('<(p|hr|table|tr|td|ol|ul|object|embed|li|blockquote)', 'gi'),'\n<$1');
12         html = html.replace(new RegExp('<\/(p|ol|ul|li|table|tr|td|blockquote|object)>', 'gi'),'</$1>\n');
13         html = tinyMCE.regexpReplace(html, '<br />','<br />\n','gi');
14         html = tinyMCE.regexpReplace(html, '\n\n','\n','gi');
15         return html;
16 }
17
18 function onLoadInit() {
19         tinyMCEPopup.resizeToInnerSize();
20
21         document.forms[0].htmlSource.value = fixContent(tinyMCE.getContent(tinyMCE.getWindowArg('editor_id')));
22         resizeInputs();
23         setWrap('off');
24 }
25
26 function setWrap(val) {
27         // hard soft off
28         document.forms[0].htmlSource.wrap = val;
29 }
30
31 function toggleWordWrap(elm) {
32         if (elm.checked)
33                 setWrap('soft');
34         else
35                 setWrap('off');
36 }
37
38 var wHeight=0, wWidth=0, owHeight=0, owWidth=0;
39
40 function resizeInputs() {
41         if (!tinyMCE.isMSIE) {
42                  wHeight = self.innerHeight-80;
43                  wWidth = self.innerWidth-16;
44         } else {
45                  wHeight = document.body.clientHeight - 80;
46                  wWidth = document.body.clientWidth - 16;
47         }
48
49         document.forms[0].htmlSource.style.height = Math.abs(wHeight) + 'px';
50         document.forms[0].htmlSource.style.width  = Math.abs(wWidth) + 'px';
51 }
52
53 function renderWordWrap() {
54         if (tinyMCE.isMSIE)
55                 document.write('<input type="checkbox" name="wraped" id="wraped" onclick="toggleWordWrap(this);" class="wordWrapCode" /><label for="wraped">{$lang_theme_code_wordwrap}</label>');
56 }