You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.1 KiB
80 lines
2.1 KiB
BI.VirtualGroup = BI.inherit(BI.Widget, { |
|
_defaultConfig: function () { |
|
return BI.extend(BI.VirtualGroup.superclass._defaultConfig.apply(this, arguments), { |
|
baseCls: "bi-virtual-group", |
|
items: [], |
|
layouts: [{ |
|
type: "bi.center", |
|
hgap: 0, |
|
vgap: 0 |
|
}] |
|
}); |
|
}, |
|
|
|
render: function () { |
|
this.populate(this.options.items); |
|
}, |
|
|
|
_packageBtns: function (items) { |
|
var o = this.options; |
|
|
|
for (var i = o.layouts.length - 1; i > 0; i--) { |
|
items = BI.map(items, function (k, it) { |
|
return BI.extend({}, o.layouts[i], { |
|
items: [ |
|
BI.extend({}, o.layouts[i].el, { |
|
el: BI.stripEL(it) |
|
}) |
|
] |
|
}); |
|
}); |
|
} |
|
return items; |
|
}, |
|
|
|
_packageItems: function (items, packBtns) { |
|
return BI.createItems(BI.makeArrayByArray(items, {}), BI.clone(packBtns)); |
|
}, |
|
|
|
_packageLayout: function (items) { |
|
var o = this.options, layout = BI.deepClone(o.layouts[0]); |
|
|
|
var lay = BI.formatEL(layout).el; |
|
while (lay && lay.items && !BI.isEmpty(lay.items)) { |
|
lay = BI.formatEL(lay.items[0]).el; |
|
} |
|
lay.items = items; |
|
return layout; |
|
}, |
|
|
|
addItems: function (items) { |
|
this.layouts.addItems(items); |
|
}, |
|
|
|
prependItems: function (items) { |
|
this.layouts.prependItems(items); |
|
}, |
|
|
|
setValue: function (v) { |
|
// this.layouts.setValue(v); |
|
}, |
|
|
|
getValue: function () { |
|
return this.layouts.getValue(); |
|
}, |
|
|
|
populate: function (items) { |
|
var self = this; |
|
items = items || []; |
|
this.options.items = items; |
|
items = this._packageBtns(items); |
|
if (!this.layouts) { |
|
this.layouts = BI.createWidget(BI.extend({element: this}, this._packageLayout(items))); |
|
} else { |
|
this.layouts.populate(items); |
|
} |
|
} |
|
}); |
|
BI.VirtualGroup.EVENT_CHANGE = "EVENT_CHANGE"; |
|
|
|
BI.shortcut("bi.virtual_group", BI.VirtualGroup); |