Browse Source

buttonGroup的layouts可以不用传数组

es6
guy 3 years ago
parent
commit
b6e2c6ed88
  1. 13
      src/base/combination/group.button.js

13
src/base/combination/group.button.js

@ -30,7 +30,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
});
this.behaviors = behaviors;
this.populate(o.items);
if(BI.isKey(o.value) || BI.isNotEmptyArray(o.value)){
if (BI.isKey(o.value) || BI.isNotEmptyArray(o.value)) {
this.setValue(o.value);
}
},
@ -77,11 +77,12 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
_packageBtns: function (btns) {
var o = this.options;
for (var i = o.layouts.length - 1; i > 0; i--) {
var layouts = BI.isArray(o.layouts) ? o.layouts : [o.layouts];
for (var i = layouts.length - 1; i > 0; i--) {
btns = BI.map(btns, function (k, it) {
return BI.extend({}, o.layouts[i], {
return BI.extend({}, layouts[i], {
items: [
BI.extend({}, o.layouts[i].el, {
BI.extend({}, layouts[i].el, {
el: it
})
]
@ -108,7 +109,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
},
_packageLayout: function (items) {
var o = this.options, layout = BI.deepClone(o.layouts[0]);
var o = this.options, layout = BI.deepClone(BI.isArray(o.layouts) ? o.layouts[0] : o.layouts);
var lay = BI.formatEL(layout).el;
while (lay && lay.items && !BI.isEmpty(lay.items)) {
@ -121,7 +122,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
// 如果是一个简单的layout
_isSimpleLayout: function () {
var o = this.options;
return o.layouts.length === 1 && !BI.isArray(o.items[0]);
return BI.isArray(o.layouts) ? (o.layouts.length === 1 && !BI.isArray(o.items[0])) : true;
},
doBehavior: function () {

Loading…
Cancel
Save