01.
(
function
($){
02.
$.fn.SimpleGallery =
function
(_config){
03.
04.
var
_config = $.extend({
05.
swapDuration: 3500,
06.
fadeOutDuration: 200,
07.
fadeInDuration: 500,
08.
activeItem : 0
09.
}, _config);
10.
11.
function
_view($item){
12.
13.
var
$SG = $(
'#SimpleGallery'
);
14.
var
itemCount = $SG.find(
'li'
).length;
15.
var
itemIndex = ($item.index() + 1);
16.
17.
if
((itemIndex+1) != _config.activeItem && !(_config.activeItem == 0 && itemIndex == itemCount)){
18.
_config.activeItem = itemIndex;
19.
if
(_config.activeItem == itemCount){
20.
_config.activeItem = 0;
21.
}
22.
$SG.find(
'div'
)
23.
.stop()
24.
.fadeTo(0, 1)
25.
.fadeOut(_config.fadeOutDuration,
function
(){
26.
$(
this
).find(
'img'
).attr(
'src'
,$item.find(
'a'
).attr(
'href'
));
27.
$(
this
).find(
'span'
).text($item.find(
'a'
).attr(
'title'
));
28.
$(
this
).fadeIn(_config.fadeInDuration);
29.
});
30.
}
31.
}
32.
33.
function
_play(){
34.
_view($(
'#SimpleGallery'
).find(
'li'
).eq(_config.activeItem));
35.
}
36.
37.
return
this
.each(
function
(){
38.
_play();
39.
var
_interval = setInterval(_play, _config.swapDuration);
40.
$(
this
).find(
'li'
).hover(
function
(){
41.
if
(_interval){
42.
clearInterval(_interval);
43.
}
44.
_interval = setInterval(_play, _config.swapDuration);
45.
$(
'#SimpleGallery'
).find(
'div'
).show();
46.
_view($(
this
));
47.
}).find(
'a'
).click(
function
(){
return
false
;});
48.
});
49.
}
50.
})(jQuery);