Browse Source

Improve the mobile extension

Dennis Hernández 10 years ago
parent
commit
2588a5eb59
1 changed files with 12 additions and 9 deletions
  1. 12 9
      src/extensions/mobile/bootstrap-table-mobile.js

+ 12 - 9
src/extensions/mobile/bootstrap-table-mobile.js

@@ -17,15 +17,15 @@
     var changeView = function (el, width, height) {
         if (el.options.minHeight) {
             if (checkValuesLessEqual(width, el.options.minWidth) && checkValuesLessEqual(height, el.options.minHeight)) {
-                checkToggledStatus(false, true, el);
+                conditionCardView(el);
             } else if (checkValuesGreater(width, el.options.minWidth) && checkValuesGreater(height, el.options.minHeight)) {
-                checkToggledStatus(true, false, el);
+                conditionFullView(el);
             }
         } else {
             if (checkValuesLessEqual(width, el.options.minWidth)) {
-                checkToggledStatus(false, true, el);
+                conditionCardView(el);
             } else if (checkValuesGreater(width, el.options.minWidth)) {
-                checkToggledStatus(true, false, el);
+                conditionFullView(el);
             }
         }
 
@@ -40,11 +40,14 @@
         return currentValue > targetValue;
     };
 
-    var checkToggledStatus = function (targetToggledStatus, newToggledStatus, el) {
-        if (el.options.toggled === targetToggledStatus) {
-            el.toggleView();
-            el.options.toggled = newToggledStatus;
-        }
+    var conditionCardView = function (el) {
+        el.options.cardView = false;
+        el.toggleView();
+    };
+
+    var conditionFullView = function (el) {
+        el.options.cardView = true;
+        el.toggleView();
     };
 
     $.extend($.fn.bootstrapTable.defaults, {