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