⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 oradio.lib.js

📁 asp的bbs程序
💻 JS
字号:
/*
  By Hangring
  #2008.02.27#
  ---
  use list:
  > global.lib.js
  > node.lib.js
  > events.lib.js
  > node.lib.js
  > css.lib.js
  ---
  复选框
  ---
  包含样式:
  <link rel="stylesheet" href="css/oradio.lib.css" type="text/css" />
*/
function oRadio (name, value) {
    this.container = null;
    // the radio object
    this.radio = null;
    // the icon object
    this.icon = null;
    // radio's name
    this.name = name || 'radio_' + Math.random();
    // radio's value
    this.value = value || '';
    // view text
    this.text = '';
    // checked or not
    this.checked = false;

    // function
    this.check = null;

    this.css = {
        container:'oradio',
        icon:'icon',
        icon_checked:'icon-checked',
        icon_nonchecked:'icon-nonchecked'
    };
}

oRadio.prototype.Init = function () {
};

oRadio.prototype.Create = function () {
    var self = this;
    oRadio.Union(this, this.name);

    var container = this.container = oNode.CreateNode('a');
    CSS.AddClass(container, this.css.container);
    container.href = '#';
    var radio = this.radio = oNode.CreateNode('input');
    radio.type = 'radio';
    oNode.AddNode(radio, container);
    radio.name = this.name;
    radio.value = this.value;
    var icon = this.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);
    }

    this.check = function (e) {
        if (!self.checked) {
            self.checked = true;
            CSS.ReplaceClass(icon, self.css.icon_nonchecked, self.css.icon_checked);
            self.radio.checked = true;
            self._Change();

            for (var i = 0, len = oRadio[self.name].length; i < len; i++) {
                var radio = oRadio[self.name][i];
                if (radio != self) {
                    radio.checked = false;
                    CSS.ReplaceClass(radio.icon, radio.css.icon_checked, radio.css.icon_nonchecked);
                }
            }
        }

        Events.CancelAll(e);
    }
    Events.AttachEvent(container, 'click', this.check);

    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;
};

oRadio.prototype._MouseOver = function (e /* window.event|MouseEvent:Object */, th /* :HTMLElement */) {
    this.MouseOver(e, th);
};
oRadio.prototype.MouseOver = function (e /* window.event|MouseEvent:Object */, th /* :HTMLElement */) {
};

oRadio.prototype._MouseOut = function (e /* window.event|MouseEvent:Object */, th /* :HTMLElement */) {
    this.MouseOut(e, th);
};
oRadio.prototype.MouseOut = function (e /* window.event|MouseEvent:Object */, th /* :HTMLElement */) {
};

oRadio.prototype._Change = function () {
    this.Change();
};
oRadio.prototype.Change = function () {
};

oRadio.Union = function (radio /* :oRadio */, name /* radio's name:String */) {
    if (typeof this[name] != 'object') this[name] = [];
    this[name].push(radio);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -