* Removed the Kevin Roth rich text editor and replaced it with TinyMCE.
[citadel.git] / webcit / tiny_mce / 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         html = html.replace(new RegExp('<(p|hr|table|tr|td|ol|ul|object|embed|li|blockquote)', 'gi'),'\n<$1');
9         html = html.replace(new RegExp('<\/(p|ol|ul|li|table|tr|td|blockquote|object)>', 'gi'),'</$1>\n');
10         html = tinyMCE.regexpReplace(html, '<br />','<br />\n','gi');
11         html = tinyMCE.regexpReplace(html, '\n\n','\n','gi');
12         return html;
13 }
14
15 function onLoadInit() {
16         tinyMCEPopup.resizeToInnerSize();
17
18         document.forms[0].htmlSource.value = fixContent(tinyMCE.getContent(tinyMCE.getWindowArg('editor_id')));
19         resizeInputs();
20         setWrap('off');
21 }
22
23 function setWrap(val) {
24         // hard soft off
25         document.forms[0].htmlSource.wrap = val;
26 }
27
28 function toggleWordWrap(elm) {
29         if (elm.checked)
30                 setWrap('soft');
31         else
32                 setWrap('off');
33 }
34
35 var wHeight=0, wWidth=0, owHeight=0, owWidth=0;
36
37 function resizeInputs() {
38         if (!tinyMCE.isMSIE) {
39                  wHeight = self.innerHeight-80;
40                  wWidth = self.innerWidth-16;
41         } else {
42                  wHeight = document.body.clientHeight-80;
43                  wWidth = document.body.clientWidth-16;
44         }
45
46         document.forms[0].htmlSource.style.height = Math.abs(wHeight) + 'px';
47         document.forms[0].htmlSource.style.width  = Math.abs(wWidth) + 'px';
48                 
49 }
50
51 function renderWordWrap() {
52         if (tinyMCE.isMSIE)
53                 document.write('<input type="checkbox" name="wraped" id="wraped" onclick="toggleWordWrap(this);" class="wordWrapCode" /><label for="wraped">{$lang_theme_code_wordwrap}</label>');
54 }