!function(e){"use strict";var t=e.tablesorter,o=t.columnSelector={queryAll:"@media only all { [columns] { display: none; } } ",queryBreak:"@media all and (min-width: [size]) { [columns] { display: table-cell; } } ",init:function(t,l,a){var n,c;(n=e(a.columnSelector_layout)).find("input").add(n.filter("input")).length?(l.$table.addClass(l.namespace.slice(1)+"columnselector"),(c=l.selector={$container:e(a.columnSelector_container||"
")}).$style=e("").prop("disabled",!0).appendTo("head"),c.$breakpoints=e("").prop("disabled",!0).appendTo("head"),c.isInitializing=!0,o.setUpColspan(l,a),o.setupSelector(l,a),a.columnSelector_mediaquery&&o.setupBreakpoints(l,a),c.isInitializing=!1,c.$container.length?o.updateCols(l,a):l.debug&&console.warn("ColumnSelector: >> container not found"),l.$table.off("refreshColumnSelector.tscolsel").on("refreshColumnSelector.tscolsel",function(e,t,l){o.refreshColumns(this.config,t,l)})):l.debug&&console.error("ColumnSelector: >> ERROR: Column Selector aborting, no input found in the layout! ***")},refreshColumns:function(t,l,a){var n,c,r,s,u=t.selector,i=e.isArray(a||l),d=t.widgetOptions;if(void 0!==l&&null!==l&&u.$container.length){if("selectors"===l&&(u.$container.empty(),o.setupSelector(t,d),o.setupBreakpoints(t,d),void 0===a&&null!==a&&(a=u.auto)),i)for(c=a||l,e.each(c,function(e,t){c[e]=parseInt(t,10)}),n=0;n=0,(r=u.$container.find("input[data-column="+n+"]")).length&&(r.prop("checked",s),u.states[n]=s);s=!0===a||!0===l||"auto"===l&&!1!==a,r=u.$container.find('input[data-column="auto"]').prop("checked",s),o.updateAuto(t,d,r)}else o.updateBreakpoints(t,d),o.updateCols(t,d);o.saveValues(t,d),o.adjustColspans(t,d)},setupSelector:function(l,a){var n,c,r,s,u,i,d,p=l.selector,m=p.$container,h=a.columnSelector_saveColumns&&t.storage,f=h?t.storage(l.table,"tablesorter-columnSelector"):[],S=h?t.storage(l.table,"tablesorter-columnSelector-auto"):{};for(p.auto=e.isEmptyObject(S)||"boolean"!==e.type(S.auto)?a.columnSelector_mediaqueryState:S.auto,p.states=[],p.$column=[],p.$wrapper=[],p.$checkbox=[],n=0;n0||"disable"===S||a.columnSelector_columns[i]&&"disable"===a.columnSelector_columns[i]?p.states[i]=null:(p.states[i]=f&&void 0!==f[i]&&null!==f[i]?f[i]:void 0!==a.columnSelector_columns[i]&&null!==a.columnSelector_columns[i]?a.columnSelector_columns[i]:"true"===S||"false"!==S,p.$column[i]=e(this),m.length&&(c=r.attr(a.columnSelector_name)||r.text().trim(),"function"==typeof a.columnSelector_layoutCustomizer&&(d=r.find("."+t.css.headerIn),c=a.columnSelector_layoutCustomizer(d.length?d:r,c,parseInt(i,10))),p.$wrapper[i]=e(a.columnSelector_layout.replace(/\{name\}/g,c)).appendTo(m),p.$checkbox[i]=p.$wrapper[i].find("input").add(p.$wrapper[i].filter("input")).attr("data-column",i).toggleClass(a.columnSelector_cssChecked,p.states[i]).prop("checked",p.states[i]).on("change",function(){if(!p.isInitializing){var t=e(this).attr("data-column");if(!o.checkChange(l,this.checked))return this.checked=!this.checked,!1;l.selector.states[t]=this.checked,o.updateCols(l,a)}}).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;c-- >=0;)n[c]&&r++;return!(t&null!==l&&r>=l||!t&&null!==a&&r<=a)},setupBreakpoints:function(t,l){var a=t.selector;l.columnSelector_mediaquery&&(a.lastIndex=-1,o.updateBreakpoints(t,l),t.$table.off("updateAll.tscolsel").on("updateAll.tscolsel",function(){o.setupSelector(t,l),o.setupBreakpoints(t,l),o.updateBreakpoints(t,l),o.updateCols(t,l)})),a.$container.length&&(l.columnSelector_mediaquery&&(a.$auto=e(l.columnSelector_layout.replace(/\{name\}/g,l.columnSelector_mediaqueryName)).prependTo(a.$container),a.$auto.find("input").add(a.$auto.filter("input")).attr("data-column","auto").prop("checked",a.auto).toggleClass(l.columnSelector_cssChecked,a.auto).on("change",function(){o.updateAuto(t,l,e(this))}).change()),t.$table.off("update.tscolsel").on("update.tscolsel",function(){o.updateCols(t,l)}))},updateAuto:function(t,l,a){var n=t.selector;n.auto=a.prop("checked")||!1,e.each(n.$checkbox,function(e,t){t&&(t[0].disabled=n.auto,n.$wrapper[e].toggleClass("disabled",n.auto))}),l.columnSelector_mediaquery&&o.updateBreakpoints(t,l),o.updateCols(t,l),t.selector.$popup&&t.selector.$popup.find(".tablesorter-column-selector").html(n.$container.html()).find("input").each(function(){var t=e(this).attr("data-column");e(this).prop("checked","auto"===t?n.auto:n.states[t])}),o.saveValues(t,l),o.adjustColspans(t,l),n.auto&&t.$table.triggerHandler(l.columnSelector_updated)},addSelectors:function(e,t,o){var l=[],a=" col:nth-child("+o+")";return l.push(t+a+","+t+"_extra_table"+a),a=" tr:not(."+e.columnSelector_classHasSpan+') th[data-column="'+(o-1)+'"]',l.push(t+a+","+t+"_extra_table"+a),a=" tr:not(."+e.columnSelector_classHasSpan+") td:nth-child("+o+")",l.push(t+a+","+t+"_extra_table"+a),a=" tr td:not("+t+e.columnSelector_classHasSpan+')[data-column="'+(o-1)+'"]',l.push(t+a+","+t+"_extra_table"+a),l},updateBreakpoints:function(l,a){var n,c,r,s,u=[],i=l.selector,d=l.namespace+"columnselector",p=[],m="";if(a.columnSelector_mediaquery&&!i.auto)return i.$breakpoints.prop("disabled",!0),void i.$style.prop("disabled",!1);if(a.columnSelector_mediaqueryHidden)for(r=0;r1&&(u=!0,i.eq(n).addClass(l.namespace.slice(1)+"columnselector"+a.columnSelector_classHasSpan).attr("data-col-span",c),t.computeColumnIndex(i.eq(n).parent().addClass(a.columnSelector_classHasSpan)));u&&a.columnSelector_mediaquery&&(r=l.namespace+"columnselector",s.off(r).on("resize"+r,t.window_resize).on("resizeEnd"+r,function(){s.off("resize"+r,t.window_resize),o.adjustColspans(l,a),s.on("resize"+r,t.window_resize)}))},adjustColspans:function(t,o){var l,a,n,c,r,s,u=t.selector,i=o.filter_filteredRow||"filtered",d=o.columnSelector_mediaquery&&u.auto,p=t.$table.children("thead, tfoot").children().children().add(e(t.namespace+"_extra_table").children("thead, tfoot").children().children()).add(t.$table.find(".group-header").children()),m=p.length;for(l=0;l1){for(a=n;a'),a=r.selector,n=r.widgetOptions,s.find(".tablesorter-column-selector").html(a.$container.html()).find("input").each(function(){var t=e(this).attr("data-column"),o="auto"===t?a.auto:a.states[t];e(this).toggleClass(n.columnSelector_cssChecked,o).prop("checked",o)}),a.$popup=s.on("change","input",function(){if(!a.isInitializing){if(!o.checkChange(r,this.checked))return this.checked=!this.checked,!1;c=e(this).toggleClass(n.columnSelector_cssChecked,this.checked).attr("data-column"),a.$container.find('input[data-column="'+c+'"]').prop("checked",this.checked).trigger("change")}}))}};t.window_resize=function(){t.timer_resize&&clearTimeout(t.timer_resize),t.timer_resize=setTimeout(function(){e(window).trigger("resizeEnd")},250)},t.addWidget({id:"columnSelector",priority:10,options:{columnSelector_container:null,columnSelector_columns:{},columnSelector_saveColumns:!0,columnSelector_layout:'',columnSelector_layoutCustomizer:null,columnSelector_name:"data-selector-name",columnSelector_mediaquery:!0,columnSelector_mediaqueryName:"Auto: ",columnSelector_mediaqueryState:!0,columnSelector_mediaqueryHidden:!1,columnSelector_maxVisible:null,columnSelector_minVisible:null,columnSelector_breakpoints:["20em","30em","40em","50em","60em","70em"],columnSelector_maxPriorities:6,columnSelector_priority:"data-priority",columnSelector_cssChecked:"checked",columnSelector_classHasSpan:"hasSpan",columnSelector_updated:"columnUpdate"},init:function(e,t,l,a){o.init(e,l,a)},remove:function(t,o,l,a){var n=o.selector;!a&&n&&(n&&n.$container.empty(),n.$popup&&n.$popup.empty(),n.$style.remove(),n.$breakpoints.remove(),e(o.namespace+"columnselector"+l.columnSelector_classHasSpan).removeClass(l.filter_filteredRow||"filtered"),o.$table.find("[data-col-span]").each(function(t,o){var l=e(o);l.attr("colspan",l.attr("data-col-span"))}),o.$table.off("updateAll.tscolsel update.tscolsel"))}})}(jQuery);