|
|
|
!function(h){"use strict";var f=h.tablesorter,c=".tscolsel",S=f.columnSelector={queryAll:"@media only all { [columns] { display: none; } } ",queryBreak:"@media all and (min-width: [size]) { [columns] { display: table-cell; } } ",init:function(e,t,o){var l,a,n=f.debug(t,"columnSelector");(l=h(o.columnSelector_layout)).find("input").add(l.filter("input")).length?(t.$table.addClass(t.namespace.slice(1)+"columnselector"),(a=t.selector={$container:h(o.columnSelector_container||"<div>")}).$style=h("<style></style>").prop("disabled",!0).appendTo("head"),a.$breakpoints=h("<style></style>").prop("disabled",!0).appendTo("head"),a.isInitializing=!0,S.setUpColspan(t,o),S.setupSelector(t,o),o.columnSelector_mediaquery&&S.setupBreakpoints(t,o),a.isInitializing=!1,a.$container.length?S.updateCols(t,o):n&&console.warn("ColumnSelector >> container not found"),t.$table.off("refreshColumnSelector"+c).on("refreshColumnSelector"+c,function(e,t,o){S.refreshColumns(this.config,t,o)}),n&&console.log("ColumnSelector >> Widget initialized")):n&&console.error("ColumnSelector >> ERROR: Column Selector aborting, no input found in the layout! ***")},refreshColumns:function(e,t,o){var l,a,n,c,r=e.selector,s=h.isArray(o||t),i=e.widgetOptions;if(null!=t&&r.$container.length){if("selectors"===t&&(r.$container.empty(),S.setupSelector(e,i),S.setupBreakpoints(e,i),void 0===o&&null!==o&&(o=r.auto)),s)for(a=o||t,h.each(a,function(e,t){a[e]=parseInt(t,10)}),l=0;l<e.columns;l++)c=0<=h.inArray(l,a),(n=r.$container.find("input[data-column="+l+"]")).length&&(n.prop("checked",c),r.states[l]=c);c=!0===o||!0===t||"auto"===t&&!1!==o,n=r.$container.find('input[data-column="auto"]').prop("checked",c),S.updateAuto(e,i,n)}else S.updateBreakpoints(e,i),S.updateCols(e,i);S.saveValues(e,i),S.adjustColspans(e,i)},setupSelector:function(t,o){var e,l,a,n,c,r,s,i=t.selector,u=i.$container,d=o.columnSelector_saveColumns&&f.storage,p=d?f.storage(t.table,"tablesorter-columnSelector"):[],m=d?f.storage(t.table,"tablesorter-columnSelector-auto"):{};for(i.auto=h.isEmptyObject(m)||"boolean"!==h.type(m.auto)?o.columnSelector_mediaqueryState:m.auto,i.states=[],i.$column=[],i.$wrapper=[],i.$checkbox=[],e=0;e<t.columns;e++)n=(a=t.$headerIndexed[e]).attr(o.columnSelector_priority)||1,r=a.attr("data-column"),c=f.getColumnData(t.table,t.headers,r),m=f.getData(a,c,"columnSelector"),isNaN(n)&&0<n.length||"disable"===m||o.columnSelector_columns[r]&&"disable"===o.columnSelector_columns[r]?i.states[r]=null:(i.states[r]=p&&void 0!==p[r]&&null!==p[r]?p[r]:void 0!==o.columnSelector_columns[r]&&null!==o.columnSelector_columns[r]?o.columnSelector_columns[r]:"true"===m||"false"!==m,i.$column[r]=h(this),u.length&&(l=a.attr(o.columnSelector_name)||a.text().trim(),"function"==typeof o.columnSelector_layoutCustomizer&&(s=a.find("."+f.css.headerIn),l=o.columnSelector_layoutCustomizer(s.length?s:a,l,parseInt(r,10))),i.$wrapper[r]=h(o.columnSelector_layout.replace(/\{name\}/g,l)).appendTo(u),i.$checkbox[r]=i.$wrapper[r].find("input").add(i.$wrapper[r].filter("input")).attr("data-column",r).toggleClass(o.columnSelector_cssChecked,i.states[r]).prop("checked",i.states[r]).on("change",function(){if(!i.isInitializing){var e=h(this).attr("data-column");if(!S.checkChange(t,this.checked))return this.checked=!this.checked,!1;t.selector.states[e]=this.checked,S.updateCols(t,o)}}).change()))},checkChange:function(e,t){for(var o=e.widgetOptions,l=o.columnSelector_maxVisible,a=o.columnSelector_minVisible,n=e.selector.states,c=n.length,r=0;0<=c--;)n[c]&&r++;return!(t&null!==l&&l<=r||!t&&null!==a&&r<=a)},setupBreakpoints:function(e,t){var o=e.selector;t.columnSelector_mediaquery&&(o.lastIndex=-1,S.updateBreakpoints(e,t),e.$table.off("updateAll"+c).on("updateAll"+c,function(){S.setupSelector(e,t),S.setupBreakpoints(e,t),S.updateBreakpoints(e,t),S.updateCols(e,t)})),o.$container.length&&(t.columnSelector_mediaquery&&(o.$auto=h(t.columnSelector_layout.replace(/\{name\}/g,t.columnSelector_mediaqueryName)).prependTo(o.$container),o.$auto.find("input").add(o.$auto.filter("input")).attr("data-column","auto").prop("checked",o.auto).
|