(function (ns) { /** * @alias qs.viewController.list.EnumCell * @constructor */ ns.EnumCell = function () { this.construct.apply(this, arguments); }; var proto = ns.EnumCell.prototype; proto.construct = function (options) { this.eventNS = 'qsListEnumCell'; this.options = $.extend({ listId: undefined, enumType: 'link_enum' }, options); this.lockCounter = 0; this.element = {}; /** @type {jQuery} */ this.element.list = $('#' + this.options.listId); this.element.list.find('tbody').on('click.' + this.eventNS, '[data-type="' + this.options.enumType + '"] a', $.proxy(this.onEnumLinkClick, this)); return this; }; proto.onEnumLinkClick = function (e) { var that = this, target = $(e.target), href = target.prop('href'), cellNode = target.closest('[data-name]'), cellName = cellNode.data('name'); if (0 === cellNode.length) { return; } e.preventDefault(); if (cellNode.data('lock.' + this.eventNS)) { return; } this.lockCounter++; cellNode.data('lock.' + this.eventNS, true); qs.showLoading(); qs.ajax(href, {cell: cellName}, { qsShowLoading: false }).always(function () { that.lockCounter--; cellNode.removeData('lock.' + that.eventNS); if (0 == that.lockCounter) qs.hideLoading(); }).then(function (response) { if (response && !response.isError && response.html) { var content = $(response.html).find('tbody [data-name="' + cellName + '"]').contents(); cellNode.empty().append(content); } else { location.reload(); } }, function () { location.reload(); }); }; })(qs.defineNS('qs.viewController.list'));