define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-buttons"], function (require, exports, ej2_base_1, ej2_buttons_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function createButtonGroup(selector, options, createElement) {
if (options === void 0) { options = {}; }
var child;
var btnElem;
var nextChild;
var btnModel;
Eif (ej2_base_1.isNullOrUndefined(createElement)) {
createElement = ej2_base_1.createElement;
}
var wrapper = document.querySelector(selector);
ej2_base_1.addClass([wrapper], ['e-btn-group', 'e-css']);
wrapper.setAttribute('role', 'group');
var childs = wrapper.children;
options.buttons = options.buttons || [];
for (var i = 0, j = 0; j < childs.length; i++, j++) {
child = childs[j];
btnModel = options.buttons[i];
if (btnModel !== null) {
if (child.tagName === 'BUTTON') {
btnElem = child;
}
else {
btnElem = createElement('label');
nextChild = childs[j + 1];
if (nextChild) {
wrapper.insertBefore(btnElem, nextChild);
}
else {
wrapper.appendChild(btnElem);
}
if (child.id) {
btnElem.setAttribute('for', child.id);
}
Iif (btnModel && btnModel.disabled) {
child.disabled = true;
}
j++;
}
if (options.cssClass && btnModel && !btnModel.cssClass) {
btnModel.cssClass = options.cssClass;
}
new ej2_buttons_1.Button(btnModel || {}, btnElem);
}
}
return wrapper;
}
exports.createButtonGroup = createButtonGroup;
});
|