|
@@ -46,6 +46,10 @@
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if ($.inArray(cookieName.toLowerCase(), that.options.cookiesEnabled) === -1) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
cookieName = that.options.cookieIdTable + '.' + cookieName;
|
|
cookieName = that.options.cookieIdTable + '.' + cookieName;
|
|
|
if (!cookieName || /^(?:expires|max\-age|path|domain|secure)$/i.test(cookieName)) {
|
|
if (!cookieName || /^(?:expires|max\-age|path|domain|secure)$/i.test(cookieName)) {
|
|
|
return false;
|
|
return false;
|
|
@@ -55,11 +59,17 @@
|
|
|
return true;
|
|
return true;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- var getCookie = function (tableName, cookieName) {
|
|
|
|
|
- cookieName = tableName + '.' + cookieName;
|
|
|
|
|
|
|
+ var getCookie = function (that, tableName, cookieName) {
|
|
|
if (!cookieName) {
|
|
if (!cookieName) {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ if ($.inArray(cookieName.toLowerCase(), that.options.cookiesEnabled) === -1) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ cookieName = tableName + '.' + cookieName;
|
|
|
|
|
+
|
|
|
return decodeURIComponent(document.cookie.replace(new RegExp('(?:(?:^|.*;)\\s*' + encodeURIComponent(cookieName).replace(/[\-\.\+\*]/g, '\\$&') + '\\s*\\=\\s*([^;]*).*$)|^.*$'), '$1')) || null;
|
|
return decodeURIComponent(document.cookie.replace(new RegExp('(?:(?:^|.*;)\\s*' + encodeURIComponent(cookieName).replace(/[\-\.\+\*]/g, '\\$&') + '\\s*\\=\\s*([^;]*).*$)|^.*$'), '$1')) || null;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -117,6 +127,7 @@
|
|
|
cookieDomain: null,
|
|
cookieDomain: null,
|
|
|
cookieSecure: null,
|
|
cookieSecure: null,
|
|
|
cookieIdTable: '',
|
|
cookieIdTable: '',
|
|
|
|
|
+ cookiesEnabled: ['bs.table.sortOrder', 'bs.table.sortName', 'bs.table.pageNumber', 'bs.table.pageList', 'bs.table.columns', 'bs.table.searchText', 'bs.table.filterControl'],
|
|
|
//internal variable
|
|
//internal variable
|
|
|
filterControls: [],
|
|
filterControls: [],
|
|
|
filterControlValuesLoaded: false
|
|
filterControlValuesLoaded: false
|
|
@@ -143,6 +154,10 @@
|
|
|
this.options.filterControls = [];
|
|
this.options.filterControls = [];
|
|
|
this.options.filterControlValuesLoaded = false;
|
|
this.options.filterControlValuesLoaded = false;
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ this.options.cookiesEnabled = typeof this.options.cookiesEnabled === 'string' ?
|
|
|
|
|
+ this.options.cookiesEnabled.replace('[', '').replace(']', '').replace(/ /g, '').toLowerCase().split(',') : this.options.cookiesEnabled;
|
|
|
|
|
+
|
|
|
if (this.options.filterControl) {
|
|
if (this.options.filterControl) {
|
|
|
var that = this;
|
|
var that = this;
|
|
|
this.$el.on('column-search.bs.table', function (e, field, text) {
|
|
this.$el.on('column-search.bs.table', function (e, field, text) {
|
|
@@ -167,7 +182,7 @@
|
|
|
setTimeout(function () {
|
|
setTimeout(function () {
|
|
|
if (!that.options.filterControlValuesLoaded) {
|
|
if (!that.options.filterControlValuesLoaded) {
|
|
|
that.options.filterControlValuesLoaded = true;
|
|
that.options.filterControlValuesLoaded = true;
|
|
|
- var filterControl = JSON.parse(getCookie(that.options.cookieIdTable, cookieIds.filterControl));
|
|
|
|
|
|
|
+ var filterControl = JSON.parse(getCookie(that, that.options.cookieIdTable, cookieIds.filterControl));
|
|
|
if (filterControl) {
|
|
if (filterControl) {
|
|
|
var field = null,
|
|
var field = null,
|
|
|
result = [],
|
|
result = [],
|
|
@@ -208,12 +223,12 @@
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- var sortOrderCookie = getCookie(this.options.cookieIdTable, cookieIds.sortOrder),
|
|
|
|
|
- sortOrderNameCookie = getCookie(this.options.cookieIdTable, cookieIds.sortName),
|
|
|
|
|
- pageNumberCookie = getCookie(this.options.cookieIdTable, cookieIds.pageNumber),
|
|
|
|
|
- pageListCookie = getCookie(this.options.cookieIdTable, cookieIds.pageList),
|
|
|
|
|
- columnsCookie = JSON.parse(getCookie(this.options.cookieIdTable, cookieIds.columns)),
|
|
|
|
|
- searchTextCookie = getCookie(this.options.cookieIdTable, cookieIds.searchText);
|
|
|
|
|
|
|
+ var sortOrderCookie = getCookie(this, this.options.cookieIdTable, cookieIds.sortOrder),
|
|
|
|
|
+ sortOrderNameCookie = getCookie(this, this.options.cookieIdTable, cookieIds.sortName),
|
|
|
|
|
+ pageNumberCookie = getCookie(this, this.options.cookieIdTable, cookieIds.pageNumber),
|
|
|
|
|
+ pageListCookie = getCookie(this, this.options.cookieIdTable, cookieIds.pageList),
|
|
|
|
|
+ columnsCookie = JSON.parse(getCookie(this, this.options.cookieIdTable, cookieIds.columns)),
|
|
|
|
|
+ searchTextCookie = getCookie(this, this.options.cookieIdTable, cookieIds.searchText);
|
|
|
|
|
|
|
|
//sortOrder
|
|
//sortOrder
|
|
|
this.options.sortOrder = sortOrderCookie ? sortOrderCookie : 'asc';
|
|
this.options.sortOrder = sortOrderCookie ? sortOrderCookie : 'asc';
|