浏览代码

Merge pull request #746 from djhvscf/master

Improving the extensions code
文翼 10 年之前
父节点
当前提交
eb7054442e
共有 2 个文件被更改,包括 23 次插入21 次删除
  1. 0 1
      src/extensions/cookie/bootstrap-table-cookie.js
  2. 23 20
      src/extensions/mobile/bootstrap-table-mobile.js

+ 0 - 1
src/extensions/cookie/bootstrap-table-cookie.js

@@ -117,7 +117,6 @@
     };
     };
 
 
     BootstrapTable.prototype.initStateSave = function () {
     BootstrapTable.prototype.initStateSave = function () {
-        var that = this;
         if (!this.options.stateSave) {
         if (!this.options.stateSave) {
             return;
             return;
         }
         }

+ 23 - 20
src/extensions/mobile/bootstrap-table-mobile.js

@@ -8,28 +8,28 @@
 
 
     'use strict';
     'use strict';
 
 
-    var resetView = function (el) {
-        if (el.options.height || el.options.showFooter) {
-            setTimeout(el.resetView(), 1);
+    var resetView = function (that) {
+        if (that.options.height || that.options.showFooter) {
+            setTimeout(that.resetView(), 1);
         }
         }
     };
     };
 
 
-    var changeView = function (el, width, height) {
-        if (el.options.minHeight) {
-            if (checkValuesLessEqual(width, el.options.minWidth) && checkValuesLessEqual(height, el.options.minHeight)) {
-                conditionCardView(el);
-            } else if (checkValuesGreater(width, el.options.minWidth) && checkValuesGreater(height, el.options.minHeight)) {
-                conditionFullView(el);
+    var changeView = function (that, width, height) {
+        if (that.options.minHeight) {
+            if (checkValuesLessEqual(width, that.options.minWidth) && checkValuesLessEqual(height, that.options.minHeight)) {
+                conditionCardView(that);
+            } else if (checkValuesGreater(width, that.options.minWidth) && checkValuesGreater(height, that.options.minHeight)) {
+                conditionFullView(that);
             }
             }
         } else {
         } else {
-            if (checkValuesLessEqual(width, el.options.minWidth)) {
-                conditionCardView(el);
-            } else if (checkValuesGreater(width, el.options.minWidth)) {
-                conditionFullView(el);
+            if (checkValuesLessEqual(width, that.options.minWidth)) {
+                conditionCardView(that);
+            } else if (checkValuesGreater(width, that.options.minWidth)) {
+                conditionFullView(that);
             }
             }
         }
         }
 
 
-        resetView(el);
+        resetView(that);
     };
     };
 
 
     var checkValuesLessEqual = function (currentValue, targetValue) {
     var checkValuesLessEqual = function (currentValue, targetValue) {
@@ -40,14 +40,17 @@
         return currentValue > targetValue;
         return currentValue > targetValue;
     };
     };
 
 
-    var conditionCardView = function (el) {
-        el.options.cardView = false;
-        el.toggleView();
+    var conditionCardView = function (that) {
+        changeTableView(that, false);
     };
     };
 
 
-    var conditionFullView = function (el) {
-        el.options.cardView = true;
-        el.toggleView();
+    var conditionFullView = function (that) {
+        changeTableView(that, true);
+    };
+
+    var changeTableView = function (that, cardViewState) {
+        that.options.cardView = cardViewState;
+        that.toggleView();
     };
     };
 
 
     $.extend($.fn.bootstrapTable.defaults, {
     $.extend($.fn.bootstrapTable.defaults, {