!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(l,a,n){var c,r,s=t.debug(a,"columnSelector");(c=e(n.columnSelector_layout)).find("input").add(c.filter("input")).length?(a.$table.addClass(a.namespace.slice(1)+"columnselector"),(r=a.selector={$container:e(n.columnSelector_container||"
")}).$style=e("").prop("disabled",!0).appendTo("head"),r.$breakpoints=e("").prop("disabled",!0).appendTo("head"),r.isInitializing=!0,o.setUpColspan(a,n),o.setupSelector(a,n),n.columnSelector_mediaquery&&o.setupBreakpoints(a,n),r.isInitializing=!1,r.$container.length?o.updateCols(a,n):s&&console.warn("ColumnSelector >> container not found"),a.$table.off("refreshColumnSelector.tscolsel").on("refreshColumnSelector.tscolsel",function(e,t,l){o.refreshColumns(this.config,t,l)}),s&&console.log("ColumnSelector >> Widget initialized")):s&&console.error("ColumnSelector >> ERROR: Column Selector aborting, no input found in the layout! ***")},refreshColumns:function(t,l,a){var n,c,r,s,i=t.selector,u=e.isArray(a||l),d=t.widgetOptions;if(void 0!==l&&null!==l&&i.$container.length){if("selectors"===l&&(i.$container.empty(),o.setupSelector(t,d),o.setupBreakpoints(t,d),void 0===a&&null!==a&&(a=i.auto)),u)for(c=a||l,e.each(c,function(e,t){c[e]=parseInt(t,10)}),n=0;n=0,(r=i.$container.find("input[data-column="+n+"]")).length&&(r.prop("checked",s),i.states[n]=s);s=!0===a||!0===l||"auto"===l&&!1!==a,r=i.$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,i,u,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[u]&&"disable"===a.columnSelector_columns[u]?p.states[u]=null:(p.states[u]=f&&void 0!==f[u]&&null!==f[u]?f[u]:void 0!==a.columnSelector_columns[u]&&null!==a.columnSelector_columns[u]?a.columnSelector_columns[u]:"true"===S||"false"!==S,p.$column[u]=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(u,10))),p.$wrapper[u]=e(a.columnSelector_layout.replace(/\{name\}/g,c)).appendTo(m),p.$checkbox[u]=p.$wrapper[u].find("input").add(p.$wrapper[u].filter("input")).attr("data-column",u).toggleClass(a.columnSelector_cssChecked,p.states[u]).prop("checked",p.states[u]).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,i=[],u=l.selector,d=l.namespace+"columnselector",p=[],m="";if(a.columnSelector_mediaquery&&!u.auto)return u.$breakpoints.prop("disabled",!0),void u.$style.prop("disabled",!1);if(a.columnSelector_mediaqueryHidden)for(r=0;r1&&(i=!0,u.eq(n).addClass(l.namespace.slice(1)+"columnselector"+a.columnSelector_classHasSpan).attr("data-col-span",c),t.computeColumnIndex(u.eq(n).parent().addClass(a.columnSelector_classHasSpan)));i&&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,i=t.selector,u=o.filter_filteredRow||"filtered",d=o.columnSelector_mediaquery&&i.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);