No regular expressions were active.
1 |
|
/**
|
|
1 |
|
/**
|
2 |
|
*
$Id:
mclayer.js
16
2
200
7
-01-0
3
16:
16
:
5
2Z
spocke
$
|
|
2 |
|
*
$Id:
mclayer.js
5
2
0
200
8
-01-0
7
16:
30
:
3
2Z
spocke
$
|
3 |
|
*
|
|
3 |
|
*
|
4 |
|
* Moxieco
de floatin
g layer sc
ript.
|
|
4 |
|
* Moxieco
de floatin
g layer sc
ript.
|
5 |
|
*
|
|
5 |
|
*
|
6 |
|
* @author
Moxiecode
|
|
6 |
|
* @author
Moxiecode
|
7 |
|
*
@copyright
Copyright
©
2004-200
7
,
Moxiecode
Systems
AB,
All
rights
reserved.
|
|
7 |
|
*
@copyright
Copyright
©
2004-200
8
,
Moxiecode
Systems
AB,
All
rights
reserved.
|
8 |
|
*/
|
|
8 |
|
*/
|
9 |
|
|
|
9 |
|
|
10 |
|
function M
CLayer(id)
{
|
|
10 |
|
function M
CLayer(id)
{
|
11 |
|
this.i
d = id;
|
|
11 |
|
this.i
d = id;
|
12 |
|
this.s
ettings =
new Array(
);
|
|
12 |
|
this.s
ettings =
new Array(
);
|
13 |
|
this.b
lockerElem
ent = null
;
|
|
13 |
|
this.b
lockerElem
ent = null
;
|
14 |
|
this.i
sMSIE = na
vigator.ap
pName == "
Microsoft
Internet E
xplorer";
|
|
14 |
|
this.i
sMSIE = na
vigator.ap
pName == "
Microsoft
Internet E
xplorer";
|
15 |
|
this.e
vents = fa
lse;
|
|
15 |
|
this.e
vents = fa
lse;
|
16 |
|
this.a
utoHideCal
lback = nu
ll;
|
|
16 |
|
this.a
utoHideCal
lback = nu
ll;
|
17 |
|
}
|
|
17 |
|
}
|
18 |
|
|
|
18 |
|
|
19 |
|
MCLayer.pr
ototype =
{
|
|
19 |
|
MCLayer.pr
ototype =
{
|
20 |
|
moveRe
lativeTo :
function(
re, p, a)
{
|
|
20 |
|
moveRe
lativeTo :
function(
re, p, a)
{
|
21 |
|
va
r rep = th
is.getAbsP
osition(re
);
|
|
21 |
|
va
r rep = th
is.getAbsP
osition(re
);
|
22 |
|
va
r w = pars
eInt(re.of
fsetWidth)
;
|
|
22 |
|
va
r w = pars
eInt(re.of
fsetWidth)
;
|
23 |
|
va
r h = pars
eInt(re.of
fsetHeight
);
|
|
23 |
|
va
r h = pars
eInt(re.of
fsetHeight
);
|
24 |
|
va
r x, y;
|
|
24 |
|
va
r x, y;
|
25 |
|
|
|
25 |
|
|
26 |
|
sw
itch (p) {
|
|
26 |
|
sw
itch (p) {
|
27 |
|
case "tl
":
|
|
27 |
|
case "tl
":
|
28 |
|
brea
k;
|
|
28 |
|
brea
k;
|
29 |
|
|
|
29 |
|
|
30 |
|
case "tr
":
|
|
30 |
|
case "tr
":
|
31 |
|
x =
rep.absLef
t + w;
|
|
31 |
|
x =
rep.absLef
t + w;
|
32 |
|
y =
rep.absTop
;
|
|
32 |
|
y =
rep.absTop
;
|
33 |
|
brea
k;
|
|
33 |
|
brea
k;
|
34 |
|
|
|
34 |
|
|
35 |
|
case "bl
":
|
|
35 |
|
case "bl
":
|
36 |
|
brea
k;
|
|
36 |
|
brea
k;
|
37 |
|
|
|
37 |
|
|
38 |
|
case "br
":
|
|
38 |
|
case "br
":
|
39 |
|
brea
k;
|
|
39 |
|
brea
k;
|
40 |
|
}
|
|
40 |
|
}
|
41 |
|
|
|
41 |
|
|
42 |
|
th
is.moveTo(
x, y);
|
|
42 |
|
th
is.moveTo(
x, y);
|
43 |
|
},
|
|
43 |
|
},
|
44 |
|
|
|
44 |
|
|
45 |
|
moveBy
: functio
n(dx, dy)
{
|
|
45 |
|
moveBy
: functio
n(dx, dy)
{
|
46 |
|
va
r e = this
.getElemen
t();
|
|
46 |
|
va
r e = this
.getElemen
t();
|
47 |
|
va
r x = pars
eInt(e.sty
le.left);
|
|
47 |
|
va
r x = pars
eInt(e.sty
le.left);
|
48 |
|
va
r y = pars
eInt(e.sty
le.top);
|
|
48 |
|
va
r y = pars
eInt(e.sty
le.top);
|
49 |
|
|
|
49 |
|
|
50 |
|
e.
style.left
= (x + dx
) + "px";
|
|
50 |
|
e.
style.left
= (x + dx
) + "px";
|
51 |
|
e.
style.top
= (y + dy)
+ "px";
|
|
51 |
|
e.
style.top
= (y + dy)
+ "px";
|
52 |
|
|
|
52 |
|
|
53 |
|
th
is.updateB
locker();
|
|
53 |
|
th
is.updateB
locker();
|
54 |
|
},
|
|
54 |
|
},
|
55 |
|
|
|
55 |
|
|
56 |
|
moveTo
: functio
n(x, y) {
|
|
56 |
|
moveTo
: functio
n(x, y) {
|
57 |
|
va
r e = this
.getElemen
t();
|
|
57 |
|
va
r e = this
.getElemen
t();
|
58 |
|
|
|
58 |
|
|
59 |
|
e.
style.left
= x + "px
";
|
|
59 |
|
e.
style.left
= x + "px
";
|
60 |
|
e.
style.top
= y + "px"
;
|
|
60 |
|
e.
style.top
= y + "px"
;
|
61 |
|
|
|
61 |
|
|
62 |
|
th
is.updateB
locker();
|
|
62 |
|
th
is.updateB
locker();
|
63 |
|
},
|
|
63 |
|
},
|
64 |
|
|
|
64 |
|
|
65 |
|
show :
function(
) {
|
|
65 |
|
show :
function(
) {
|
66 |
|
MC
Layer.visi
bleLayer =
this;
|
|
66 |
|
MC
Layer.visi
bleLayer =
this;
|
67 |
|
|
|
67 |
|
|
68 |
|
th
is.getElem
ent().styl
e.display
= 'block';
|
|
68 |
|
th
is.getElem
ent().styl
e.display
= 'block';
|
69 |
|
th
is.updateB
locker();
|
|
69 |
|
th
is.updateB
locker();
|
70 |
|
},
|
|
70 |
|
},
|
71 |
|
|
|
71 |
|
|
72 |
|
hide :
function(
) {
|
|
72 |
|
hide :
function(
) {
|
73 |
|
th
is.getElem
ent().styl
e.display
= 'none';
|
|
73 |
|
th
is.getElem
ent().styl
e.display
= 'none';
|
74 |
|
th
is.updateB
locker();
|
|
74 |
|
th
is.updateB
locker();
|
75 |
|
},
|
|
75 |
|
},
|
76 |
|
|
|
76 |
|
|
77 |
|
setAut
oHide : fu
nction(s,
cb) {
|
|
77 |
|
setAut
oHide : fu
nction(s,
cb) {
|
78 |
|
th
is.autoHid
eCallback
= cb;
|
|
78 |
|
th
is.autoHid
eCallback
= cb;
|
79 |
|
th
is.registe
rEventHand
lers();
|
|
79 |
|
th
is.registe
rEventHand
lers();
|
80 |
|
},
|
|
80 |
|
},
|
81 |
|
|
|
81 |
|
|
82 |
|
getEle
ment : fun
ction() {
|
|
82 |
|
getEle
ment : fun
ction() {
|
83 |
|
re
turn docum
ent.getEle
mentById(t
his.id);
|
|
83 |
|
re
turn docum
ent.getEle
mentById(t
his.id);
|
84 |
|
},
|
|
84 |
|
},
|
85 |
|
|
|
85 |
|
|
86 |
|
update
Blocker :
function()
{
|
|
86 |
|
update
Blocker :
function()
{
|
87 |
|
if
(!this.is
MSIE)
|
|
87 |
|
if
(!this.is
MSIE)
|
88 |
|
return;
|
|
88 |
|
return;
|
89 |
|
|
|
89 |
|
|
90 |
|
va
r e = this
.getElemen
t();
|
|
90 |
|
va
r e = this
.getElemen
t();
|
91 |
|
va
r b = this
.getBlocke
r();
|
|
91 |
|
va
r b = this
.getBlocke
r();
|
92 |
|
va
r x = this
.parseInt(
e.style.le
ft);
|
|
92 |
|
va
r x = this
.parseInt(
e.style.le
ft);
|
93 |
|
va
r y = this
.parseInt(
e.style.to
p);
|
|
93 |
|
va
r y = this
.parseInt(
e.style.to
p);
|
94 |
|
va
r w = this
.parseInt(
e.offsetWi
dth);
|
|
94 |
|
va
r w = this
.parseInt(
e.offsetWi
dth);
|
95 |
|
va
r h = this
.parseInt(
e.offsetHe
ight);
|
|
95 |
|
va
r h = this
.parseInt(
e.offsetHe
ight);
|
96 |
|
|
|
96 |
|
|
97 |
|
b.
style.left
= x + 'px
';
|
|
97 |
|
b.
style.left
= x + 'px
';
|
98 |
|
b.
style.top
= y + 'px'
;
|
|
98 |
|
b.
style.top
= y + 'px'
;
|
99 |
|
b.
style.widt
h = w + 'p
x';
|
|
99 |
|
b.
style.widt
h = w + 'p
x';
|
100 |
|
b.
style.heig
ht = h + '
px';
|
|
100 |
|
b.
style.heig
ht = h + '
px';
|
101 |
|
b.
style.disp
lay = e.st
yle.displa
y;
|
|
101 |
|
b.
style.disp
lay = e.st
yle.displa
y;
|
102 |
|
},
|
|
102 |
|
},
|
103 |
|
|
|
103 |
|
|
104 |
|
getBlo
cker : fun
ction() {
|
|
104 |
|
getBlo
cker : fun
ction() {
|
105 |
|
if
(!this.bl
ockerEleme
nt) {
|
|
105 |
|
if
(!this.bl
ockerEleme
nt) {
|
106 |
|
var d =
document,
b = d.crea
teElement(
"iframe");
|
|
106 |
|
var d =
document,
b = d.crea
teElement(
"iframe");
|
107 |
|
|
|
107 |
|
|
108 |
|
b.style.
cssText =
'display:
none; left
: 0px; pos
ition: abs
olute; top
: 0';
|
|
108 |
|
b.style.
cssText =
'display:
none; left
: 0px; pos
ition: abs
olute; top
: 0';
|
109 |
|
b.src =
'javascrip
t:false;';
|
|
109 |
|
b.src =
'javascrip
t:false;';
|
110 |
|
b.frameB
order = '0
';
|
|
110 |
|
b.frameB
order = '0
';
|
111 |
|
b.scroll
ing = 'no'
;
|
|
111 |
|
b.scroll
ing = 'no'
;
|
112 |
|
|
|
112 |
|
|
113 |
|
d.body.a
ppendChild
(b);
|
|
113 |
|
d.body.a
ppendChild
(b);
|
114 |
|
this.blo
ckerElemen
t = b;
|
|
114 |
|
this.blo
ckerElemen
t = b;
|
115 |
|
}
|
|
115 |
|
}
|
116 |
|
|
|
116 |
|
|
117 |
|
re
turn this.
blockerEle
ment;
|
|
117 |
|
re
turn this.
blockerEle
ment;
|
118 |
|
},
|
|
118 |
|
},
|
119 |
|
|
|
119 |
|
|
120 |
|
getAbs
Position :
function(
n) {
|
|
120 |
|
getAbs
Position :
function(
n) {
|
121 |
|
va
r p = {abs
Left : 0,
absTop : 0
};
|
|
121 |
|
va
r p = {abs
Left : 0,
absTop : 0
};
|
122 |
|
|
|
122 |
|
|
123 |
|
wh
ile (n) {
|
|
123 |
|
wh
ile (n) {
|
124 |
|
p.absLef
t += n.off
setLeft;
|
|
124 |
|
p.absLef
t += n.off
setLeft;
|
125 |
|
p.absTop
+= n.offs
etTop;
|
|
125 |
|
p.absTop
+= n.offs
etTop;
|
126 |
|
n = n.of
fsetParent
;
|
|
126 |
|
n = n.of
fsetParent
;
|
127 |
|
}
|
|
127 |
|
}
|
128 |
|
|
|
128 |
|
|
129 |
|
re
turn p;
|
|
129 |
|
re
turn p;
|
130 |
|
},
|
|
130 |
|
},
|
131 |
|
|
|
131 |
|
|
132 |
|
regist
erEventHan
dlers : fu
nction() {
|
|
132 |
|
regist
erEventHan
dlers : fu
nction() {
|
133 |
|
if
(!this.ev
ents) {
|
|
133 |
|
if
(!this.ev
ents) {
|
134 |
|
var d =
document;
|
|
134 |
|
var d =
document;
|
135 |
|
|
|
135 |
|
|
136 |
|
this.add
Event(d, '
mousedown'
, MCLayer.
prototype.
onMouseDow
n);
|
|
136 |
|
this.add
Event(d, '
mousedown'
, MCLayer.
prototype.
onMouseDow
n);
|
137 |
|
|
|
137 |
|
|
138 |
|
this.eve
nts = true
;
|
|
138 |
|
this.eve
nts = true
;
|
139 |
|
}
|
|
139 |
|
}
|
140 |
|
},
|
|
140 |
|
},
|
141 |
|
|
|
141 |
|
|
142 |
|
addEve
nt : funct
ion(o, n,
h) {
|
|
142 |
|
addEve
nt : funct
ion(o, n,
h) {
|
143 |
|
if
(o.attach
Event)
|
|
143 |
|
if
(o.attach
Event)
|
144 |
|
o.attach
Event("on"
+ n, h);
|
|
144 |
|
o.attach
Event("on"
+ n, h);
|
145 |
|
el
se
|
|
145 |
|
el
se
|
146 |
|
o.addEve
ntListener
(n, h, fal
se);
|
|
146 |
|
o.addEve
ntListener
(n, h, fal
se);
|
147 |
|
},
|
|
147 |
|
},
|
148 |
|
|
|
148 |
|
|
149 |
|
onMous
eDown : fu
nction(e)
{
|
|
149 |
|
onMous
eDown : fu
nction(e)
{
|
150 |
|
e
= typeof(e
) == "unde
fined" ? w
indow.even
t : e;
|
|
150 |
|
e
= typeof(e
) == "unde
fined" ? w
indow.even
t : e;
|
151 |
|
va
r b = docu
ment.body;
|
|
151 |
|
va
r b = docu
ment.body;
|
152 |
|
va
r l = MCLa
yer.visibl
eLayer;
|
|
152 |
|
va
r l = MCLa
yer.visibl
eLayer;
|
153 |
|
|
|
153 |
|
|
154 |
|
if
(l) {
|
|
154 |
|
if
(l) {
|
155 |
|
var mx =
l.isMSIE
? e.client
X + b.scro
llLeft : e
.pageX;
|
|
155 |
|
var mx =
l.isMSIE
? e.client
X + b.scro
llLeft : e
.pageX;
|
156 |
|
var my =
l.isMSIE
? e.client
Y + b.scro
llTop : e.
pageY;
|
|
156 |
|
var my =
l.isMSIE
? e.client
Y + b.scro
llTop : e.
pageY;
|
157 |
|
var el =
l.getElem
ent();
|
|
157 |
|
var el =
l.getElem
ent();
|
158 |
|
var x =
parseInt(e
l.style.le
ft);
|
|
158 |
|
var x =
parseInt(e
l.style.le
ft);
|
159 |
|
var y =
parseInt(e
l.style.to
p);
|
|
159 |
|
var y =
parseInt(e
l.style.to
p);
|
160 |
|
var w =
parseInt(e
l.offsetWi
dth);
|
|
160 |
|
var w =
parseInt(e
l.offsetWi
dth);
|
161 |
|
var h =
parseInt(e
l.offsetHe
ight);
|
|
161 |
|
var h =
parseInt(e
l.offsetHe
ight);
|
162 |
|
|
|
162 |
|
|
163 |
|
if (!(mx
> x && mx
< x + w &
& my > y &
& my < y +
h)) {
|
|
163 |
|
if (!(mx
> x && mx
< x + w &
& my > y &
& my < y +
h)) {
|
164 |
|
MCLa
yer.visibl
eLayer = n
ull;
|
|
164 |
|
MCLa
yer.visibl
eLayer = n
ull;
|
165 |
|
|
|
165 |
|
|
166 |
|
if (
l.autoHide
Callback &
& l.autoHi
deCallback
(l, e, mx,
my))
|
|
166 |
|
if (
l.autoHide
Callback &
& l.autoHi
deCallback
(l, e, mx,
my))
|
167 |
|
return tru
e;
|
|
167 |
|
return tru
e;
|
168 |
|
|
|
168 |
|
|
169 |
|
l.hi
de();
|
|
169 |
|
l.hi
de();
|
170 |
|
}
|
|
170 |
|
}
|
171 |
|
}
|
|
171 |
|
}
|
172 |
|
},
|
|
172 |
|
},
|
173 |
|
|
|
173 |
|
|
174 |
|
addCSS
Class : fu
nction(e,
c) {
|
|
174 |
|
addCSS
Class : fu
nction(e,
c) {
|
175 |
|
th
is.removeC
SSClass(e,
c);
|
|
175 |
|
th
is.removeC
SSClass(e,
c);
|
176 |
|
va
r a = this
.explode('
', e.clas
sName);
|
|
176 |
|
va
r a = this
.explode('
', e.clas
sName);
|
177 |
|
a[
a.length]
= c;
|
|
177 |
|
a[
a.length]
= c;
|
178 |
|
e.
className
= a.join('
');
|
|
178 |
|
e.
className
= a.join('
');
|
179 |
|
},
|
|
179 |
|
},
|
180 |
|
|
|
180 |
|
|
181 |
|
remove
CSSClass :
function(
e, c) {
|
|
181 |
|
remove
CSSClass :
function(
e, c) {
|
182 |
|
va
r a = this
.explode('
', e.clas
sName), i;
|
|
182 |
|
va
r a = this
.explode('
', e.clas
sName), i;
|
183 |
|
|
|
183 |
|
|
184 |
|
fo
r (i=0; i<
a.length;
i++) {
|
|
184 |
|
fo
r (i=0; i<
a.length;
i++) {
|
185 |
|
if (a[i]
== c)
|
|
185 |
|
if (a[i]
== c)
|
186 |
|
a[i]
= '';
|
|
186 |
|
a[i]
= '';
|
187 |
|
}
|
|
187 |
|
}
|
188 |
|
|
|
188 |
|
|
189 |
|
e.
className
= a.join('
');
|
|
189 |
|
e.
className
= a.join('
');
|
190 |
|
},
|
|
190 |
|
},
|
191 |
|
|
|
191 |
|
|
192 |
|
explod
e : functi
on(d, s) {
|
|
192 |
|
explod
e : functi
on(d, s) {
|
193 |
|
va
r ar = s.s
plit(d);
|
|
193 |
|
va
r ar = s.s
plit(d);
|
194 |
|
va
r oar = ne
w Array();
|
|
194 |
|
va
r oar = ne
w Array();
|
195 |
|
|
|
195 |
|
|
196 |
|
fo
r (var i =
0; i<ar.l
ength; i++
) {
|
|
196 |
|
fo
r (var i =
0; i<ar.l
ength; i++
) {
|
197 |
|
if (ar[i
] != "")
|
|
197 |
|
if (ar[i
] != "")
|
198 |
|
oar[
oar.length
] = ar[i];
|
|
198 |
|
oar[
oar.length
] = ar[i];
|
199 |
|
}
|
|
199 |
|
}
|
200 |
|
|
|
200 |
|
|
201 |
|
re
turn oar;
|
|
201 |
|
re
turn oar;
|
202 |
|
},
|
|
202 |
|
},
|
203 |
|
|
|
203 |
|
|
204 |
|
parseI
nt : funct
ion(s) {
|
|
204 |
|
parseI
nt : funct
ion(s) {
|
205 |
|
if
(s == nul
l || s ==
'')
|
|
205 |
|
if
(s == nul
l || s ==
'')
|
206 |
|
return 0
;
|
|
206 |
|
return 0
;
|
207 |
|
|
|
207 |
|
|
208 |
|
re
turn parse
Int(s);
|
|
208 |
|
re
turn parse
Int(s);
|
209 |
|
}
|
|
209 |
|
}
|
210 |
|
}
|
|
210 |
|
}
|