ソースを参照

Improve the cookie extension

Dennis Hernández 10 年 前
コミット
eace765330

+ 2 - 2
src/extensions/cookie/README.md

@@ -38,13 +38,13 @@ Use Plugin: [bootstrap-table-cookie](https://github.com/wenzhixin/bootstrap-tabl
 ### cookieSecure
 
 * type: Boolean
-* description: This property keep cookie communication limited to encrypted transmission, directing browsers to use cookies only via secure/encrypted connections.
+* description: This property keeps cookie communication limited to encrypted transmission, directing browsers to use cookies only via secure/encrypted connections.
 * default: `null`
 
 ### cookieIdTable
 
 * type: String
-* description: You must set this property if stateSave is enable to sets an unique cookie with an identifier for each table in your page or project. You must set this property because we need create cookies with an identifier.
+* description: You must set this property if the cookie property is enabled to set an unique cookie with an identifier for each table in your page or project. You must set this property because we need create cookies with an identifier.
 * default: ``
 
 ## This plugin saves

+ 5 - 9
src/extensions/cookie/bootstrap-table-cookie.js

@@ -19,10 +19,10 @@
     };
 
     var cookieEnabled = function () {
-        return (navigator.cookieEnabled) ? true : false;
+        return !!(navigator.cookieEnabled);
     };
 
-    var setCookie = function (that, cookieName, sValue) {
+    var setCookie = function (that, cookieName, cookieValue) {
         if ((!that.options.stateSave) || (!cookieEnabled()) || (that.options.cookieIdTable === '')) {
             return;
         }
@@ -32,7 +32,7 @@
             return false;
         }
 
-        document.cookie = encodeURIComponent(cookieName) + '=' + encodeURIComponent(sValue) + calculateExpiration(that.options.cookieExpire) + (that.options.cookieDomain ? '; domain=' + that.options.cookieDomain : '') + (that.options.cookiePath ? '; path=' + that.options.cookiePath : '') + (that.cookieSecure ? '; secure' : '');
+        document.cookie = encodeURIComponent(cookieName) + '=' + encodeURIComponent(cookieValue) + calculateExpiration(that.options.cookieExpire) + (that.options.cookieDomain ? '; domain=' + that.options.cookieDomain : '') + (that.options.cookiePath ? '; path=' + that.options.cookiePath : '') + (that.cookieSecure ? '; secure' : '');
         return true;
     };
 
@@ -125,11 +125,7 @@
             return;
         }
 
-        if (!cookieEnabled()) {
-            return;
-        }
-
-        if (this.options.cookieIdTable === '' || this.options.cookieExpire === '') {
+        if ((this.options.cookieIdTable === '') || (this.options.cookieExpire === '') || (!cookieEnabled())) {
             return;
         }
 
@@ -218,6 +214,6 @@
             return;
         }
 
-        deleteCookie(cookieIds[cookieName], this.options.cookiePath, this.options.cookieDomain);
+        deleteCookie(this.options.cookieIdTable, cookieIds[cookieName], this.options.cookiePath, this.options.cookieDomain);
     };
 })(jQuery);

+ 3 - 7
src/extensions/filter-control/bootstrap-table-filter-control.js

@@ -292,20 +292,16 @@
             pageTo = this.pageTo < this.options.data.length ? this.options.data.length : this.pageTo;
 
         for (var i = this.pageFrom - 1; i < pageTo; i++) {
-            var key,
-                item = data[i];
+            var item = data[i];
 
             $.each(this.header.fields, function (j, field) {
                 var value = item[field],
                     column = that.options.columns[getFieldIndex(that.options.columns, field)];
 
-                value = calculateObjectValue(that.header,
-                    that.header.formatters[j], [value, item, i], value);
+                value = calculateObjectValue(that.header, that.header.formatters[j], [value, item, i], value);
 
                 if ((!column.checkbox) || (!column.radio)) {
-                    if (column.filterControl !== undefined && column.filterControl.toLowerCase() === 'select'
-                            && column.searchable) {
-
+                    if (column.filterControl !== undefined && column.filterControl.toLowerCase() === 'select' && column.searchable) {
                         if (column.filterData === undefined || column.filterData.toLowerCase() === 'column') {
                             var selectControl = $('.' + column.field);
                             if (selectControl !== undefined && selectControl.length > 0) {