author | Dan |
Thu, 26 Jun 2008 20:59:23 -0400 | |
changeset 297 | 4f0f987717c6 |
parent 259 | 112debff64bd |
child 343 | 7e6537fd4730 |
permissions | -rw-r--r-- |
1 | 1 |
// Message box system |
2 |
||
3 |
function darken(nofade) |
|
4 |
{ |
|
5 |
if(IE) |
|
6 |
nofade = true; |
|
7 |
if(document.getElementById('specialLayer_darkener')) |
|
8 |
{ |
|
9 |
document.getElementById('specialLayer_darkener').style.display = 'block'; |
|
10 |
if(nofade) |
|
11 |
{ |
|
12 |
document.getElementById('specialLayer_darkener').style.opacity = '0.7'; |
|
13 |
document.getElementById('specialLayer_darkener').style.filter = 'alpha(opacity=70)'; |
|
14 |
} |
|
15 |
else |
|
16 |
{ |
|
17 |
opacity('specialLayer_darkener', 0, 70, 1000); |
|
18 |
} |
|
19 |
} else { |
|
20 |
w = getWidth(); |
|
21 |
h = getHeight(); |
|
22 |
var thediv = document.createElement('div'); |
|
23 |
if(IE) |
|
24 |
thediv.style.position = 'absolute'; |
|
25 |
else |
|
26 |
thediv.style.position = 'fixed'; |
|
27 |
thediv.style.top = '0px'; |
|
28 |
thediv.style.left = '0px'; |
|
29 |
thediv.style.opacity = '0'; |
|
30 |
thediv.style.filter = 'alpha(opacity=0)'; |
|
31 |
thediv.style.backgroundColor = '#000000'; |
|
32 |
thediv.style.width = '100%'; |
|
33 |
thediv.style.height = '100%'; |
|
34 |
thediv.zIndex = getHighestZ() + 5; |
|
35 |
thediv.id = 'specialLayer_darkener'; |
|
36 |
if(nofade) |
|
37 |
{ |
|
38 |
thediv.style.opacity = '0.7'; |
|
39 |
thediv.style.filter = 'alpha(opacity=70)'; |
|
40 |
body = document.getElementsByTagName('body'); |
|
41 |
body = body[0]; |
|
42 |
body.appendChild(thediv); |
|
43 |
} else { |
|
44 |
body = document.getElementsByTagName('body'); |
|
45 |
body = body[0]; |
|
46 |
body.appendChild(thediv); |
|
47 |
opacity('specialLayer_darkener', 0, 70, 1000); |
|
48 |
} |
|
49 |
} |
|
50 |
} |
|
51 |
||
52 |
function enlighten(nofade) |
|
53 |
{ |
|
54 |
if(IE) |
|
55 |
nofade = true; |
|
56 |
if(document.getElementById('specialLayer_darkener')) |
|
57 |
{ |
|
58 |
if(nofade) |
|
59 |
{ |
|
60 |
document.getElementById('specialLayer_darkener').style.display = 'none'; |
|
61 |
} |
|
62 |
opacity('specialLayer_darkener', 70, 0, 1000); |
|
63 |
setTimeout("document.getElementById('specialLayer_darkener').style.display = 'none';", 1000); |
|
64 |
} |
|
65 |
} |
|
66 |
||
67 |
/** |
|
68 |
* The ultimate message box framework for Javascript |
|
69 |
* Syntax is (almost) identical to the MessageBox command in NSIS |
|
70 |
* @param int type - a bitfield consisting of the MB_* constants |
|
71 |
* @param string title - the blue text at the top of the window |
|
72 |
* @param string text - HTML for the body of the message box |
|
73 |
* Properties: |
|
74 |
* onclick - an array of functions to be called on button click events |
|
75 |
* NOTE: key names are to be strings, and they must be the value of the input, CaSe-SeNsItIvE |
|
76 |
* onbeforeclick - same as onclick but called before the messagebox div is destroyed |
|
259
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
150
diff
changeset
|
77 |
* Methods: |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
150
diff
changeset
|
78 |
* destroy: kills the running message box |
1 | 79 |
* Example: |
80 |
* var my_message = new messagebox(MB_OK|MB_ICONSTOP, 'Error logging in', 'The username and/or password is incorrect. Please check the username and retype your password'); |
|
81 |
* my_message.onclick['OK'] = function() { |
|
82 |
* document.getElementById('password').value = ''; |
|
83 |
* }; |
|
84 |
* Deps: |
|
85 |
* Modern browser that supports DOM |
|
86 |
* darken() and enlighten() (above) |
|
87 |
* opacity() - required for darken() and enlighten() |
|
88 |
* MB_* constants are defined in enano-lib-basic.js |
|
89 |
*/ |
|
90 |
||
91 |
var mb_current_obj; |
|
92 |
||
93 |
function messagebox(type, title, message) |
|
94 |
{ |
|
95 |
var y = getScrollOffset(); |
|
96 |
if(document.getElementById('messageBox')) return; |
|
97 |
darken(true); |
|
150
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
98 |
if ( aclDisableTransitionFX ) |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
99 |
{ |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
100 |
document.getElementById('specialLayer_darkener').style.zIndex = '5'; |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
101 |
} |
1 | 102 |
var master_div = document.createElement('div'); |
150
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
103 |
master_div.style.zIndex = '6'; |
1 | 104 |
var mydiv = document.createElement('div'); |
105 |
mydiv.style.width = '400px'; |
|
106 |
mydiv.style.height = '200px'; |
|
107 |
w = getWidth(); |
|
108 |
h = getHeight(); |
|
150
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
109 |
if ( aclDisableTransitionFX ) |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
110 |
{ |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
111 |
master_div.style.left = ((w / 2) - 200)+'px'; |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
112 |
master_div.style.top = ((h / 2) + y - 120)+'px'; |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
113 |
master_div.style.position = 'absolute'; |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
114 |
} |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
115 |
else |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
116 |
{ |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
117 |
master_div.style.top = '-10000px'; |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
118 |
master_div.style.position = ( IE ) ? 'absolute' : 'fixed'; |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
119 |
} |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
120 |
z = ( aclDisableTransitionFX ) ? document.getElementById('specialLayer_darkener').style.zIndex : getHighestZ(); |
1 | 121 |
mydiv.style.backgroundColor = '#FFFFFF'; |
122 |
mydiv.style.padding = '10px'; |
|
123 |
mydiv.style.marginBottom = '1px'; |
|
124 |
mydiv.id = 'messageBox'; |
|
125 |
mydiv.style.overflow = 'auto'; |
|
126 |
||
127 |
var buttondiv = document.createElement('div'); |
|
128 |
buttondiv.style.width = '400px'; |
|
129 |
w = getWidth(); |
|
130 |
h = getHeight(); |
|
150
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
131 |
if ( aclDisableTransitionFX ) |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
132 |
{ |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
133 |
//buttondiv.style.left = ((w / 2) - 200)+'px'; |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
134 |
//buttondiv.style.top = ((h / 2) + y + 101)+'px'; |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
135 |
} |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
136 |
//buttondiv.style.position = ( IE ) ? 'absolute' : 'fixed'; |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
137 |
z = ( aclDisableTransitionFX ) ? document.getElementById('specialLayer_darkener').style.zIndex : getHighestZ(); |
1 | 138 |
buttondiv.style.backgroundColor = '#C0C0C0'; |
139 |
buttondiv.style.padding = '10px'; |
|
140 |
buttondiv.style.textAlign = 'right'; |
|
141 |
buttondiv.style.verticalAlign = 'middle'; |
|
142 |
buttondiv.id = 'messageBoxButtons'; |
|
143 |
||
144 |
this.clickHandler = function() { messagebox_click(this, mb_current_obj); }; |
|
145 |
||
38 | 146 |
if( ( type & MB_ICONINFORMATION || type & MB_ICONSTOP || type & MB_ICONQUESTION || type & MB_ICONEXCLAMATION ) && !(type & MB_ICONLOCK) ) |
1 | 147 |
{ |
148 |
mydiv.style.paddingLeft = '50px'; |
|
149 |
mydiv.style.width = '360px'; |
|
150 |
mydiv.style.backgroundRepeat = 'no-repeat'; |
|
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
1
diff
changeset
|
151 |
mydiv.style.backgroundPosition = '8px 8px'; |
1 | 152 |
} |
38 | 153 |
else if ( type & MB_ICONLOCK ) |
154 |
{ |
|
155 |
mydiv.style.paddingLeft = '50px'; |
|
156 |
mydiv.style.width = '360px'; |
|
157 |
mydiv.style.backgroundRepeat = 'no-repeat'; |
|
158 |
} |
|
1 | 159 |
|
160 |
if(type & MB_ICONINFORMATION) |
|
161 |
{ |
|
162 |
mydiv.style.backgroundImage = 'url(\''+scriptPath+'/images/info.png\')'; |
|
163 |
} |
|
164 |
||
165 |
if(type & MB_ICONQUESTION) |
|
166 |
{ |
|
167 |
mydiv.style.backgroundImage = 'url(\''+scriptPath+'/images/question.png\')'; |
|
168 |
} |
|
169 |
||
170 |
if(type & MB_ICONSTOP) |
|
171 |
{ |
|
172 |
mydiv.style.backgroundImage = 'url(\''+scriptPath+'/images/error.png\')'; |
|
173 |
} |
|
174 |
||
175 |
if(type & MB_ICONEXCLAMATION) |
|
176 |
{ |
|
177 |
mydiv.style.backgroundImage = 'url(\''+scriptPath+'/images/warning.png\')'; |
|
178 |
} |
|
179 |
||
180 |
if(type & MB_ICONLOCK) |
|
181 |
{ |
|
182 |
mydiv.style.backgroundImage = 'url(\''+scriptPath+'/images/lock.png\')'; |
|
183 |
} |
|
184 |
||
185 |
if(type & MB_OK) |
|
186 |
{ |
|
187 |
btn = document.createElement('input'); |
|
188 |
btn.type = 'button'; |
|
189 |
btn.value = 'OK'; |
|
190 |
btn.onclick = this.clickHandler; |
|
191 |
btn.style.margin = '0 3px'; |
|
192 |
buttondiv.appendChild(btn); |
|
193 |
} |
|
194 |
||
195 |
if(type & MB_OKCANCEL) |
|
196 |
{ |
|
197 |
btn = document.createElement('input'); |
|
198 |
btn.type = 'button'; |
|
199 |
btn.value = 'OK'; |
|
200 |
btn.onclick = this.clickHandler; |
|
201 |
btn.style.margin = '0 3px'; |
|
202 |
buttondiv.appendChild(btn); |
|
203 |
||
204 |
btn = document.createElement('input'); |
|
205 |
btn.type = 'button'; |
|
206 |
btn.value = 'Cancel'; |
|
207 |
btn.onclick = this.clickHandler; |
|
208 |
btn.style.margin = '0 3px'; |
|
209 |
buttondiv.appendChild(btn); |
|
210 |
} |
|
211 |
||
212 |
if(type & MB_YESNO) |
|
213 |
{ |
|
214 |
btn = document.createElement('input'); |
|
215 |
btn.type = 'button'; |
|
216 |
btn.value = 'Yes'; |
|
217 |
btn.onclick = this.clickHandler; |
|
218 |
btn.style.margin = '0 3px'; |
|
219 |
buttondiv.appendChild(btn); |
|
220 |
||
221 |
btn = document.createElement('input'); |
|
222 |
btn.type = 'button'; |
|
223 |
btn.value = 'No'; |
|
224 |
btn.onclick = this.clickHandler; |
|
225 |
btn.style.margin = '0 3px'; |
|
226 |
buttondiv.appendChild(btn); |
|
227 |
} |
|
228 |
||
229 |
if(type & MB_YESNOCANCEL) |
|
230 |
{ |
|
231 |
btn = document.createElement('input'); |
|
232 |
btn.type = 'button'; |
|
233 |
btn.value = 'Yes'; |
|
234 |
btn.onclick = this.clickHandler; |
|
235 |
btn.style.margin = '0 3px'; |
|
236 |
buttondiv.appendChild(btn); |
|
237 |
||
238 |
btn = document.createElement('input'); |
|
239 |
btn.type = 'button'; |
|
240 |
btn.value = 'No'; |
|
241 |
btn.onclick = this.clickHandler; |
|
242 |
btn.style.margin = '0 3px'; |
|
243 |
buttondiv.appendChild(btn); |
|
244 |
||
245 |
btn = document.createElement('input'); |
|
246 |
btn.type = 'button'; |
|
247 |
btn.value = 'Cancel'; |
|
248 |
btn.onclick = this.clickHandler; |
|
249 |
btn.style.margin = '0 3px'; |
|
250 |
buttondiv.appendChild(btn); |
|
251 |
} |
|
252 |
||
253 |
heading = document.createElement('h2'); |
|
254 |
heading.innerHTML = title; |
|
255 |
heading.style.color = '#50A0D0'; |
|
256 |
heading.style.fontFamily = 'trebuchet ms, verdana, arial, helvetica, sans-serif'; |
|
257 |
heading.style.fontSize = '12pt'; |
|
258 |
heading.style.fontWeight = 'lighter'; |
|
259 |
heading.style.textTransform = 'lowercase'; |
|
260 |
heading.style.marginTop = '0'; |
|
261 |
mydiv.appendChild(heading); |
|
262 |
||
263 |
var text = document.createElement('div'); |
|
264 |
text.innerHTML = String(message); |
|
265 |
this.text_area = text; |
|
266 |
mydiv.appendChild(text); |
|
267 |
||
268 |
this.updateContent = function(text) |
|
269 |
{ |
|
270 |
this.text_area.innerHTML = text; |
|
271 |
}; |
|
259
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
150
diff
changeset
|
272 |
|
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
150
diff
changeset
|
273 |
this.destroy = function() |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
150
diff
changeset
|
274 |
{ |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
150
diff
changeset
|
275 |
var mbdiv = document.getElementById('messageBox'); |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
150
diff
changeset
|
276 |
mbdiv.parentNode.removeChild(mbdiv.nextSibling); |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
150
diff
changeset
|
277 |
mbdiv.parentNode.removeChild(mbdiv); |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
150
diff
changeset
|
278 |
enlighten(true); |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
150
diff
changeset
|
279 |
}; |
1 | 280 |
|
281 |
//domObjChangeOpac(0, mydiv); |
|
282 |
//domObjChangeOpac(0, master_div); |
|
283 |
||
284 |
body = document.getElementsByTagName('body'); |
|
285 |
body = body[0]; |
|
286 |
master_div.appendChild(mydiv); |
|
287 |
master_div.appendChild(buttondiv); |
|
288 |
||
289 |
body.appendChild(master_div); |
|
290 |
||
150
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
291 |
if ( !aclDisableTransitionFX ) |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
292 |
setTimeout('mb_runFlyIn();', 100); |
1 | 293 |
|
294 |
this.onclick = new Array(); |
|
295 |
this.onbeforeclick = new Array(); |
|
296 |
mb_current_obj = this; |
|
297 |
} |
|
298 |
||
299 |
function mb_runFlyIn() |
|
300 |
{ |
|
301 |
var mydiv = document.getElementById('messageBox'); |
|
302 |
var maindiv = mydiv.parentNode; |
|
303 |
fly_in_top(maindiv, true, false); |
|
304 |
} |
|
305 |
||
306 |
function messagebox_click(obj, mb) |
|
307 |
{ |
|
308 |
val = obj.value; |
|
309 |
if(typeof mb.onbeforeclick[val] == 'function') |
|
310 |
{ |
|
311 |
var o = mb.onbeforeclick[val]; |
|
312 |
var resp = o(); |
|
313 |
if ( resp ) |
|
314 |
return false; |
|
315 |
o = false; |
|
316 |
} |
|
317 |
||
318 |
var mydiv = document.getElementById('messageBox'); |
|
319 |
var maindiv = mydiv.parentNode; |
|
320 |
||
150
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
321 |
if ( aclDisableTransitionFX ) |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
322 |
{ |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
323 |
var mbdiv = document.getElementById('messageBox'); |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
324 |
mbdiv.parentNode.removeChild(mbdiv.nextSibling); |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
325 |
mbdiv.parentNode.removeChild(mbdiv); |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
326 |
enlighten(true); |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
327 |
} |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
328 |
else |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
329 |
{ |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
330 |
var to = fly_out_top(maindiv, true, false); |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
331 |
setTimeout("var mbdiv = document.getElementById('messageBox'); mbdiv.parentNode.removeChild(mbdiv.nextSibling); mbdiv.parentNode.removeChild(mbdiv); enlighten(true);", to); |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
53
diff
changeset
|
332 |
} |
1 | 333 |
if(typeof mb.onclick[val] == 'function') |
334 |
{ |
|
335 |
o = mb.onclick[val]; |
|
336 |
o(); |
|
337 |
o = false; |
|
338 |
} |
|
339 |
} |
|
340 |
||
341 |
function testMessageBox() |
|
342 |
{ |
|
343 |
mb = new messagebox(MB_OKCANCEL|MB_ICONINFORMATION, 'Javascripted dynamic message boxes', 'This is soooooo coool, now if only document.createElement() worked in IE!<br />this is some more text<br /><br /><br /><br /><br />this is some more text<br /><br /><br /><br /><br />this is some more text<br /><br /><br /><br /><br />this is some more text<br /><br /><br /><br /><br />this is some more text<br /><br /><br /><br /><br />this is some more text<br /><br /><br /><br /><br />this is some more text<br /><br /><br /><br /><br />this is some more text'); |
|
344 |
mb.onclick['OK'] = function() |
|
345 |
{ |
|
346 |
alert('You clicked OK!'); |
|
347 |
} |
|
348 |
mb.onbeforeclick['Cancel'] = function() |
|
349 |
{ |
|
350 |
alert('You clicked Cancel!'); |
|
351 |
} |
|
352 |
} |
|
353 |
||
354 |
// Function to fade classes info-box, warning-box, error-box, etc. |
|
355 |
||
356 |
function fadeInfoBoxes() |
|
357 |
{ |
|
358 |
var divs = new Array(); |
|
359 |
d = document.getElementsByTagName('div'); |
|
360 |
j = 0; |
|
361 |
for(var i in d) |
|
362 |
{ |
|
363 |
if ( !d[i].tagName ) |
|
364 |
continue; |
|
365 |
if(d[i].className=='info-box' || d[i].className=='error-box' || d[i].className=='warning-box' || d[i].className=='question-box') |
|
366 |
{ |
|
367 |
divs[j] = d[i]; |
|
368 |
j++; |
|
369 |
} |
|
370 |
} |
|
371 |
if(divs.length < 1) return; |
|
372 |
for(i in divs) |
|
373 |
{ |
|
374 |
if(!divs[i].id) divs[i].id = 'autofade_'+Math.floor(Math.random() * 100000); |
|
375 |
switch(divs[i].className) |
|
376 |
{ |
|
377 |
case 'info-box': |
|
378 |
default: |
|
379 |
from = '#3333FF'; |
|
380 |
break; |
|
381 |
case 'error-box': |
|
382 |
from = '#FF3333'; |
|
383 |
break; |
|
384 |
case 'warning-box': |
|
385 |
from = '#FFFF33'; |
|
386 |
break; |
|
387 |
case 'question-box': |
|
388 |
from = '#33FF33'; |
|
389 |
break; |
|
390 |
} |
|
391 |
Fat.fade_element(divs[i].id,30,2000,from,Fat.get_bgcolor(divs[i].id)); |
|
392 |
} |
|
393 |
} |
|
394 |
||
395 |
// Alpha fades |
|
396 |
||
397 |
function opacity(id, opacStart, opacEnd, millisec) { |
|
398 |
//speed for each frame |
|
399 |
var speed = Math.round(millisec / 100); |
|
400 |
var timer = 0; |
|
401 |
||
402 |
//determine the direction for the blending, if start and end are the same nothing happens |
|
403 |
if(opacStart > opacEnd) { |
|
404 |
for(i = opacStart; i >= opacEnd; i--) { |
|
405 |
setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); |
|
406 |
timer++; |
|
407 |
} |
|
408 |
} else if(opacStart < opacEnd) { |
|
409 |
for(i = opacStart; i <= opacEnd; i++) |
|
410 |
{ |
|
411 |
setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); |
|
412 |
timer++; |
|
413 |
} |
|
414 |
} |
|
415 |
} |
|
416 |
||
53 | 417 |
var opacityDOMCache = new Object(); |
418 |
function domOpacity(obj, opacStart, opacEnd, millisec) { |
|
419 |
//speed for each frame |
|
420 |
var speed = Math.round(millisec / 100); |
|
421 |
var timer = 0; |
|
422 |
||
423 |
// unique ID for this animation |
|
424 |
var uniqid = Math.floor(Math.random() * 1000000); |
|
425 |
opacityDOMCache[uniqid] = obj; |
|
426 |
||
427 |
//determine the direction for the blending, if start and end are the same nothing happens |
|
428 |
if(opacStart > opacEnd) { |
|
429 |
for(i = opacStart; i >= opacEnd; i--) { |
|
430 |
setTimeout("var obj = opacityDOMCache["+uniqid+"]; domObjChangeOpac(" + i + ",obj)",(timer * speed)); |
|
431 |
timer++; |
|
432 |
} |
|
433 |
} else if(opacStart < opacEnd) { |
|
434 |
for(i = opacStart; i <= opacEnd; i++) |
|
435 |
{ |
|
436 |
setTimeout("var obj = opacityDOMCache["+uniqid+"]; domObjChangeOpac(" + i + ",obj)",(timer * speed)); |
|
437 |
timer++; |
|
438 |
} |
|
439 |
} |
|
440 |
setTimeout("delete(opacityDOMCache["+uniqid+"]);",(timer * speed)); |
|
441 |
} |
|
442 |
||
1 | 443 |
//change the opacity for different browsers |
444 |
function changeOpac(opacity, id) { |
|
445 |
var object = document.getElementById(id).style; |
|
446 |
object.opacity = (opacity / 100); |
|
447 |
object.MozOpacity = (opacity / 100); |
|
448 |
object.KhtmlOpacity = (opacity / 100); |
|
449 |
object.filter = "alpha(opacity=" + opacity + ")"; |
|
450 |
} |
|
451 |
||
452 |
function mb_logout() |
|
453 |
{ |
|
454 |
var mb = new messagebox(MB_YESNO|MB_ICONQUESTION, 'Are you sure you want to log out?', 'If you log out, you will no longer be able to access your user preferences, your private messages, or certain areas of this site until you log in again.'); |
|
455 |
mb.onclick['Yes'] = function() |
|
456 |
{ |
|
457 |
window.location = makeUrlNS('Special', 'Logout/' + title); |
|
458 |
} |
|
459 |
} |
|
460 |