author | Dan |
Mon, 28 Jul 2008 13:01:53 -0600 | |
changeset 665 | af7e8ec6aef7 |
parent 582 | a38876c0793c |
child 677 | 2a263b598a2b |
permissions | -rw-r--r-- |
582
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
1 |
/** |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
2 |
* Darkens the browser screen. This will make the entire page un-clickable except for any floating divs created after this is called. Restore with enlighten(). |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
3 |
* @param bool Controls whether the fade should be disabled or not. aclDisableTransitionFX will override this if set to true, and fades are never fired on IE. |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
4 |
* @param int When specified, represents the numeric opacity value to set the fade layer to. 1-100. |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
5 |
*/ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
6 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
7 |
var darkener_index = 0; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
8 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
9 |
function darken(nofade, opacVal) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
10 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
11 |
if(IE) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
12 |
nofade = true; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
13 |
if ( !opacVal ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
14 |
opacVal = 70; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
15 |
darkener_index++; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
16 |
if(document.getElementById('specialLayer_darkener')) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
17 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
18 |
if(nofade) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
19 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
20 |
changeOpac(opacVal, 'specialLayer_darkener'); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
21 |
document.getElementById('specialLayer_darkener').style.display = 'block'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
22 |
document.getElementById('specialLayer_darkener').myOpacVal = opacVal; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
23 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
24 |
else |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
25 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
26 |
if ( document.getElementById('specialLayer_darkener').style.display != 'none' ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
27 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
28 |
var currentOpac = document.getElementById('specialLayer_darkener').myOpacVal; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
29 |
opacity('specialLayer_darkener', currentOpac, opacVal, 1000); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
30 |
document.getElementById('specialLayer_darkener').myOpacVal = opacVal; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
31 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
32 |
else |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
33 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
34 |
document.getElementById('specialLayer_darkener').style.display = 'block'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
35 |
document.getElementById('specialLayer_darkener').myOpacVal = opacVal; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
36 |
opacity('specialLayer_darkener', 0, opacVal, 1000); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
37 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
38 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
39 |
} else { |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
40 |
w = getWidth(); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
41 |
h = getHeight(); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
42 |
var thediv = document.createElement('div'); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
43 |
if(IE) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
44 |
thediv.style.position = 'absolute'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
45 |
else |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
46 |
thediv.style.position = 'fixed'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
47 |
if ( IE ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
48 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
49 |
var top = getScrollOffset(); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
50 |
thediv.style.top = String(top) + 'px'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
51 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
52 |
else |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
53 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
54 |
thediv.style.top = '0px'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
55 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
56 |
thediv.style.left = '0px'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
57 |
thediv.style.opacity = '0'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
58 |
thediv.style.filter = 'alpha(opacity=0)'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
59 |
thediv.style.backgroundColor = '#000000'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
60 |
thediv.style.width = '100%'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
61 |
thediv.style.height = '100%'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
62 |
thediv.zIndex = getHighestZ() + 5; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
63 |
thediv.id = 'specialLayer_darkener'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
64 |
thediv.myOpacVal = opacVal; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
65 |
if(nofade) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
66 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
67 |
thediv.style.opacity = ( parseFloat(opacVal) / 100 ); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
68 |
thediv.style.filter = 'alpha(opacity=' + opacVal + ')'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
69 |
body = document.getElementsByTagName('body'); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
70 |
body = body[0]; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
71 |
body.appendChild(thediv); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
72 |
} else { |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
73 |
body = document.getElementsByTagName('body'); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
74 |
body = body[0]; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
75 |
body.appendChild(thediv); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
76 |
opacity('specialLayer_darkener', 0, opacVal, 1000); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
77 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
78 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
79 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
80 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
81 |
/** |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
82 |
* Un-darkens the screen and re-enables clicking of on-screen controls. |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
83 |
* @param bool If true, disables the fade effect. Fades are always disabled if aclDisableTransitionFX is true and on IE. |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
84 |
*/ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
85 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
86 |
function enlighten(nofade) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
87 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
88 |
if(IE) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
89 |
nofade = true; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
90 |
darkener_index -= 1; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
91 |
if ( darkener_index > 0 ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
92 |
return false; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
93 |
if(document.getElementById('specialLayer_darkener')) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
94 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
95 |
if(nofade) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
96 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
97 |
document.getElementById('specialLayer_darkener').style.display = 'none'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
98 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
99 |
else |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
100 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
101 |
var from = document.getElementById('specialLayer_darkener').myOpacVal; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
102 |
// console.info('Fading from ' + from); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
103 |
opacity('specialLayer_darkener', from, 0, 1000); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
104 |
setTimeout("document.getElementById('specialLayer_darkener').style.display = 'none';", 1000); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
105 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
106 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
107 |
} |