This commit was generated by cvs2svn to compensate for changes in r4407,
[freeside.git] / httemplate / elements / qlib / messagebox.js
1 /**\r
2  * QLIB 1.0 Message Box Control\r
3  * Copyright (C) 2002 2003, Quazzle.com Serge Dolgov\r
4  * This program is free software; you can redistribute it and/or\r
5  * modify it under the terms of the GNU General Public License\r
6  * as published by the Free Software Foundation; either version 2\r
7  * of the License, or (at your option) any later version.\r
8  * http://qlib.quazzle.com\r
9  */\r
10 \r
11 function QMessageBox_alert(msg) {\r
12     if (typeof(msg) == "string") {\r
13         this.label.set(this.value = msg);\r
14     }\r
15     this.center();\r
16     this.focus();\r
17     this.show(true);\r
18 }\r
19 \r
20 function QMessageBox_close() {\r
21     with (this.parent) {\r
22         if (!onClose(tag)) show(false);\r
23     }\r
24 }\r
25 \r
26 function QMessageBox_body() {\r
27     with (this) {\r
28         document.write('<table border="0" width="' + cwidth + '"><tr><td align="left" valign="top" unselectable="on">');\r
29         this.label = new QLabel(this, "label", value);\r
30         document.write('</td></tr><tr><td height="' + (bres.height + 14) + '" align="center" valign="bottom" unselectable="on">');\r
31         this.button = new QButton(this, "button", bres, "Close");\r
32         document.write('</td></tr></table>');\r
33         button.onClick = QMessageBox_close;\r
34     }\r
35 }\r
36 \r
37 function QMessageBox(parent, name, box, btn, msg, effects, opacity) {\r
38     this.init(parent, name);\r
39     if ((this.res = box) && (this.bres = btn)) {\r
40         this.value = typeof(msg) == "string" ? msg : "";\r
41         this.width = Math.max(200, Math.floor(Math.sqrt(555 * this.value.length)));\r
42         this.height = null;\r
43         this.x = this.y = 0;\r
44         this.visible = false;\r
45         this.zindex = null;\r
46         this.body = QMessageBox_body;\r
47         var j = QMessageBox.arguments.length;\r
48         this.effects = j > 5 ? effects : (box.effects != null ? box.effects : 0);\r
49         this.opacity = j > 6 ? opacity : (box.opacity != null ? box.opacity : 100);\r
50         this.create();\r
51         this.alert = QMessageBox_alert;\r
52         this.onClose = QControl.event;\r
53     } else {\r
54         this.document.write("invalid resource");\r
55     }\r
56 }\r
57 QMessageBox.prototype = new QBoxCtrl();\r