all files / dui/src/widget/ Button.js

53.33% Statements 8/15
25% Branches 3/12
66.67% Functions 2/3
53.33% Lines 8/15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43                                                                     
/**
 * 按钮控件
 *
 * @file 按钮控件
 * @author Brian Li (lbxxlht@163.com)
 */
var define = typeof define === 'function' && define.amd ? define : function (factory) {
    typeof module === 'object' ? (module.exports = factory(require)) : '';
};
 
define(function (require) {
 
    var Controller = require('../core/controller');
    var util = require('../core/util');
 
    // public /////////////////////////////////////////////////////////////////
 
    /**
     * Button构造函数
     *
     * @param {Object} param 初始化参数
     * @return {Button} Button实例
     */
    function Button(param) {
        if (!(this instanceof Button)) {
            return new Button(param);
        }
        param = param || {};
        // 原始模板
        param.tpl = '';
        // 调用父类初始化
        Controller.call(this, param);
        // 初始化完毕后的附加修改
        if (param.disable) {
            this.disable = true;
        }
    }
 
    util.inherit(Button, Controller);
 
    return Button;
});