tablesorter/dist/js/widgets/widget-saveSort.min.js

2 lines
1.1 KiB
JavaScript
Raw Normal View History

2018-03-18 13:49:07 +00:00
/*! Widget: saveSort - updated 2018-03-18 (v2.30.0) */
!function(t){"use strict";function s(s){var o=r.storage(s.table,"tablesorter-savesort");return o&&o.hasOwnProperty("sortList")&&t.isArray(o.sortList)?o.sortList:""}function o(t,o){return(o||s(t)).join(",")!==t.sortList.join(",")}var r=t.tablesorter||{};r.addWidget({id:"saveSort",priority:20,options:{saveSort:!0},init:function(t,s,o,r){s.format(t,o,r,!0)},format:function(t,a,e,i){var n,l=a.$table,v=!1!==e.saveSort,g={sortList:a.sortList},S=r.debug(a,"saveSort");S&&(n=new Date),l.hasClass("hasSaveSort")?v&&t.hasInitialized&&r.storage&&o(a)&&(r.storage(t,"tablesorter-savesort",g),S&&console.log("saveSort >> Saving last sort: "+a.sortList+r.benchmark(n))):(l.addClass("hasSaveSort"),g="",r.storage&&(g=s(a),S&&console.log('saveSort >> Last sort loaded: "'+g+'"'+r.benchmark(n)),l.bind("saveSortReset",function(s){s.stopPropagation(),r.storage(t,"tablesorter-savesort","")})),i&&g&&g.length>0?a.sortList=g:t.hasInitialized&&g&&g.length>0&&o(a,g)&&r.sortOn(a,g))},remove:function(t,s){s.$table.removeClass("hasSaveSort"),r.storage&&r.storage(t,"tablesorter-savesort","")}})}(jQuery);