浏览代码

Merge pull request #1062 from djhvscf/master

Fix Cookie Extension - pageSize 10
文翼 10 年之前
父节点
当前提交
9a5916582b
共有 2 个文件被更改,包括 28 次插入24 次删除
  1. 2 2
      src/extensions/cookie/bootstrap-table-cookie.js
  2. 26 22
      src/extensions/mobile/bootstrap-table-mobile.js

+ 2 - 2
src/extensions/cookie/bootstrap-table-cookie.js

@@ -142,9 +142,9 @@
         //sortName
         this.options.sortName = sortOrderNameCookie ? sortOrderNameCookie : undefined;
         //pageNumber
-        this.options.pageNumber = pageNumberCookie ? +pageNumberCookie : 1;
+        this.options.pageNumber = pageNumberCookie ? +pageNumberCookie : this.options.pageNumber;
         //pageSize
-        this.options.pageSize = pageListCookie ? pageListCookie === this.options.formatAllRows() ? pageListCookie : +pageListCookie : 10;
+        this.options.pageSize = pageListCookie ? pageListCookie === this.options.formatAllRows() ? pageListCookie : +pageListCookie : this.options.pageSize;
         //searchText
         this.options.searchText = searchTextCookie ? searchTextCookie : '';
 

+ 26 - 22
src/extensions/mobile/bootstrap-table-mobile.js

@@ -16,15 +16,15 @@
 
     var changeView = function (that, width, height) {
         if (that.options.minHeight) {
-            if (checkValuesLessEqual(width, that.options.minWidth) && checkValuesLessEqual(height, that.options.minHeight)) {
+            if ((width <= that.options.minWidth) && (height <= that.options.minHeight)) {
                 conditionCardView(that);
-            } else if (checkValuesGreater(width, that.options.minWidth) && checkValuesGreater(height, that.options.minHeight)) {
+            } else if ((width > that.options.minWidth) && (height > that.options.minHeight)) {
                 conditionFullView(that);
             }
         } else {
-            if (checkValuesLessEqual(width, that.options.minWidth)) {
+            if (width <= that.options.minWidth) {
                 conditionCardView(that);
-            } else if (checkValuesGreater(width, that.options.minWidth)) {
+            } else if (width > that.options.minWidth) {
                 conditionFullView(that);
             }
         }
@@ -32,14 +32,6 @@
         resetView(that);
     };
 
-    var checkValuesLessEqual = function (currentValue, targetValue) {
-        return currentValue <= targetValue;
-    };
-
-    var checkValuesGreater = function (currentValue, targetValue) {
-        return currentValue > targetValue;
-    };
-
     var conditionCardView = function (that) {
         changeTableView(that, false);
     };
@@ -71,8 +63,7 @@
         minWidth: 562,
         minHeight: undefined,
         heightThreshold: 100, // just slightly larger than mobile chrome's auto-hiding toolbar
-        checkOnInit: true,
-        toggled: false
+        checkOnInit: true
     });
 
     var BootstrapTable = $.fn.bootstrapTable.Constructor,
@@ -89,21 +80,34 @@
             return;
         }
 
-        var that = this, old = { w: $(window).width(), h: $(window).height() };
+        var that = this,
+            old = {
+                width: $(window).width(),
+                height: $(window).height()
+            };
 
         $(window).on('resize orientationchange',debounce(function (evt) {
             // reset view if height has only changed by at least the threshold.
-            var h = $(this).height(), w = $(this).width();
-            if (Math.abs(old.h - h) > that.options.heightThreshold || old.w != w) {
-                changeView(that, w, h);
-                old = { w: w, h: h };
+            var height = $(this).height(),
+                width = $(this).width();
+
+            if (Math.abs(old.height - height) > that.options.heightThreshold || old.width != width) {
+                changeView(that, width, height);
+                old = {
+                    width: width,
+                    height: height
+                };
             }
         },200));
 
         if (this.options.checkOnInit) {
-            var h = $(window).height(), w = $(window).width();
-            changeView(this, w, h);
-            old = { w: w, h: h };
+            var height = $(window).height(),
+                width = $(window).width();
+            changeView(this, width, height);
+            old = {
+                width: width,
+                height: height
+            };
         }
     };
 }(jQuery);