No regular expressions were active.
|
|
1 |
|
/* Copyrig
ht (c) 200
7 Paul Bak
aus (paul.
bakaus@goo
glemail.co
m) and Bra
ndon Aaron
(brandon.
aaron@gmai
l.com || h
ttp://bran
donaaron.n
et)
|
|
|
2 |
|
* Dual li
censed und
er the MIT
(http://w
ww.opensou
rce.org/li
censes/mit
-license.p
hp)
|
|
|
3 |
|
* and GPL
(http://w
ww.opensou
rce.org/li
censes/gpl
-license.p
hp) licens
es.
|
|
|
4 |
|
*
|
|
|
5 |
|
* $LastCh
angedDate:
2007-12-2
0 15:43:48
+0100 (Do
, 20 Dez 2
007) $
|
|
|
6 |
|
* $Rev: 4
257 $
|
|
|
7 |
|
*
|
|
|
8 |
|
* Version
: @VERSION
|
|
|
9 |
|
*
|
|
|
10 |
|
* Require
s: jQuery
1.2+
|
|
|
11 |
|
*/
|
|
|
12 |
|
|
|
|
13 |
|
(function(
$){
|
|
|
14 |
|
|
|
|
15 |
|
$.dimensio
ns = {
|
|
|
16 |
|
versio
n: '@VERSI
ON'
|
|
|
17 |
|
};
|
|
|
18 |
|
|
|
|
19 |
|
// Create
innerHeigh
t, innerWi
dth, outer
Height and
outerWidt
h methods
|
|
|
20 |
|
$.each( [
'Height',
'Width' ],
function(
i, name){
|
|
|
21 |
|
|
|
|
22 |
|
// inn
erHeight a
nd innerWi
dth
|
|
|
23 |
|
$.fn[
'inner' +
name ] = f
unction()
{
|
|
|
24 |
|
if
(!this[0]
) return;
|
|
|
25 |
|
|
|
|
26 |
|
va
r torl = n
ame == 'He
ight' ? 'T
op' : '
Left', //
top or le
ft
|
|
|
27 |
|
borr = n
ame == 'He
ight' ? 'B
ottom' : '
Right'; //
bottom or
right
|
|
|
28 |
|
|
|
|
29 |
|
re
turn this.
is(':visib
le') ? thi
s[0]['clie
nt' + name
] : num( t
his, name.
toLowerCas
e() ) + nu
m(this, 'p
adding' +
torl) + nu
m(this, 'p
adding' +
borr);
|
|
|
30 |
|
};
|
|
|
31 |
|
|
|
|
32 |
|
// out
erHeight a
nd outerWi
dth
|
|
|
33 |
|
$.fn[
'outer' +
name ] = f
unction(op
tions) {
|
|
|
34 |
|
if
(!this[0]
) return;
|
|
|
35 |
|
|
|
|
36 |
|
va
r torl = n
ame == 'He
ight' ? 'T
op' : '
Left', //
top or le
ft
|
|
|
37 |
|
borr = n
ame == 'He
ight' ? 'B
ottom' : '
Right'; //
bottom or
right
|
|
|
38 |
|
|
|
|
39 |
|
op
tions = $.
extend({ m
argin: fal
se }, opti
ons || {})
;
|
|
|
40 |
|
|
|
|
41 |
|
va
r val = th
is.is(':vi
sible') ?
|
|
|
42 |
|
this
[0]['offse
t' + name]
:
|
|
|
43 |
|
num(
this, nam
e.toLowerC
ase() )
|
|
|
44 |
|
+ num(this
, 'border'
+ torl +
'Width') +
num(this,
'border'
+ borr + '
Width')
|
|
|
45 |
|
+ num(this
, 'padding
' + torl)
+ num(this
, 'padding
' + borr);
|
|
|
46 |
|
|
|
|
47 |
|
re
turn val +
(options.
margin ? (
num(this,
'margin' +
torl) + n
um(this, '
margin' +
borr)) : 0
);
|
|
|
48 |
|
};
|
|
|
49 |
|
});
|
|
|
50 |
|
|
|
|
51 |
|
// Create
scrollLeft
and scrol
lTop metho
ds
|
|
|
52 |
|
$.each( ['
Left', 'To
p'], funct
ion(i, nam
e) {
|
|
|
53 |
|
$.fn[
'scroll' +
name ] =
function(v
al) {
|
|
|
54 |
|
if
(!this[0]
) return;
|
|
|
55 |
|
|
|
|
56 |
|
re
turn val !
= undefine
d ?
|
|
|
57 |
|
|
|
|
58 |
|
// Set t
he scroll
offset
|
|
|
59 |
|
this.eac
h(function
() {
|
|
|
60 |
|
this
== window
|| this =
= document
?
|
|
|
61 |
|
window.scr
ollTo(
|
|
|
62 |
|
name =
= 'Left' ?
val : $(w
indow)[ 's
crollLeft'
](),
|
|
|
63 |
|
name =
= 'Top' ?
val : $(w
indow)[ 's
crollTop'
]()
|
|
|
64 |
|
) :
|
|
|
65 |
|
this[ 'scr
oll' + nam
e ] = val;
|
|
|
66 |
|
}) :
|
|
|
67 |
|
|
|
|
68 |
|
// Retur
n the scro
ll offset
|
|
|
69 |
|
this[0]
== window
|| this[0]
== docume
nt ?
|
|
|
70 |
|
self
[ (name ==
'Left' ?
'pageXOffs
et' : 'pag
eYOffset')
] ||
|
|
|
71 |
|
$.boxModel
&& docume
nt.documen
tElement[
'scroll' +
name ] ||
|
|
|
72 |
|
document.b
ody[ 'scro
ll' + name
] :
|
|
|
73 |
|
this
[0][ 'scro
ll' + name
];
|
|
|
74 |
|
};
|
|
|
75 |
|
});
|
|
|
76 |
|
|
|
|
77 |
|
$.fn.exten
d({
|
|
|
78 |
|
positi
on: functi
on() {
|
|
|
79 |
|
va
r left = 0
, top = 0,
elem = th
is[0], off
set, paren
tOffset, o
ffsetParen
t, results
;
|
|
|
80 |
|
|
|
|
81 |
|
if
(elem) {
|
|
|
82 |
|
// Get *
real* offs
etParent
|
|
|
83 |
|
offsetPa
rent = thi
s.offsetPa
rent();
|
|
|
84 |
|
|
|
|
85 |
|
// Get c
orrect off
sets
|
|
|
86 |
|
offset
= thi
s.offset()
;
|
|
|
87 |
|
parentOf
fset = off
setParent.
offset();
|
|
|
88 |
|
|
|
|
89 |
|
// Subtr
act elemen
t margins
|
|
|
90 |
|
offset.t
op -= num
(elem, 'ma
rginTop');
|
|
|
91 |
|
offset.l
eft -= num
(elem, 'ma
rginLeft')
;
|
|
|
92 |
|
|
|
|
93 |
|
// Add o
ffsetParen
t borders
|
|
|
94 |
|
parentOf
fset.top
+= num(off
setParent,
'borderTo
pWidth');
|
|
|
95 |
|
parentOf
fset.left
+= num(off
setParent,
'borderLe
ftWidth');
|
|
|
96 |
|
|
|
|
97 |
|
// Subtr
act the tw
o offsets
|
|
|
98 |
|
results
= {
|
|
|
99 |
|
top:
offset.t
op - pare
ntOffset.t
op,
|
|
|
100 |
|
left
: offset.l
eft - pare
ntOffset.l
eft
|
|
|
101 |
|
};
|
|
|
102 |
|
}
|
|
|
103 |
|
|
|
|
104 |
|
re
turn resul
ts;
|
|
|
105 |
|
},
|
|
|
106 |
|
|
|
|
107 |
|
offset
Parent: fu
nction() {
|
|
|
108 |
|
va
r offsetPa
rent = thi
s[0].offse
tParent;
|
|
|
109 |
|
wh
ile ( offs
etParent &
& (!/^body
|html$/i.t
est(offset
Parent.tag
Name) && $
.css(offse
tParent, '
position')
== 'stati
c') )
|
|
|
110 |
|
offsetPa
rent = off
setParent.
offsetPare
nt;
|
|
|
111 |
|
re
turn $(off
setParent)
;
|
|
|
112 |
|
}
|
|
|
113 |
|
});
|
|
|
114 |
|
|
|
|
115 |
|
function n
um(el, pro
p) {
|
|
|
116 |
|
return
parseInt(
$.curCSS(e
l.jquery?e
l[0]:el,pr
op,true))|
|0;
|
|
|
117 |
|
};
|
|
|
118 |
|
|
|
|
119 |
|
})(jQuery)
;
|