首页 > 代码库 > 下载站焦点图
下载站焦点图
/*
down.js by sunhw
2014-11-17
*/
;(function(){
function SiderFocus(option){
this.option = T.object.extend({
root : ‘‘,
dot : ‘‘,
list : ‘‘,
autoTime : 5000
}, option || {});
this.map = {
currCls : ‘on‘,
visiCls : ‘visible‘,
hidden : ‘hidden‘
};
this.index = 0;
this.dots = T.query(‘a‘, T.get(this.option.dot));
this.lists = T.query(‘li‘, T.get(this.option.list));
this.init();
}
SiderFocus.prototype.bind = function(index){
var me = this;
me.index = index;
T.each(me.lists, function(item){
T.setStyle(item, ‘visibility‘, me.map.hidden);
});
T.each(me.dots, function(item){
T.removeClass(item, me.map.currCls);
});
T.addClass(me.dots[me.index], me.map.currCls);
T.setStyle(me.lists[me.index], ‘visibility‘, me.map.visiCls);
}
SiderFocus.prototype.autoPlay = function(){
var me = this;
clearInterval(me.autoTimer);
me.autoTimer = setInterval(function(){
if(me.index >= 3){
me.index = 0;
}else{
me.index++;
}
me.bind(me.index);
}, me.option.autoTime);
}
SiderFocus.prototype.init = function(){
var me = this;
me.autoTimer = 0;
T.each(me.dots, function(item, index){
T.on(item, ‘mouseover‘, function(e){
T.event.stop(T.event.get(e));
clearInterval(me.autoTimer);
me.bind(index);
});
});
T.on(T.get(me.option.root), ‘mouseover‘, function(){
clearInterval(me.autoTimer);
});
T.on(T.get(me.option.root), ‘mouseout‘, function(){
me.autoPlay();
});
me.autoPlay();
}
T.dom.ready(function(){
new SiderFocus({
root : ‘slide-focus‘,
dot : ‘down-slide-nums‘,
list : ‘slide-focus-ul‘,
autoTime : 5000
});
});
})();
下载站焦点图