2 // Though "Dialog" looks like an object, it isn't really an object. Instead
3 // it's just namespace for protecting global symbols.
5 function Dialog(url, action, init) {
6 if (typeof init == "undefined") {
7 init = window; // pass this window object by default
9 Dialog._geckoOpenModal(url, action, init);
12 Dialog._parentEvent = function(ev) {
13 if (Dialog._modal && !Dialog._modal.closed) {
14 Dialog._modal.focus();
15 HTMLArea._stopEvent(ev);
19 // should be a function, the return handler of the currently opened dialog.
20 Dialog._return = null;
22 // constant, the currently opened dialog
25 // the dialog will read it's args from this variable
26 Dialog._arguments = null;
28 Dialog._geckoOpenModal = function(url, action, init) {
30 var file = url.substring(url.lastIndexOf('/') + 1, url.lastIndexOf('.'));
33 case "insert_image": x = 730; y = 560; break;
34 case "dlg_ins_smile": x = 330; y = 320; break;
35 case "dlg_ins_char": x = 480; y = 290; break;
36 case "select_color": x = 238; y = 195; break;
37 case "insert_table": x = 420; y = 250; break;
38 case "link_std": x = 420; y = 230; break;
39 case "insert_image_std": x = 450; y = 240; break;
40 case "createanchor": x = 300; y = 140; break;
41 case "searchandreplace": x = 400; y = 250; break;
42 default: x = 50; y = 50;
45 var lx = (screen.width - x) / 2;
46 var tx = (screen.height - y) / 2;
47 var dlg = window.open(url, "ha_dialog", "toolbar=no,menubar=no,personalbar=no, width="+ x +",height="+ y +",scrollbars=no,resizable=no, left="+ lx +", top="+ tx +"");
49 Dialog._arguments = init;
51 // capture some window's events
53 HTMLArea._addEvent(w, "click", Dialog._parentEvent);
54 HTMLArea._addEvent(w, "mousedown", Dialog._parentEvent);
55 HTMLArea._addEvent(w, "focus", Dialog._parentEvent);
57 // release the captured events
59 HTMLArea._removeEvent(w, "click", Dialog._parentEvent);
60 HTMLArea._removeEvent(w, "mousedown", Dialog._parentEvent);
61 HTMLArea._removeEvent(w, "focus", Dialog._parentEvent);
64 // capture other frames
66 for (var i = 0; i < window.frames.length; capwin(window.frames[i++]));
68 // make up a function to be called when the Dialog ends.
69 Dialog._return = function (val) {
71 // capture other frames
73 for (var i = 0; i < window.frames.length; relwin(window.frames[i++]));