/**
* By www.865171.cn
* q q : 215288671
* Date : 2010.4.22
*//**
* 控件基类.
* 控件即是本包中已实现的控件对象.
*/
var CBase = { //类型,保留作为Component标识.
type: 'CBase', //代表该控件的DOM结点.
view: null, draggable: false, resizable: false, id: 0, title: '', tleLen: 15, //初始化.
initialize: function(opts) { if ((typeof this.id) == 'undefined') {
this.id = CC.uniqueID();
} //所有赋值给view的属性通过用viewAttr传递.
var viewAttr = null; if (opts && opts.viewAttr) {
viewAttr = opts.viewAttr;
delete opts.viewAttr;
} CC.extend(this, opts); if (!this.view) {
this.view = CC. $C('DIV');
} if (this.parent) {
this.parent.appendChild(this.view);
} if (viewAttr) {
CC.extend(this.view, viewAttr);
} //view附加一个控件本身的引用.
this.view.component = this;
}
, //设置view的宽度.
setWidth: function(width) {
CC.style(this.view, 'width', width + 'px');
}
, //设置view的高度.
setHeight: function(height) {
CC.style(this.view, 'width', height + 'px');
}
, //设置view 的top.
setTop: function(top) {
CC.style(this.view, 'top', top + 'px');
}
, setLeft: function(left) {
CC.style(this.view, 'left', left + 'px');
}
, //是否禁用该控件的view,参数:true或false.
setDisabled: function(b) {
CC.disabled(this.view, b);
}
, //设置view的className.
setClass: function(c) {
CC.setClass(this.view, c);
}
, //设置控件view的属性.
//如设置高为setViewAttr('top',50);
setViewAttr: function(n, v) {
this.view[n] = v;
}
, //设置view中任一子层id为childId的子结子的属性.
//属性也可以多层次.
//如存在一id为'_ico'子结点,设置其display属性为
//inspectAttr('_ico','style.display','block');
inspectViewAttr: function(childId, childAttrList, attrValue) {
var obj = CC.inspect(this.view, childId);
//??Shoud do this??
if (obj == null) {
return ;
}
CC.inspectAttr(obj, childAttrList, attrValue);
return obj;
}
, //设置控件的图标,如果存在的话.
//图标结点id必须是'_ico'且在view中是唯一的.
setIcon: function(cssIco) {
this.inspectViewAttr('_ico', 'className', cssIco);
}
,
setVisible: function(b) {
CC.display(this.view, b);
}
, //设置控件的标题,如果存在的话.
//标题结点id必须是'_tle'且在view中是唯一的.
setTitle: function(ss) {
this.title = ss;
var tle = CC.inspect(this.view, '_tle');
CC.style(tle.parentNode, 'title', tle);
tle.innerHTML = ss.truncate(this.tleLen);
}
, //设置控件view的宽度高度.
setSize: function(width, height) {
CC.style(this.view, 'width', width + 'px');
CC.style(this.view, 'height', height + 'px');
}
, setPosition: function(left, top) {
CC.style(this.view, 'left', left + 'px');
CC.style(this.view, 'top', top + 'px');
}
, //控件view是否可见.
isVisible: function() {
return this.view.style.display != "none";
}
, //为view添加DOM事件.
//useCapture:否是支持冒泡.
observe: function(name, observer, useCapture) {
Event.observe(this.view, name, observer, useCapture);
}
,
stopObserving: function(name, observer, useCapture) {
Event.stopObserving(this.view, observer, useCapture);
}
, //设置控件是否可拖动.
//moveObj:发生拖动时要移动的结点.
setDragable: function(b, moveObj, fnOnMov, fnOnDrag, fnOnDrog) {
this.draggable = b;
(moveObj) ? Position.setDragable(this.view, moveObj, b, fnOnMov, fnOnDrag, fnOnDrog): Position.setDragable(this.view, this.view, b, fnOnMov, fnOnDrag, fnOnDrog);
}
, //之前版本appendView已改为appendChild
//为view添加一个子DOM结点.
appendChild: function(v) {
this.view.appendChild(v);
}
, removeChild: function(v) {
this.view.removeChild(v);
}
};给个介绍的链接也可以
这个自己搜吧,除了搜索和原作者(你可以和他QQ联系),没什么其它资料。