mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-12-05 05:04:20 +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(e){"use strict";var l=e.tablesorter,t=l.toggleTS={init:function(e,l){l.toggleTS_isEnabled=!0,l.toggleTS_areDisabled={headers:[],filters:[]},e.$table.on("enable.toggleTS disable.toggleTS",function(e){t.toggle(this.config,this.config.widgetOptions,"enable"===e.type)})},toggle:function(e,t,i){if(t.toggleTS_isEnabled!==i){t.toggleTS_isEnabled=i;var s,o,g=e.$headers.length;for(s=0;s<g;s++)o=e.$headers.eq(s),l.setColumnSort(e,o,!i),l.setColumnAriaLabel(e,o,i);if(t.toggleTS_hideFilterRow)e.$table.find("."+l.css.filterRow).toggle(i);else if(l.hasWidget(e.$table,"filter"))for(g=e.$filters.length,s=0;s<g;s++)i&&!t.toggleTS_areDisabled.filters[s]?e.$filters.eq(s).find("input, select").removeClass(l.css.filterDisabled).prop("disabled",!1):i||((o=e.$filters.eq(s).find("input, select")).hasClass(l.css.filterDisabled)&&(t.toggleTS_areDisabled.filters[s]=!0),o.addClass(l.css.filterDisabled).prop("disabled",!0));t.filter_$externalFilters.toggleClass(l.css.filterDisabled,i).prop("disabled",!i)}"function"==typeof t.toggleTS_callback&&t.toggleTS_callback(e,i)}};l.addWidget({id:"toggle-ts",options:{toggleTS_hideFilterRow:!1,toggleTS_callback:null},init:function(e,l,i,s){t.init(i,s)},remove:function(e,l){l.$table.off("enable.toggleTS disable.toggleTS")}})}(jQuery); |