gd-sprest-js
Version:
SharePoint 2013/Online js components.
46 lines (45 loc) • 1.43 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var _1 = require(".");
/**
* List
*/
exports.List = function (props) {
// Method to append list items
var appendItems = function (items) {
if (items === void 0) { items = []; }
// Parse the items
for (var i = 0; i < items.length; i++) {
// Create the item
var item = _1.ListItem(items[i]);
// See if the click event exists
if (props.onClick) {
// Add the click event
item._container.addEventListener("click", props.onClick.bind(item._container));
}
// Append the list item
_list._container.appendChild(item._container);
_list._listItemComponents.push(item);
}
};
// Method to get the fabric component
var get = function () { return _list; };
// Method to get the list items
var getItems = function () { return _list._listItemComponents; };
// Set the template
props.el.innerHTML = _1.Templates.List({
className: props.className,
el: props.el,
items: []
});
// Create the list
var _list = new _1.fabric.List(props.el.querySelector(".ms-List"));
// Append the items
appendItems(props.items);
// Return the list
return {
appendItems: appendItems,
get: get,
getItems: getItems
};
};