Annotation of loncom/html/htmlarea/popups/fullscreen.html, revision 1.2

1.2     ! www         1: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1.1       www         2: <html>
1.2     ! www         3:   <head>
        !             4:     <title>Fullscreen HTMLArea</title>
        !             5:     <script type="text/javascript">
        !             6:       _editor_url = window.opener._editor_url;
        !             7:       _editor_lang = window.opener._editor_lang;
        !             8:       var BASE = window.opener.document.baseURI || window.opener.document.URL;
        !             9:       var head = document.getElementsByTagName("head")[0];
        !            10:       var base = document.createElement("base");
        !            11:       base.href = BASE;
        !            12:       head.appendChild(base);
        !            13:     </script>
        !            14: 
        !            15:     <script type="text/javascript" src="../htmlarea.js"></script>
        !            16: 
        !            17:     <script type="text/javascript">
        !            18: 	// load HTMLArea scripts that are present in the opener frame
        !            19: 	var scripts = window.opener.HTMLArea._scripts;
        !            20: 	for (var i = 4; i < scripts.length; ++i) {
        !            21:            document.write("<scr" + "ipt type='text/javascript' src='" + scripts[i] + "'></scr" + "ipt>");
        !            22:         }
        !            23:     </script>
1.1       www        24: 
1.2     ! www        25:     <!-- browser takes a coffee break here -->
        !            26:     <script type="text/javascript">
1.1       www        27: var parent_object  = null;
1.2     ! www        28: var editor	   = null;	// to be initialized later [ function init() ]
1.1       www        29: 
                     30: /* ---------------------------------------------------------------------- *\
1.2     ! www        31:    Function    : 
        !            32:    Description : 
1.1       www        33: \* ---------------------------------------------------------------------- */
                     34: 
                     35: function _CloseOnEsc(ev) {
1.2     ! www        36: 	ev || (ev = window.event);
        !            37: 	if (ev.keyCode == 27) {
        !            38: 		// update_parent();
        !            39: 		window.close();
        !            40: 		return;
        !            41: 	}
1.1       www        42: }
                     43: 
                     44: /* ---------------------------------------------------------------------- *\
1.2     ! www        45:    Function    : resize_editor
        !            46:    Description : resize the editor when the user resizes the popup
1.1       www        47: \* ---------------------------------------------------------------------- */
                     48: 
                     49: function resize_editor() {  // resize editor to fix window
1.2     ! www        50: 	var newHeight;
        !            51: 	if (document.all) {
        !            52: 		// IE
        !            53: 		newHeight = document.body.offsetHeight - editor._toolbar.offsetHeight;
        !            54: 		if (newHeight < 0) { newHeight = 0; }
        !            55: 	} else {
        !            56: 		// Gecko
        !            57: 		newHeight = window.innerHeight - editor._toolbar.offsetHeight;
        !            58: 	}
        !            59: 	if (editor.config.statusBar) {
        !            60: 		newHeight -= editor._statusBar.offsetHeight;
        !            61: 	}
        !            62: 	editor._textArea.style.height = editor._iframe.style.height = newHeight + "px";
1.1       www        63: }
                     64: 
                     65: /* ---------------------------------------------------------------------- *\
1.2     ! www        66:    Function    : init
        !            67:    Description : run this code on page load
1.1       www        68: \* ---------------------------------------------------------------------- */
                     69: 
                     70: function init() {
1.2     ! www        71: 	parent_object	   = opener.HTMLArea._object;
        !            72: 	var config	   = HTMLArea.cloneObject( parent_object.config );
        !            73: 	config.width	   = "100%";
        !            74: 	config.height	   = "auto";
        !            75: 
        !            76: 	// change maximize button to minimize button
        !            77: 	config.btnList["popupeditor"] = [ 'Minimize Editor', _editor_url + 'images/fullscreen_minimize.gif', true,
        !            78: 					  function() { window.close(); } ];
        !            79: 
        !            80: 	// generate editor and resize it
        !            81: 	editor = new HTMLArea("editor", config);
        !            82: 
        !            83: 	// register the plugins, if any
        !            84: 	for (var i in parent_object.plugins) {
        !            85: 		var plugin = parent_object.plugins[i];
        !            86: 		editor.registerPlugin2(plugin.name, plugin.args);
        !            87: 	}
        !            88: 	// and restore the original toolbar
        !            89:         config.toolbar = parent_object.config.toolbar;
        !            90: 	editor.generate();
        !            91: 	editor._iframe.style.width = "100%";
        !            92: 	editor._textArea.style.width = "100%";
        !            93: 	resize_editor();
        !            94: 
        !            95: 	editor.doctype = parent_object.doctype;
        !            96: 
        !            97: 	// set child window contents and event handlers, after a small delay
        !            98: 	setTimeout(function() {
        !            99: 			   editor.setHTML(parent_object.getInnerHTML());
        !           100: 
        !           101: 			   // switch mode if needed
        !           102: 			   if (parent_object._mode == "textmode") { editor.setMode("textmode"); }
        !           103: 
        !           104: 			   // continuously update parent editor window
        !           105: 			   setInterval(update_parent, 500);
        !           106: 
        !           107: 			   // setup event handlers
        !           108: 			   document.body.onkeypress = _CloseOnEsc;
        !           109: 			   editor._doc.body.onkeypress = _CloseOnEsc;
        !           110: 			   editor._textArea.onkeypress = _CloseOnEsc;
        !           111: 			   window.onresize = resize_editor;
        !           112: 		   }, 333);			 // give it some time to meet the new frame
1.1       www       113: }
                    114: 
                    115: /* ---------------------------------------------------------------------- *\
1.2     ! www       116:    Function    : update_parent
        !           117:    Description : update parent window editor field with contents from child window
        !           118:    \* ---------------------------------------------------------------------- */
1.1       www       119: 
                    120: function update_parent() {
1.2     ! www       121: 	// use the fast version
        !           122: 	parent_object.setHTML(editor.getInnerHTML());
1.1       www       123: }
                    124: 
1.2     ! www       125:     </script>
        !           126:     <style type="text/css"> html, body { height: 100%; margin: 0px; border: 0px; background-color: buttonface; } </style>
        !           127:   </head>
        !           128:   <body scroll="no" onload="setTimeout(function(){init();}, 500)" onunload="update_parent()">
        !           129:     <form style="margin: 0px; border: 1px solid; border-color: threedshadow threedhighlight threedhighlight threedshadow;">
        !           130:       <textarea name="editor" id="editor" style="width:100%; height:300px">&nbsp;</textarea>
        !           131:     </form>
        !           132:   </body>
        !           133: </html>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>