Annotation of loncom/html/htmlarea/popups/popup.js, revision 1.2
1.2 ! www 1: // htmlArea v3.0 - Copyright (c) 2002, 2003 interactivetools.com, inc.
! 2: // This copyright notice MUST stay intact for use (see license.txt).
! 3: //
! 4: // Portions (c) dynarch.com, 2003
! 5: //
! 6: // A free WYSIWYG editor replacement for <textarea> fields.
! 7: // For full source code and docs, visit http://www.interactivetools.com/
! 8: //
! 9: // Version 3.0 developed by Mihai Bazon.
! 10: // http://dynarch.com/mishoo
! 11: //
! 12: // $Id: popup.js,v 1.8 2003/12/05 09:19:01 mishoo Exp $
! 13:
! 14: function getAbsolutePos(el) {
! 15: var r = { x: el.offsetLeft, y: el.offsetTop };
! 16: if (el.offsetParent) {
! 17: var tmp = getAbsolutePos(el.offsetParent);
! 18: r.x += tmp.x;
! 19: r.y += tmp.y;
! 20: }
! 21: return r;
! 22: };
! 23:
! 24: function comboSelectValue(c, val) {
! 25: var ops = c.getElementsByTagName("option");
! 26: for (var i = ops.length; --i >= 0;) {
! 27: var op = ops[i];
! 28: op.selected = (op.value == val);
! 29: }
! 30: c.value = val;
! 31: };
! 32:
1.1 www 33: function __dlg_onclose() {
1.2 ! www 34: opener.Dialog._return(null);
1.1 www 35: };
36:
1.2 ! www 37: function __dlg_init(bottom) {
! 38: var body = document.body;
! 39: var body_height = 0;
! 40: if (typeof bottom == "undefined") {
! 41: var div = document.createElement("div");
! 42: body.appendChild(div);
! 43: var pos = getAbsolutePos(div);
! 44: body_height = pos.y;
! 45: } else {
! 46: var pos = getAbsolutePos(bottom);
! 47: body_height = pos.y + bottom.offsetHeight;
! 48: }
! 49: window.dialogArguments = opener.Dialog._arguments;
1.1 www 50: if (!document.all) {
51: window.sizeToContent();
52: window.sizeToContent(); // for reasons beyond understanding,
53: // only if we call it twice we get the
54: // correct size.
55: window.addEventListener("unload", __dlg_onclose, true);
56: // center on parent
1.2 ! www 57: var x = opener.screenX + (opener.outerWidth - window.outerWidth) / 2;
! 58: var y = opener.screenY + (opener.outerHeight - window.outerHeight) / 2;
1.1 www 59: window.moveTo(x, y);
1.2 ! www 60: window.innerWidth = body.offsetWidth + 5;
! 61: window.innerHeight = body_height + 2;
1.1 www 62: } else {
1.2 ! www 63: // window.dialogHeight = body.offsetHeight + 50 + "px";
! 64: // window.dialogWidth = body.offsetWidth + "px";
! 65: window.resizeTo(body.offsetWidth, body_height);
! 66: var ch = body.clientHeight;
! 67: var cw = body.clientWidth;
! 68: window.resizeBy(body.offsetWidth - cw, body_height - ch);
! 69: var W = body.offsetWidth;
! 70: var H = 2 * body_height - ch;
! 71: var x = (screen.availWidth - W) / 2;
! 72: var y = (screen.availHeight - H) / 2;
! 73: window.moveTo(x, y);
! 74: }
! 75: document.body.onkeypress = __dlg_close_on_esc;
! 76: };
! 77:
! 78: function __dlg_translate(i18n) {
! 79: var types = ["span", "option", "td", "button", "div"];
! 80: for (var type in types) {
! 81: var spans = document.getElementsByTagName(types[type]);
! 82: for (var i = spans.length; --i >= 0;) {
! 83: var span = spans[i];
! 84: if (span.firstChild && span.firstChild.data) {
! 85: var txt = i18n[span.firstChild.data];
! 86: if (txt)
! 87: span.firstChild.data = txt;
! 88: }
! 89: }
1.1 www 90: }
1.2 ! www 91: var txt = i18n[document.title];
! 92: if (txt)
! 93: document.title = txt;
1.1 www 94: };
95:
96: // closes the dialog and passes the return info upper.
97: function __dlg_close(val) {
1.2 ! www 98: opener.Dialog._return(val);
! 99: window.close();
! 100: };
! 101:
! 102: function __dlg_close_on_esc(ev) {
! 103: ev || (ev = window.event);
! 104: if (ev.keyCode == 27) {
! 105: window.close();
! 106: return false;
1.1 www 107: }
1.2 ! www 108: return true;
1.1 www 109: };
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>