tablesorter/dist/js/widgets/widget-storage.min.js
Rob Garrison 72b45976d8 v2.28.8
2017-04-18 19:50:08 -05:00

2 lines
1.5 KiB
JavaScript

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