|
|
@@ -68,19 +68,18 @@
|
|
|
switch(that.options.cookieStorage) {
|
|
|
case 'cookieStorage':
|
|
|
document.cookie = [
|
|
|
- cookieName, '=', cookieValue,
|
|
|
- '; expires=' + that.options.cookieExpire,
|
|
|
- that.options.cookiePath ? '; path=' + that.options.cookiePath : '',
|
|
|
- that.options.cookieDomain ? '; domain=' + that.options.cookieDomain : '',
|
|
|
- that.options.cookieSecure ? '; secure' : ''
|
|
|
- ].join('');
|
|
|
- break;
|
|
|
+ cookieName, '=', cookieValue,
|
|
|
+ '; expires=' + calculateExpiration(that.options.cookieExpire),
|
|
|
+ that.options.cookiePath ? '; path=' + that.options.cookiePath : '',
|
|
|
+ that.options.cookieDomain ? '; domain=' + that.options.cookieDomain : '',
|
|
|
+ that.options.cookieSecure ? '; secure' : ''
|
|
|
+ ].join('');
|
|
|
case 'localStorage':
|
|
|
localStorage.setItem(cookieName, cookieValue);
|
|
|
- break;
|
|
|
+ break;
|
|
|
case 'sessionStorage':
|
|
|
sessionStorage.setItem(cookieName, cookieValue);
|
|
|
- break;
|
|
|
+ break;
|
|
|
default:
|
|
|
return false;
|
|
|
}
|
|
|
@@ -113,22 +112,22 @@
|
|
|
|
|
|
var deleteCookie = function (that, tableName, cookieName) {
|
|
|
cookieName = tableName + '.' + cookieName;
|
|
|
-
|
|
|
+
|
|
|
switch(that.options.cookieStorage) {
|
|
|
case 'cookieStorage':
|
|
|
document.cookie = [
|
|
|
- encodeURIComponent(cookieName), '=',
|
|
|
- '; expires=Thu, 01 Jan 1970 00:00:00 GMT',
|
|
|
- that.options.cookiePath ? '; path=' + that.options.cookiePath : '',
|
|
|
- that.options.cookieDomain ? '; domain=' + that.options.cookieDomain : '',
|
|
|
- ].join('');
|
|
|
+ encodeURIComponent(cookieName), '=',
|
|
|
+ '; expires=Thu, 01 Jan 1970 00:00:00 GMT',
|
|
|
+ that.options.cookiePath ? '; path=' + that.options.cookiePath : '',
|
|
|
+ that.options.cookieDomain ? '; domain=' + that.options.cookieDomain : '',
|
|
|
+ ].join('');
|
|
|
break;
|
|
|
case 'localStorage':
|
|
|
localStorage.removeItem(cookieName);
|
|
|
- break;
|
|
|
+ break;
|
|
|
case 'sessionStorage':
|
|
|
sessionStorage.removeItem(cookieName);
|
|
|
- break;
|
|
|
+ break;
|
|
|
|
|
|
}
|
|
|
return true;
|
|
|
@@ -136,7 +135,7 @@
|
|
|
|
|
|
var calculateExpiration = function(cookieExpire) {
|
|
|
var time = cookieExpire.replace(/[0-9]*/, ''); //s,mi,h,d,m,y
|
|
|
- cookieExpire = cookieExpire.replace(/[A-Za-z]{1,2}}/, ''); //number
|
|
|
+ cookieExpire = cookieExpire.replace(/[A-Za-z]{1,2}/, ''); //number
|
|
|
|
|
|
switch (time.toLowerCase()) {
|
|
|
case 's':
|
|
|
@@ -161,8 +160,12 @@
|
|
|
cookieExpire = undefined;
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
- return cookieExpire === undefined ? '' : '; max-age=' + cookieExpire;
|
|
|
+ if(!cookieExpire){
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ var d = new Date();
|
|
|
+ d.setTime(d.getTime() + cookieExpire*1000);
|
|
|
+ return d.toGMTString();
|
|
|
};
|
|
|
|
|
|
var initCookieFilters = function (bootstrapTable) {
|
|
|
@@ -247,7 +250,7 @@
|
|
|
this.options.cookiesEnabled = typeof this.options.cookiesEnabled === 'string' ?
|
|
|
this.options.cookiesEnabled.replace('[', '').replace(']', '')
|
|
|
.replace(/ /g, '').toLowerCase().split(',') :
|
|
|
- this.options.cookiesEnabled;
|
|
|
+ this.options.cookiesEnabled;
|
|
|
|
|
|
if (this.options.filterControl) {
|
|
|
var that = this;
|
|
|
@@ -392,7 +395,7 @@
|
|
|
_onSearch.apply(this, target);
|
|
|
|
|
|
if ($(target[0].currentTarget).parent().hasClass('search')) {
|
|
|
- setCookie(this, cookieIds.searchText, this.searchText);
|
|
|
+ setCookie(this, cookieIds.searchText, this.searchText);
|
|
|
}
|
|
|
};
|
|
|
|