mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
5 lines
1.4 KiB
JavaScript
5 lines
1.4 KiB
JavaScript
/*! tablesorter enable/disable sort & filter (BETA) - 11/10/2015 (v2.24.4)
|
|
* Requires tablesorter v2.24.4+ & jQuery 1.7+
|
|
* by Rob Garrison
|
|
*/
|
|
!function(a){"use strict";var b=a.tablesorter,c=b.toggleTS={init:function(a,b){b.toggleTS_isEnabled=!0,b.toggleTS_areDisabled={headers:[],filters:[]},a.$table.on("enable.toggleTS disable.toggleTS",function(a){c.toggle(this.config,this.config.widgetOptions,"enable"===a.type)})},toggle:function(a,c,d){if(c.toggleTS_isEnabled!==d){c.toggleTS_isEnabled=d;var e,f,g=a.$headers.length;for(e=0;e<g;e++)f=a.$headers.eq(e),b.setColumnSort(a,f,!d),b.setColumnAriaLabel(a,f,d);if(c.toggleTS_hideFilterRow)a.$table.find("."+b.css.filterRow).toggle(d);else if(b.hasWidget(a.$table,"filter"))for(g=a.$filters.length,e=0;e<g;e++)d&&!c.toggleTS_areDisabled.filters[e]?a.$filters.eq(e).find("input, select").removeClass(b.css.filterDisabled).prop("disabled",!1):d||(f=a.$filters.eq(e).find("input, select"),f.hasClass(b.css.filterDisabled)&&(c.toggleTS_areDisabled.filters[e]=!0),f.addClass(b.css.filterDisabled).prop("disabled",!0));c.filter_$externalFilters.toggleClass(b.css.filterDisabled,d).prop("disabled",!d)}"function"==typeof c.toggleTS_callback&&c.toggleTS_callback(a,d)}};b.addWidget({id:"toggle-ts",options:{toggleTS_hideFilterRow:!1,toggleTS_callback:null},init:function(a,b,d,e){c.init(d,e)},remove:function(a,b){b.$table.off("enable.toggleTS disable.toggleTS")}})}(jQuery); |