From 19bc6efa87230b057a50bd447dba71d3de21fb35 Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 21 Mar 2017 00:39:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=95=B0=E6=8D=AE=E7=BB=93?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/ob.js | 11 ++++++----- src/core/widget.js | 12 +++++------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/core/ob.js b/src/core/ob.js index 8f1d4a885..182c68f07 100644 --- a/src/core/ob.js +++ b/src/core/ob.js @@ -4,7 +4,11 @@ * @abstract */ BI.OB = function (config) { - this.options = $.extend(this._defaultConfig(config), config); + var props = this.props; + if (BI.isFunction(this.props)) { + props = this.props(config); + } + this.options = $.extend(this._defaultConfig(config), props, config); this._init(); this._initRef(); }; @@ -14,10 +18,7 @@ $.extend(BI.OB.prototype, { }, _defaultConfig: function (config) { - if (BI.isFunction(this.props)) { - return this.props(config); - } - return this.props; + return {}; }, _init: function () { diff --git a/src/core/widget.js b/src/core/widget.js index 799934f2e..1326dee57 100644 --- a/src/core/widget.js +++ b/src/core/widget.js @@ -7,7 +7,7 @@ */ BI.Widget = BI.inherit(BI.OB, { _defaultConfig: function () { - return BI.extend({ + return BI.extend(BI.Widget.superclass._defaultConfig.apply(this), { tagName: "div", attributes: null, data: null, @@ -17,8 +17,9 @@ BI.Widget = BI.inherit(BI.OB, { invisible: false, invalid: false, baseCls: "", + extraCls: "", cls: "" - }, BI.Widget.superclass._defaultConfig.call(this)) + }) }, //生命周期函数 @@ -74,11 +75,8 @@ BI.Widget = BI.inherit(BI.OB, { } else { this.element = $(document.createElement(o.tagName)); } - if (o.baseCls) { - this.element.addClass(o.baseCls); - } - if (o.cls) { - this.element.addClass(o.cls); + if (o.baseCls || o.extraCls || o.cls) { + this.element.addClass((o.baseCls || "") + " " + (o.extraCls || "") + " " + (o.cls || "")); } if (o.attributes) { this.element.attr(o.attributes);