?? checkbox.lib.js
字號:
?/*
By Hangring
#2008.02.26#
---
use list:
> global.lib.js
> node.lib.js
> events.lib.js
> node.lib.js
> css.lib.js
---
復選框
---
包含樣式:
<link rel="stylesheet" href="css/checkbox.lib.css" type="text/css" />
*/
function CheckBox (name, value) {
this.container = null;
// the checkbox object
this.checkbox = null;
// checkbox's name
this.name = name || 'checkbox_' + Math.random();
// checkbox's value
this.value = value || '';
// view text
this.text = '';
// checked or not
this.checked = false;
this.css = {
container:'check-box',
icon:'icon',
icon_checked:'icon-checked',
icon_nonchecked:'icon-nonchecked'
};
}
CheckBox.prototype.Init = function () {
};
CheckBox.prototype.Create = function () {
var self = this;
var container = this.container = oNode.CreateNode('a');
CSS.AddClass(container, this.css.container);
container.href = '#';
var checkbox = this.checkbox = oNode.CreateNode('input');
checkbox.type = 'checkbox';
oNode.AddNode(checkbox, container);
checkbox.name = this.name;
checkbox.value = this.value;
var icon = oNode.CreateNode('span');
oNode.AddNode(icon, container);
CSS.AddClass(icon, this.css.icon);
if (this.text) {
var label = oNode.CreateNode('label');
oNode.AddNode(label, container);
oNode.AddNode('\x20' + this.text, label);
}
Events.AttachEvent(container, 'click', function (e) {
if (self.checked) {
CSS.ReplaceClass(icon, self.css.icon_checked, self.css.icon_nonchecked);
}
else {
CSS.ReplaceClass(icon, self.css.icon_nonchecked, self.css.icon_checked);
}
self.checked = !self.checked;
self.checkbox.checked = self.checked;
self._Change();
Events.CancelAll(e);
});
Events.AttachEvent(container, 'mouseover', function (e, th) {
self._MouseOver(e, th || this);
});
Events.AttachEvent(container, 'mouseout', function (e, th) {
self._MouseOut(e, th || this);
});
return container;
};
CheckBox.prototype._MouseOver = function (e /* window.event|MouseEvent:Object */, th /* :HTMLElement */) {
this.MouseOver(e, th);
};
CheckBox.prototype.MouseOver = function (e /* window.event|MouseEvent:Object */, th /* :HTMLElement */) {
};
CheckBox.prototype._MouseOut = function (e /* window.event|MouseEvent:Object */, th /* :HTMLElement */) {
this.MouseOut(e, th);
};
CheckBox.prototype.MouseOut = function (e /* window.event|MouseEvent:Object */, th /* :HTMLElement */) {
};
CheckBox.prototype._Change = function () {
this.Change();
};
CheckBox.prototype.Change = function () {
//alert(this.checked);
};
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -