var addAll2FilterCombobox = false; function IobListHeader(header, options) { if (!(this instanceof IobListHeader)) return new IobListHeader(header, options); if (options === undefined) options = {}; if (options.colWidthOffset === undefined) options.colWidthOffset = 0; var $headerThs; var $listTds; var $header; $header = typeof header === 'object' ? $(header) : $('#' + header); if ($header[0].tagName === 'TABLE') $header = $header.find('tr:first'); header = $header[0]; var that = this; that.selectIdOffset = []; $header.html(''); this.setList = function (_list) { var $tds; if (typeof _list === 'string') { if (_list[0] !== '#') { _list = '#' + _list; } $tds = $(_list) } else { $tds = _list; } if (!$tds || !$tds.length) return; if ($tds[0].tagName !== 'TD' && $tds[0].tagName !== 'TH') { $tds = $tds.find('>thead>tr:first>th,>thead>tr:first>td'); if (!$tds.length) $tds = _list.find('>tbody>tr:first>th,>tr:first>th,>tbody>tr:first>td, >tr:first>td'); } $listTds = $tds; }; if (options.list) { this.setList(options.list); } this.syncHeader = function () { if (typeof $listTds !== 'object') return; var syncHeader = function () { $listTds.each(function (i, o) { if (i >= $listTds.length - 1) return; var x = $(o).width(); var offset = that.selectIdOffset[i] || 0; if (x + offset) { $($headerThs[i]).width(Math.round(x + offset)); } }); if ($listTds.length && !that.selectIdOffset.length) { that.selectIdOffset[0] = 0; $listTds.each(function (i, o) { //if (i >= $listTds.length - 1) return; var x = $($listTds[i]).offset().left; if (x) { that.selectIdOffset[i] = x - $($headerThs[i]).offset().left; } }); syncHeader(); } }; syncHeader(); }; var resizeTimer; $(window).on('resize', function (x, y) { if (resizeTimer) clearTimeout(resizeTimer); resizeTimer = setTimeout(that.syncHeader.bind(that), 100); }); function buildId(id, fis) { if (!id || (fis && id[0] === '#')) return id; if (options.prefix && id.substr(0, options.prefix.length) !== options.prefix) { id = options.prefix + '-' + id; } return (fis ? '#' : '') + id; } this.doFilter = function () {}; function allOption(name, selectedVal) { if (addAll2FilterCombobox) { name = name ? _(name) + ' ('+_('all') + ')' : _('all'); } return ''; } that.ids = []; that.add = function (what, title, _id, selectOptions) { if (_id === undefined) _id = title; var id = buildId(_id); title = _(title); var txt = ''; switch (what) { case 'combobox': txt = ' ' + ' '; break; case 'edit': txt = ' ' + ' '; break; case 'text': txt = '' + title + ''; break; } $header.append('