Annotation of loncom/html/htmlarea/dialog.js, revision 1.1

1.1     ! www         1: // Though "Dialog" looks like an object, it isn't really an object.  Instead
        !             2: // it's just namespace for protecting global symbols.
        !             3: 
        !             4: function Dialog(url, action, init) {
        !             5: 	if (typeof init == "undefined") {
        !             6: 		init = window;	// pass this window object by default
        !             7: 	}
        !             8: 	if (document.all) {	// here we hope that Mozilla will never support document.all
        !             9: 		var value =
        !            10: 			showModalDialog(url, init,
        !            11: //			window.open(url, '_blank',
        !            12: 					"resizable: no; help: no; status: no; scroll: no");
        !            13: 		if (action) {
        !            14: 			action(value);
        !            15: 		}
        !            16: 	} else {
        !            17: 		return Dialog._geckoOpenModal(url, action, init);
        !            18: 	}
        !            19: };
        !            20: 
        !            21: Dialog._parentEvent = function(ev) {
        !            22: 	if (Dialog._modal && !Dialog._modal.closed) {
        !            23: 		Dialog._modal.focus();
        !            24: 		// we get here in Mozilla only, anyway, so we can safely use
        !            25: 		// the DOM version.
        !            26: 		ev.preventDefault();
        !            27: 		ev.stopPropagation();
        !            28: 	}
        !            29: };
        !            30: 
        !            31: // should be a function, the return handler of the currently opened dialog.
        !            32: Dialog._return = null;
        !            33: 
        !            34: // constant, the currently opened dialog
        !            35: Dialog._modal = null;
        !            36: 
        !            37: // the dialog will read it's args from this variable
        !            38: Dialog._arguments = null;
        !            39: 
        !            40: Dialog._geckoOpenModal = function(url, action, init) {
        !            41: 	var dlg = window.open(url, "ha_dialog",
        !            42: 			      "toolbar=no,menubar=no,personalbar=no,width=10,height=10," +
        !            43: 			      "scrollbars=no,resizable=no");
        !            44: 	Dialog._modal = dlg;
        !            45: 	Dialog._arguments = init;
        !            46: 
        !            47: 	// capture some window's events
        !            48: 	function capwin(w) {
        !            49: 		w.addEventListener("click", Dialog._parentEvent, true);
        !            50: 		w.addEventListener("mousedown", Dialog._parentEvent, true);
        !            51: 		w.addEventListener("focus", Dialog._parentEvent, true);
        !            52: 	};
        !            53: 	// release the captured events
        !            54: 	function relwin(w) {
        !            55: 		w.removeEventListener("focus", Dialog._parentEvent, true);
        !            56: 		w.removeEventListener("mousedown", Dialog._parentEvent, true);
        !            57: 		w.removeEventListener("click", Dialog._parentEvent, true);
        !            58: 	};
        !            59: 	capwin(window);
        !            60: 	// capture other frames
        !            61: 	for (var i = 0; i < window.frames.length; capwin(window.frames[i++]));
        !            62: 	// make up a function to be called when the Dialog ends.
        !            63: 	Dialog._return = function (val) {
        !            64: 		if (val && action) {
        !            65: 			action(val);
        !            66: 		}
        !            67: 		relwin(window);
        !            68: 		// capture other frames
        !            69: 		for (var i = 0; i < window.frames.length; relwin(window.frames[i++]));
        !            70: 		Dialog._modal = null;
        !            71: 	};
        !            72: };

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