tablesorter/dist/js/widgets/widget-storage.min.js
Rob Garrison 8b1ba542db 2.30.0
2018-03-18 09:25:52 -05:00

2 lines
1.5 KiB
JavaScript

/*! Widget: storage - updated 2018-03-18 (v2.30.0) */
!function(e,t,r){"use strict";var o=e.tablesorter||{};e.extend(!0,o.defaults,{fixedUrl:"",widgetOptions:{storage_fixedUrl:"",storage_group:"",storage_page:"",storage_storageType:"",storage_tableId:"",storage_useSessionStorage:""}}),o.storage=function(s,a,i,g){var n,p,l,d=!1,u={},S=(s=e(s)[0]).config,c=S&&S.widgetOptions,_=o.debug(S,"storage"),f=(g&&g.storageType||c&&c.storage_storageType).toString().charAt(0).toLowerCase(),m=f?"":g&&g.useSessionStorage||c&&c.storage_useSessionStorage,y=e(s),O=g&&g.id||y.attr(g&&g.group||c&&c.storage_group||"data-table-group")||c&&c.storage_tableId||s.id||e(".tablesorter").index(y),w=g&&g.url||y.attr(g&&g.page||c&&c.storage_page||"data-table-page")||c&&c.storage_fixedUrl||S&&S.fixedUrl||t.location.pathname;if("c"!==f&&(f="s"===f||m?"sessionStorage":"localStorage")in t)try{t[f].setItem("_tmptest","temp"),d=!0,t[f].removeItem("_tmptest")}catch(e){console.warn(f+" is not supported in this browser")}if(_&&console.log("Storage >> Using",d?f:"cookies"),e.parseJSON&&(d?u=e.parseJSON(t[f][a]||"null")||{}:(p=r.cookie.split(/[;\s|=]/),u=0!==(n=e.inArray(a,p)+1)?e.parseJSON(p[n]||"null")||{}:{})),void 0===i||!t.JSON||!JSON.hasOwnProperty("stringify"))return u&&u[w]?u[w][O]:"";u[w]||(u[w]={}),u[w][O]=i,d?t[f][a]=JSON.stringify(u):((l=new Date).setTime(l.getTime()+31536e6),r.cookie=a+"="+JSON.stringify(u).replace(/\"/g,'"')+"; expires="+l.toGMTString()+"; path=/")}}(jQuery,window,document);