1 // Copyright (C) 2005 Rod Roark <rod@sunsetsystems.com>
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License
5 // as published by the Free Software Foundation; either version 2
6 // of the License, or (at your option) any later version.
8 // open a new cascaded window
9 function cascwin(url, winname, width, height, options) {
10 var mywin = window.parent ? window.parent : window;
11 var newx = 25, newy = 25;
12 if (!isNaN(mywin.screenX)) {
13 newx += mywin.screenX;
14 newy += mywin.screenY;
15 } else if (!isNaN(mywin.screenLeft)) {
16 newx += mywin.screenLeft;
17 newy += mywin.screenTop;
19 if ((newx + width) > screen.width || (newy + height) > screen.height) {
25 // MS IE version detection taken from
26 // http://msdn2.microsoft.com/en-us/library/ms537509.aspx
27 // to adjust the height of this box for IE only -- JRM
28 if (navigator.appName == 'Microsoft Internet Explorer')
30 var ua = navigator.userAgent;
31 var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
32 if (re.exec(ua) != null)
33 rv = parseFloat( RegExp.$1 ); // this holds the version number
37 retval=window.open(url, winname, options +
38 ",width=" + width + ",height=" + height +
39 ",left=" + newx + ",top=" + newy +
40 ",screenX=" + newx + ",screenY=" + newy);
44 // recursive window focus-event grabber
45 function grabfocus(w) {
46 for (var i = 0; i < w.frames.length; ++i) grabfocus(w.frames[i]);
47 w.onfocus = top.imfocused;
49 // the following was tried and discarded because it's too invasive and
50 // does not help anyway, but i left it here for the curious.
52 // for (var i = 0; i < w.document.forms.length; ++i) {
53 // var e = w.document.forms[i].elements;
54 // for (var j = 0; j < e.length; ++j) {
55 // e[j].onfocus = top.imfocused;
60 // Call this when a "modal" dialog is desired.
61 // Note that the below function is used for the
62 // frames ui, and that a separate dlgopen function
63 // is used below (see if(top.tab_mode)...) for the tabs ui.
64 function dlgopen(url, winname, width, height) {
65 if (top.modaldialog && ! top.modaldialog.closed) {
66 if (window.focus) top.modaldialog.focus();
67 if (top.modaldialog.confirm(top.oemr_dialog_close_msg)) {
68 top.modaldialog.close();
69 top.modaldialog = null;
74 top.modaldialog = cascwin(url, winname, width, height,
75 "resizable=1,scrollbars=1,location=0,toolbar=0");
80 // This is called from del_related() which in turn is invoked by find_code_dynamic.php.
81 // Deletes the specified codetype:code from the indicated input text element.
82 function my_del_related(s, elem, usetitle) {
84 // Deleting everything.
91 // Convert the codes and their descriptions to arrays for easy manipulation.
92 var acodes = elem.value.split(';');
93 var i = acodes.indexOf(s);
95 return; // not found, should not happen
97 // Delete the indicated code and description and convert back to strings.
99 elem.value = acodes.join(';');
101 var atitles = elem.title.split(';');
102 atitles.splice(i, 1);
103 elem.title = atitles.join(';');
110 return Math.floor((1 + Math.random()) * 0x10000)
114 return s4() + s4() + s4() + s4() + s4() + + s4() + s4() + s4();
119 dlgOpenWindow=dlgopen;
120 dlgopen=function(url,winname,width,height,forceNewWindow)
122 top.restoreSession();
126 return dlgOpenWindow(url,winname,width,height);
137 fullURL=window.location.href.substr(0,window.location.href.lastIndexOf("/")+1)+url;
139 var dialogDiv=top.$("#dialogDiv");
141 if(winname!=="_blank")
143 dlgIframe=dialogDiv.find("iframe[name='"+winname+"']");
151 dlgIframe=top.$("<iframe></iframe>");
152 dlgIframe.attr("name",winname);
154 var dlgDivContainer=top.$("<div class='dialogIframe'></div>");
155 var closeDlg=top.$("<div class='closeDlgIframe'></div>");
156 dlgDivContainer.append(closeDlg);
157 closeDlg.click(function()
159 var body=top.$("body");
160 var closeItems=body.find("[name='"+winname+"']");
162 if(body.children("div.dialogIframe").length===0)
167 dlgDivContainer.attr("name",winname);
168 dlgDivContainer.append(dlgIframe);
169 dlgDivContainer.css({"left":(top.$("body").width()-width)/2
174 top.$("body").append(dlgDivContainer);
175 top.set_opener(winname,window);
176 dlgIframe.get(0).src=fullURL;