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