tagging as ATutor 1.5.4-release
[atutor.git] / jscripts / tiny_mce / themes / advanced / jscripts / source_editor.js
1 function saveContent() {\r
2         tinyMCE.setContent(document.getElementById('htmlSource').value);\r
3         tinyMCE.closeWindow(window);\r
4 }\r
5 \r
6 // Fixes some charcode issues\r
7 function fixContent(html) {\r
8 /*      html = html.replace(new RegExp('<(p|hr|table|tr|td|ol|ul|object|embed|li|blockquote)', 'gi'),'\n<$1');\r
9         html = html.replace(new RegExp('<\/(p|ol|ul|li|table|tr|td|blockquote|object)>', 'gi'),'</$1>\n');\r
10         html = tinyMCE.regexpReplace(html, '<br />','<br />\n','gi');\r
11         html = tinyMCE.regexpReplace(html, '\n\n','\n','gi');*/\r
12         return html;\r
13 }\r
14 \r
15 function onLoadInit() {\r
16         tinyMCEPopup.resizeToInnerSize();\r
17 \r
18         document.forms[0].htmlSource.value = fixContent(tinyMCE.getContent(tinyMCE.getWindowArg('editor_id')));\r
19         resizeInputs();\r
20 \r
21         if (tinyMCE.getParam("theme_advanced_source_editor_wrap", true)) {\r
22                 setWrap('soft');\r
23                 document.forms[0].wraped.checked = true;\r
24         }\r
25 }\r
26 \r
27 function setWrap(val) {\r
28         var s = document.forms[0].htmlSource;\r
29 \r
30         s.wrap = val;\r
31 \r
32         if (tinyMCE.isGecko) {\r
33                 var v = s.value;\r
34                 var n = s.cloneNode(false);\r
35                 n.setAttribute("wrap", val);\r
36                 s.parentNode.replaceChild(n, s);\r
37                 n.value = v;\r
38         }\r
39 }\r
40 \r
41 function toggleWordWrap(elm) {\r
42         if (elm.checked)\r
43                 setWrap('soft');\r
44         else\r
45                 setWrap('off');\r
46 }\r
47 \r
48 var wHeight=0, wWidth=0, owHeight=0, owWidth=0;\r
49 \r
50 function resizeInputs() {\r
51         if (!tinyMCE.isMSIE) {\r
52                  wHeight = self.innerHeight-80;\r
53                  wWidth = self.innerWidth-16;\r
54         } else {\r
55                  wHeight = document.body.clientHeight - 80;\r
56                  wWidth = document.body.clientWidth - 16;\r
57         }\r
58 \r
59         document.forms[0].htmlSource.style.height = Math.abs(wHeight) + 'px';\r
60         document.forms[0].htmlSource.style.width  = Math.abs(wWidth) + 'px';\r
61 }\r
62 \r
63 function renderWordWrap() {\r
64         if (tinyMCE.isMSIE || tinyMCE.isGecko)\r
65                 document.write('<input type="checkbox" name="wraped" id="wraped" onclick="toggleWordWrap(this);" class="wordWrapCode" /><label for="wraped">{$lang_theme_code_wordwrap}</label>');\r
66 }\r