[795] | 1 | <html> |
---|
| 2 | <head><title>Fullscreen Editor</title> |
---|
| 3 | <style type="text/css"> body { margin: 0px; border: 0px; background-color: buttonface; } </style> |
---|
| 4 | |
---|
| 5 | <script> |
---|
| 6 | |
---|
| 7 | // if we pass the "window" object as a argument and then set opener to |
---|
| 8 | // equal that we can refer to dialogWindows and popupWindows the same way |
---|
| 9 | if (window.dialogArguments) { opener = window.dialogArguments; } |
---|
| 10 | |
---|
| 11 | var _editor_url = "../"; |
---|
| 12 | document.write('<scr'+'ipt src="' +_editor_url+ 'editor.js" language="Javascript1.2"></scr'+'ipt>'); |
---|
| 13 | |
---|
| 14 | var parent_objname = location.search.substring(1,location.search.length); // parent editor objname |
---|
| 15 | var parent_config = opener.document.all[parent_objname].config; |
---|
| 16 | |
---|
| 17 | var config = cloneObject( parent_config ); |
---|
| 18 | var objname = 'editor'; // name of this editor |
---|
| 19 | |
---|
| 20 | // DOMViewerObj = config; |
---|
| 21 | // DOMViewerName = 'config'; |
---|
| 22 | // window.open('/innerHTML/domviewer.htm'); |
---|
| 23 | |
---|
| 24 | /* ---------------------------------------------------------------------- *\ |
---|
| 25 | Function : |
---|
| 26 | Description : |
---|
| 27 | \* ---------------------------------------------------------------------- */ |
---|
| 28 | |
---|
| 29 | function _CloseOnEsc() { |
---|
| 30 | if (event.keyCode == 27) { |
---|
| 31 | update_parent(); |
---|
| 32 | window.close(); |
---|
| 33 | return; |
---|
| 34 | } |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | /* ---------------------------------------------------------------------- *\ |
---|
| 38 | Function : cloneObject |
---|
| 39 | Description : copy an object by value instead of by reference |
---|
| 40 | Usage : var newObj = cloneObject(oldObj); |
---|
| 41 | \* ---------------------------------------------------------------------- */ |
---|
| 42 | |
---|
| 43 | function cloneObject(obj) { |
---|
| 44 | var newObj = new Object; |
---|
| 45 | |
---|
| 46 | // check for array objects |
---|
| 47 | if (obj.constructor.toString().indexOf('function Array(') == 1) { |
---|
| 48 | newObj = obj.constructor(); |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | for (var n in obj) { |
---|
| 52 | var node = obj[n]; |
---|
| 53 | if (typeof node == 'object') { newObj[n] = cloneObject(node); } |
---|
| 54 | else { newObj[n] = node; } |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | return newObj; |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | /* ---------------------------------------------------------------------- *\ |
---|
| 61 | Function : resize_editor |
---|
| 62 | Description : resize the editor when the user resizes the popup |
---|
| 63 | \* ---------------------------------------------------------------------- */ |
---|
| 64 | |
---|
| 65 | function resize_editor() { // resize editor to fix window |
---|
| 66 | var editor = document.all['_editor_editor']; |
---|
| 67 | |
---|
| 68 | newWidth = document.body.offsetWidth; |
---|
| 69 | newHeight = document.body.offsetHeight - editor.offsetTop; |
---|
| 70 | |
---|
| 71 | if (newWidth < 0) { newWidth = 0; } |
---|
| 72 | if (newHeight < 0) { newHeight = 0; } |
---|
| 73 | |
---|
| 74 | editor.style.width = newWidth; |
---|
| 75 | editor.style.height = newHeight; |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | /* ---------------------------------------------------------------------- *\ |
---|
| 79 | Function : init |
---|
| 80 | Description : run this code on page load |
---|
| 81 | \* ---------------------------------------------------------------------- */ |
---|
| 82 | |
---|
| 83 | function init() { |
---|
| 84 | // change maximize button to minimize button |
---|
| 85 | config.btnList["popupeditor"] = ['popupeditor', 'Minimize Editor', 'update_parent(); window.close();', 'fullscreen_minimize.gif']; |
---|
| 86 | |
---|
| 87 | // set htmlmode button to refer to THIS editor |
---|
| 88 | config.btnList["htmlmode"] = ['HtmlMode', 'View HTML Source', 'editor_setmode(\'editor\')', 'ed_html.gif']; |
---|
| 89 | |
---|
| 90 | // change image url to be relative to current path |
---|
| 91 | config.imgURL = "../images/"; |
---|
| 92 | |
---|
| 93 | // generate editor and resize it |
---|
| 94 | editor_generate('editor', config); |
---|
| 95 | resize_editor(); |
---|
| 96 | |
---|
| 97 | // switch mode if needed |
---|
| 98 | if (parent_config.mode == 'textedit') { editor_setmode(objname, 'textedit'); } |
---|
| 99 | |
---|
| 100 | // set child window contents |
---|
| 101 | var parentHTML = opener.editor_getHTML(parent_objname); |
---|
| 102 | editor_setHTML(objname, parentHTML); |
---|
| 103 | |
---|
| 104 | // continuously update parent editor window |
---|
| 105 | window.setInterval(update_parent, 333); |
---|
| 106 | |
---|
| 107 | // setup event handlers |
---|
| 108 | document.body.onkeypress = _CloseOnEsc; |
---|
| 109 | window.onresize = resize_editor; |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | /* ---------------------------------------------------------------------- *\ |
---|
| 113 | Function : update_parent |
---|
| 114 | Description : update parent window editor field with contents from child window |
---|
| 115 | \* ---------------------------------------------------------------------- */ |
---|
| 116 | |
---|
| 117 | function update_parent() { |
---|
| 118 | var childHTML = editor_getHTML(objname); |
---|
| 119 | opener.editor_setHTML(parent_objname, childHTML); |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | |
---|
| 123 | </script> |
---|
| 124 | </head> |
---|
| 125 | <body scroll="no" onload="init()" onunload="update_parent()"> |
---|
| 126 | |
---|
| 127 | <div style="margin: 0 0 0 0; border-width: 1; border-style: solid; border-color: threedshadow threedhighlight threedhighlight threedshadow; "></div> |
---|
| 128 | |
---|
| 129 | <textarea name="editor" style="width:100%; height:300px"></textarea><br> |
---|
| 130 | |
---|
| 131 | </body></html> |
---|