2 function PopupWin(editor
, title
, handler
, initFunction
) {
4 this.handler
= handler
;
5 var dlg
= window
.open("", "__ha_dialog",
6 "toolbar=no,menubar=no,personalbar=no,width=600,height=600," +
7 "scrollbars=no,resizable=no");
9 var doc
= dlg
.document
;
13 var base
= document
.baseURI
|| document
.URL
;
14 if (base
&& base
.match(/(.*)\/([^\/]+)/)) {
15 base
= RegExp
.$1 + "/";
20 var html
= "<html><head><title>" + title
+ "</title>\n";
21 // html += "<base href='" + base + "htmlarea.js' />\n";
22 //html += "<style type='text/css'>@import url(" + base + "htmlarea.css);</style></head>\n";
23 html
+= "<style type='text/css'>@import url(../htmlarea.css);</style></head>\n";
24 html
+= "<body class='dialog popupwin' id='--HA-body'></body></html>";
28 // sometimes I Hate Mozilla... ;-(
32 setTimeout(init2
, 25);
36 doc
.documentElement
.style
.padding
= "0px";
37 doc
.documentElement
.style
.margin
= "0px";
38 var content
= doc
.createElement("div");
39 content
.className
= "content";
40 self
.content
= content
;
41 body
.appendChild(content
);
49 PopupWin
.prototype.callHandler = function() {
50 var tags
= ["input", "textarea", "select"];
51 var params
= new Object();
52 for (var ti
in tags
) {
54 var els
= this.content
.getElementsByTagName(tag
);
55 for (var j
= 0; j
< els
.length
; ++j
) {
58 if (el
.tagName
.toLowerCase() == "input") {
59 if (el
.type
== "checkbox") {
63 params
[el
.name
] = val
;
66 this.handler(this, params
);
70 PopupWin
.prototype.close = function() {
74 PopupWin
.prototype.addButtons = function() {
76 var div
= this.doc
.createElement("div");
77 this.content
.appendChild(div
);
78 div
.className
= "buttons";
79 for (var i
= 0; i
< arguments
.length
; ++i
) {
80 var btn
= arguments
[i
];
81 var button
= this.doc
.createElement("button");
82 div
.appendChild(button
);
83 button
.innerHTML
= HTMLArea
.I18N
.buttons
[btn
];
86 button
.onclick = function() {
93 button
.onclick = function() {
102 PopupWin
.prototype.showAtElement = function() {
104 // Mozilla needs some time to realize what's goin' on..
105 setTimeout(function() {
106 var w
= self
.content
.offsetWidth
+ 4;
107 var h
= self
.content
.offsetHeight
+ 4;
108 // size to content -- that's phuckin' buggy in all phuckin' browsers!!!
109 // so that we set a larger size for the dialog window and then center
110 // the element inside... phuck!
113 var el
= self
.content
;
115 // s.width = el.offsetWidth + "px";
116 // s.height = el.offsetHeight + "px";
117 s
.position
= "absolute";
118 s
.left
= (w
- el
.offsetWidth
) / 2 + "px";
119 s
.top
= (h
- el
.offsetHeight
) / 2 + "px";
120 if (HTMLArea
.is_gecko
) {
121 self
.window
.innerWidth
= w
;
122 self
.window
.innerHeight
= h
;
124 self
.window
.resizeTo(w
+ 8, h
+ 35);