//自动播放器
Ext.onReady(function(){
Ext.ux.SlideBox = Ext.extend(Object, {
constructor : function(cfg) {
Ext.ux.SlideBox.superclass.constructor.call(this, cfg);
Ext.apply(this,cfg);
this.aciveIndex = this.aciveIndex || 0;
this.boxes = Ext.select('li', false, this.boxid);
this.boxes.each(function(box,sidebox, index) {
box.set( {
'sidebox:index' : index
});
box.on('mouseover', this.onMouseover,this);
}, this);
this.setActiveBox(this.aciveIndex);
},
setActiveBox:function(index){
this.setClsActiveOrNot(this.aciveIndex,false);
this.setClsActiveOrNot(index,true);
this.aciveIndex = index;
},
setClsActiveOrNot:function(index,bvar){
var boxTitle = this.boxes.item(index);
var boxConfig = Ext.util.JSON.decode(boxTitle.getAttributeNS('sidebox','config'));
var boxBody = Ext.get(boxConfig['bodyId']);
if(bvar){
boxTitle.replaceClass(boxConfig['deactivecls'],boxConfig['activecls']);
boxBody.replaceClass(boxConfig['bodyDeactivecls'],boxConfig['bodyActivecls']);
}else{
boxTitle.replaceClass(boxConfig['activecls'],boxConfig['deactivecls']);
boxBody.replaceClass(boxConfig['bodyActivecls'],boxConfig['bodyDeactivecls']);
}
},
onMouseover:function(e,elm){
var index = Ext.fly(elm).getAttributeNS('sidebox','index');
if(!index){
index = Ext.fly(elm).parent('li').getAttributeNS('sidebox','index');
}
if(index){this.setActiveBox(index);}
}
})
var sidebox = new Ext.ux.SlideBox({title:'hello',boxid:'slideBox'});
});
Ext.onReady(function(){
Ext.ux.SlideBox = Ext.extend(Object, {
constructor : function(cfg) {
Ext.ux.SlideBox.superclass.constructor.call(this, cfg);
Ext.apply(this,cfg);
this.aciveIndex = this.aciveIndex || 0;
this.boxes = Ext.select('li', false, this.boxid);
this.boxes.each(function(box,sidebox, index) {
box.set( {
'sidebox:index' : index
});
box.on('mouseover', this.onMouseover,this);
}, this);
this.setActiveBox(this.aciveIndex);
},
setActiveBox:function(index){
this.setClsActiveOrNot(this.aciveIndex,false);
this.setClsActiveOrNot(index,true);
this.aciveIndex = index;
},
setClsActiveOrNot:function(index,bvar){
var boxTitle = this.boxes.item(index);
var boxConfig = Ext.util.JSON.decode(boxTitle.getAttributeNS('sidebox','config'));
var boxBody = Ext.get(boxConfig['bodyId']);
if(bvar){
boxTitle.replaceClass(boxConfig['deactivecls'],boxConfig['activecls']);
boxBody.replaceClass(boxConfig['bodyDeactivecls'],boxConfig['bodyActivecls']);
}else{
boxTitle.replaceClass(boxConfig['activecls'],boxConfig['deactivecls']);
boxBody.replaceClass(boxConfig['bodyActivecls'],boxConfig['bodyDeactivecls']);
}
},
onMouseover:function(e,elm){
var index = Ext.fly(elm).getAttributeNS('sidebox','index');
if(!index){
index = Ext.fly(elm).parent('li').getAttributeNS('sidebox','index');
}
if(index){this.setActiveBox(index);}
}
})
var sidebox = new Ext.ux.SlideBox({title:'hello',boxid:'slideBox'});
});
ext-2.0-toolkit.rar (2.9 KB)
描述:
下载次数: 17
by jianfeng008cn 浏览 (72) 评论 (1) 收藏 相关推荐 评论
jianfeng008cn 2008-07-04
Js代码
//已添加自动播放功能:
Ext.onReady(function(){
Ext.ux.SlideBox = Ext.extend(Object, {
constructor : function(cfg) {
Ext.ux.SlideBox.superclass.constructor.call(this, cfg);
Ext.apply(this,cfg);
this.aciveIndex = this.aciveIndex || 0;
this.boxes = Ext.select('li', false, this.boxid);
this.boxes.each(function(box,sidebox, index) {
box.set( {
'sidebox:index' : index
});
box.on('mouseover', this.onMouseover,this);
if(this.enableSideplay){
box.on('mouseout', this.setIntervalFuc, this);
}
}, this);
this.setActiveBox(this.aciveIndex);
if(this.enableSideplay){
this.intervalTime = this.intervalTime || 2000;
this.setIntervalFuc();
this.box = Ext.get(this.boxid);
this.box.on('mouseover', this.clearIntervalFuc, this);
this.box.on('mouseout', this.setIntervalFuc, this);
}
},
setActiveBox:function(index){
this.setClsActiveOrNot(this.aciveIndex,false);
this.setClsActiveOrNot(index,true);
this.aciveIndex = index;
},
setClsActiveOrNot:function(index,bvar){
var boxTitle = this.boxes.item(index);
var boxConfig = Ext.util.JSON.decode(boxTitle.getAttributeNS('sidebox','config'));
var boxBody = Ext.get(boxConfig['bodyId']);
if(bvar){
boxTitle.replaceClass(boxConfig['deactivecls'],boxConfig['activecls']);
boxBody.replaceClass(boxConfig['bodyDeactivecls'],boxConfig['bodyActivecls']);
}else{
boxTitle.replaceClass(boxConfig['activecls'],boxConfig['deactivecls']);
boxBody.replaceClass(boxConfig['bodyActivecls'],boxConfig['bodyDeactivecls']);
}
},
onMouseover:function(e,elm){
if(this.enableSideplay){this.clearIntervalFuc();}
var index = Ext.fly(elm).getAttributeNS('sidebox','index');
if(!index){
index = Ext.fly(elm).parent('li').getAttributeNS('sidebox','index');
}
if(index){this.setActiveBox(index);}
},
setIntervalFuc : function() {
if(!this.intervalFuc){
this.intervalFuc = setInterval(this.showWhich.createDelegate(this),this.intervalTime);
}
},
clearIntervalFuc : function(e, elm, o, p, q) {
clearInterval(this.intervalFuc);
this.intervalFuc = null;
},
showWhich : function() {
var index = this.aciveIndex;
index++;
if (index >= this.boxes.getCount()){
index = 0;
}
this.setActiveBox(index);
}
})
var sidebox = new Ext.ux.SlideBox({title:'hello',boxid:'slideBox',enableSideplay:true});
});