No regular expressions were active.
|
|
1 |
|
// jQuery
plugin - D
olphin Pro
mo Images
|
|
|
2 |
|
(function(
$){
|
|
|
3 |
|
$.fn.d
olPromo =
function(
iInterval,
fRatio )
{
|
|
|
4 |
|
fu
nction res
izeMyImage
($Img) {
|
|
|
5 |
|
if( $Img
.width() >
$promo.wi
dth() ) {
|
|
|
6 |
|
var
fImgRatio
= $Img.he
ight() / $
Img.width(
);
|
|
|
7 |
|
$Img
.width( $p
romo.width
() ).heigh
t( Math.ro
und( $prom
o.width()
* fImgRati
o ) );
|
|
|
8 |
|
}
|
|
|
9 |
|
|
|
|
10 |
|
if( $Img
.height()
> $promo.h
eight() )
{
|
|
|
11 |
|
var
fImgRatio
= $Img.wid
th() / $Im
g.height()
;
|
|
|
12 |
|
$Img
.width( Ma
th.round(
$promo.hei
ght() * fI
mgRatio )
).height(
$promo.hei
ght() );
|
|
|
13 |
|
}
|
|
|
14 |
|
|
|
|
15 |
|
if( $Img
.width() <
$promo.wi
dth() ) {
|
|
|
16 |
|
var
left = Mat
h.round( (
$promo.wi
dth() - $I
mg.width()
) / 2 );
|
|
|
17 |
|
$Img
.css( 'lef
t', left )
;
|
|
|
18 |
|
}
|
|
|
19 |
|
|
|
|
20 |
|
if( $Img
.height()
< $promo.h
eight() )
{
|
|
|
21 |
|
var
top = Math
.round( (
$promo.hei
ght() - $I
mg.height(
) ) / 2 );
|
|
|
22 |
|
$Img
.css( 'top
', top );
|
|
|
23 |
|
}
|
|
|
24 |
|
}
|
|
|
25 |
|
|
|
|
26 |
|
fu
nction run
Flashing()
{
|
|
|
27 |
|
function
switchThe
m() {
|
|
|
28 |
|
if(
typeof ePr
ev != 'und
efined' )
|
|
|
29 |
|
ePrev.fade
Out( 1000
);
|
|
|
30 |
|
|
|
|
31 |
|
eNex
t.fadeIn(
1000 );
|
|
|
32 |
|
|
|
|
33 |
|
ePre
v = eNext;
|
|
|
34 |
|
eNex
t = eNext.
next( 'img
' );
|
|
|
35 |
|
|
|
|
36 |
|
if(
!eNext.len
gth )
|
|
|
37 |
|
eNext = $(
'img:firs
t', $promo
);
|
|
|
38 |
|
|
|
|
39 |
|
setT
imeout( sw
itchThem,
iInterval
);
|
|
|
40 |
|
}
|
|
|
41 |
|
|
|
|
42 |
|
var eNex
t = $( 'im
g:first',
$promo );
|
|
|
43 |
|
var ePre
v;
|
|
|
44 |
|
|
|
|
45 |
|
switchTh
em();
|
|
|
46 |
|
}
|
|
|
47 |
|
|
|
|
48 |
|
fu
nction res
etPromoSiz
e() {
|
|
|
49 |
|
if( !$pr
omo.width(
) )
|
|
|
50 |
|
//ge
t size fro
m parent
|
|
|
51 |
|
$pro
mo.width(
$promo.par
ent().widt
h() - pars
eInt( $pro
mo.css( 'm
argin-left
' ) ) - pa
rseInt( $p
romo.css(
'margin-ri
ght' ) ) )
;
|
|
|
52 |
|
else
|
|
|
53 |
|
$pro
mo.css( 'w
idth', 'au
to' );
|
|
|
54 |
|
|
|
|
55 |
|
$promo.h
eight( Mat
h.round( $
promo.widt
h() * fRat
io ) );
|
|
|
56 |
|
}
|
|
|
57 |
|
|
|
|
58 |
|
//
default pa
rameters
|
|
|
59 |
|
va
r iInterva
l = iInter
val || 300
0; //switc
hing inter
val in mil
liseconds
|
|
|
60 |
|
va
r fRatio =
fRatio ||
0.28125;
//main div
size prop
ortion (he
ight/width
)
|
|
|
61 |
|
|
|
|
62 |
|
va
r $promo =
this;
|
|
|
63 |
|
|
|
|
64 |
|
re
setPromoSi
ze();
|
|
|
65 |
|
|
|
|
66 |
|
$(
'> img',
$promo ) /
/get all i
mages
|
|
|
67 |
|
.c
ss( 'displ
ay', 'none
' ) //hide
all image
s
|
|
|
68 |
|
.e
ach( funct
ion() { //
for each i
mage
|
|
|
69 |
|
var $Img
= $(this)
; //get cu
rrent imag
e
|
|
|
70 |
|
$Img.rea
dy( functi
on() { //w
hen the im
age is loa
ded
|
|
|
71 |
|
resi
zeMyImage(
$Img );
|
|
|
72 |
|
} );
|
|
|
73 |
|
}
)
|
|
|
74 |
|
.r
eady( func
tion() { /
/when all
images loa
ded
|
|
|
75 |
|
//fire u
p behavior
|
|
|
76 |
|
$promo.c
ss( 'visib
ility', 'v
isible' );
|
|
|
77 |
|
runFlash
ing();
|
|
|
78 |
|
}
);
|
|
|
79 |
|
|
|
|
80 |
|
va
r iOldWidt
h = $promo
.width()
|
|
|
81 |
|
//
attach eve
nt on wind
ow resize
|
|
|
82 |
|
$(
window).re
size( func
tion() {
|
|
|
83 |
|
resetPro
moSize();
|
|
|
84 |
|
var iNew
Width = $p
romo.width
();
|
|
|
85 |
|
|
|
|
86 |
|
if( iOld
Width != i
NewWidth )
{ //if th
e main wid
th is chan
ged
|
|
|
87 |
|
iOld
Width = $p
romo.width
();
|
|
|
88 |
|
|
|
|
89 |
|
$( '
> img', $p
romo ).eac
h( functio
n() {
|
|
|
90 |
|
var $Img =
$(this);
|
|
|
91 |
|
$Img.css(
{ width: '
auto', hei
ght: 'auto
', left: 0
, top: 0 }
);
|
|
|
92 |
|
resizeMyIm
age( $Img
);
|
|
|
93 |
|
} );
|
|
|
94 |
|
}
|
|
|
95 |
|
}
);
|
|
|
96 |
|
};
|
|
|
97 |
|
})(jQuery)
;
|