Automatic installer.php lang files by installer_builder (20070726)
[moodle-linuxchix.git] / lib / editor / htmlarea / popups / fullscreen.php
blob721810f887553ee6337f4f047f55857b7f20bc65
1 <?php // $Id$
2 require("../../../../config.php");
4 $id = optional_param('id', SITEID, PARAM_INT);
6 require_course_login($id);
7 @header('Content-Type: text/html; charset=utf-8');
8 ?>
9 <html>
10 <head><title><?php print_string("fullscreen","editor");?></title>
11 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
12 <style type="text/css">
13 @import url(../htmlarea.css);
14 html, body { margin: 0px; border: 0px; background-color: buttonface; } </style>
17 <script type="text/javascript" src="../htmlarea.php?id=<?php p($id); ?>"></script>
18 <script type="text/javascript" src="../lang/en.php"></script>
19 <script type="text/javascript" src="../dialog.js" charset="utf-8"></script>
20 <script type="text/javascript" src="../plugins/TableOperations/table-operations.js" charset="utf-8"></script>
21 <script type="text/javascript" src="../plugins/TableOperations/lang/en.js" charset="utf-8"></script>
22 <script type="text/javascript">
23 // load same scripts that were present in the opener page
24 var scripts = opener.document.getElementsByTagName("script");
25 var head = document.getElementsByTagName("head")[0];
26 for (var i = 0; i < scripts.length; ++i) {
27 var script = scripts[i];
28 if (typeof script.src != "undefined" && /\S/.test(script.src)) {
29 // document.write("<scr" + "ipt type=" + "\"script/javascript\"");
30 // document.write(" src=\"../" + script.src + "\"></scr" + "ipt>");
31 var new_script = document.createElement("script");
32 if (/^https?:/i.test(script.src)) {
33 new_script.src = script.src;
34 } else {
35 new_script.src = "../" + script.src;
37 head.appendChild(new_script);
40 </script>
42 <script type="text/javascript">
44 var parent_object = null;
45 var editor = null; // to be initialized later [ function init() ]
47 /* ---------------------------------------------------------------------- *\
48 Function :
49 Description :
50 \* ---------------------------------------------------------------------- */
52 function _CloseOnEsc(ev) {
53 try {
54 if (document.all) {
55 // IE
56 ev || (ev = editor._iframe.contentWindow.event);
58 if (ev.keyCode == 27) {
59 // update_parent();
60 window.close();
61 return;
63 } catch(e) {}
66 /* ---------------------------------------------------------------------- *\
67 Function : cloneObject
68 Description : copy an object by value instead of by reference
69 Usage : var newObj = cloneObject(oldObj);
70 \* ---------------------------------------------------------------------- */
72 function cloneObject(obj) {
73 var newObj = new Object;
75 // check for array objects
76 if (obj.constructor.toString().indexOf("function Array(") >= 0) {
77 newObj = obj.constructor();
80 // check for function objects (as usual, IE is phucked up)
81 if (obj.constructor.toString().indexOf("function Function(") >= 0) {
82 newObj = obj; // just copy reference to it
83 } else for (var n in obj) {
84 var node = obj[n];
85 if (typeof node == 'object') { newObj[n] = cloneObject(node); }
86 else { newObj[n] = node; }
89 return newObj;
92 /* ---------------------------------------------------------------------- *\
93 Function : resize_editor
94 Description : resize the editor when the user resizes the popup
95 \* ---------------------------------------------------------------------- */
97 function resize_editor() { // resize editor to fix window
98 var newHeight;
99 if (document.all) {
100 // IE
101 newHeight = document.body.offsetHeight - editor._toolbar.offsetHeight;
102 if (newHeight < 0) { newHeight = 0; }
103 } else {
104 // Gecko
105 newHeight = window.innerHeight - editor._toolbar.offsetHeight;
107 if (editor.config.statusBar) {
108 newHeight -= editor._statusBar.offsetHeight;
110 editor._textArea.style.height = editor._iframe.style.height = newHeight + "px";
113 /* ---------------------------------------------------------------------- *\
114 Function : init
115 Description : run this code on page load
116 \* ---------------------------------------------------------------------- */
118 function init() {
119 parent_object = opener.HTMLArea._object;
120 var config = cloneObject( parent_object.config );
121 config.editorURL = "../";
122 config.width = "100%";
123 config.height = "auto";
125 // change maximize button to minimize button
126 config.btnList["popupeditor"] = [ "<?php print_string("minimize","editor");?>", "<?php echo $CFG->wwwroot ?>/lib/editor/htmlarea/images/fullscreen_minimize.gif", true,
127 function() { window.close(); } ];
129 // generate editor and resize it
130 editor = new HTMLArea("editor", config);
131 editor.registerPlugin(TableOperations);
132 editor.generate();
133 editor._iframe.style.width = "100%";
134 editor._textArea.style.width = "100%";
135 resize_editor();
137 // set child window contents and event handlers, after a small delay
138 setTimeout(function() {
139 editor.setHTML(parent_object.getInnerHTML());
141 // switch mode if needed
142 if (parent_object._mode == "textmode") { editor.setMode("textmode"); }
144 // continuously update parent editor window
145 setInterval(update_parent, 500);
147 // setup event handlers FAST FIX IS UNCOMMENT THESE, NOT WORKING!
148 //document.body.onkeypress = _CloseOnEsc;
149 //editor._doc.body.onkeypress = _CloseOnEsc;
150 //editor._textArea.onkeypress = _CloseOnEsc;
151 window.onresize = resize_editor;
152 }, 333); // give it some time to meet the new frame
155 /* ---------------------------------------------------------------------- *\
156 Function : update_parent
157 Description : update parent window editor field with contents from child window
158 \* ---------------------------------------------------------------------- */
160 function update_parent() {
161 // use the fast version
162 parent_object.setHTML(editor.getInnerHTML());
166 </script>
167 </head>
168 <body scroll="no" onload="init()" onunload="update_parent()">
170 <form style="margin: 0px; border: 1px solid; border-color: threedshadow threedhighlight threedhighlight threedshadow;">
171 <textarea name="editor" id="editor" style="width:100%; height:300px">&nbsp;</textarea>
172 </form>
174 </body></html>