2008-07-04
【Ext学习二】Extjs2 小控件 slideplayer
关键字: ext这下子左右上下的tab都可以轻松添加到web页面上去了,目前没有添加自动播放功能,这2天添好了再放新的上来
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'});
});
- 17:10
- 浏览 (206)
- 评论 (1)
- 分类: [javascript]
- 进入论坛
- 发布在 javascript研究小组 圈子
- 相关推荐
评论
jianfeng008cn
2008-07-04
//已添加自动播放功能:
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});
});
对信息滚动、图片滚动、相册等网页效果有兴趣的可以一起学习,打算做些常用的用到自己的网站上去,感觉ext只使用jquery等小js库的功能,文件也不大,用起来更顺手.
发表评论
提醒: 该博客已发表在公共论坛,博客所有留言会成为论坛回贴,留言请注意遵守论坛发贴规则
- 浏览: 80456 次
- 性别:

- 来自: 湖州

- 详细资料
搜索本博客
我的相册
旋转 SNV10095
共 1 张
共 1 张
最新评论
-
MySQL5安装版windows xp重 ...
可以下载我精简的绿色版 (*^__^*) 嘻嘻…… 其实很简单的
-- by vb2005xu -
【Ext学习二】Extjs2 小 ...
//已添加自动播放功能: Ext.onReady(function() ...
-- by jianfeng008cn -
【Ext学习一】Ext 继承函 ...
fins 写道我说的是第一个问题 不是第二个空函数F的问题 我说了啊, 这些问题 ...
-- by jianfeng008cn -
【Ext学习一】Ext 继承函 ...
我搞错了,可以支持inline constructor的原因是: sb = ov ...
-- by sp42 -
【Ext学习一】Ext 继承函 ...
空函数是经典的闭包应用,用来解决继承的问题了 呵呵, 至于 "spp.cons ...
-- by sp42






评论排行榜