提交 3131dd59 编写于 作者: C Catouse

* refactor codes.

上级 920c17d3
...@@ -16,43 +16,34 @@ ...@@ -16,43 +16,34 @@
var resetCssClass = function() { var resetCssClass = function() {
var width = $window.width(); var width = $window.width();
var classNames = ''; $('html').toggleClass('screen-desktop', width >= desktop && width < desktopLg)
.toggleClass('screen-desktop-wide', width >= desktopLg)
if (width >= desktopLg) { .toggleClass('screen-tablet', width >= tablet && width < desktop)
classNames += ' screen-desktop-wide'; .toggleClass('screen-phone', width < tablet)
} else if (width >= desktop && width < desktopLg) { .toggleClass('device-mobile', width < desktop)
classNames += ' screen-desktop'; .toggleClass('device-desktop', width >= desktop);
} else if (width >= tablet && width < desktop) {
classNames += ' screen-tablet';
} else {
classNames += ' screen-phone';
}
if (width < desktop) {
classNames += ' device-mobile';
} else {
classNames += ' device-desktop';
}
if ('ontouchstart' in document.documentElement) {
classNames += ' is-touchable';
}
var userAgent = navigator.userAgent;
if (userAgent.match(/(iPad|iPhone|iPod)/i)) {
classNames += ' os-ios';
} else if (userAgent.match(/android/i)) {
classNames += ' os-android';
} else if (userAgent.match(/Win/i)) {
classNames += ' os-windows';
} else if (userAgent.match(/Mac/i)) {
classNames += ' os-mac';
} else if (userAgent.match(/Linux/i)) {
classNames += ' os-linux';
} else if (userAgent.match(/X11/i)) {
classNames += ' os-unix';
}
$('html').addClass(classNames);
}; };
var classNames = '';
var userAgent = navigator.userAgent;
if (userAgent.match(/(iPad|iPhone|iPod)/i)) {
classNames += ' os-ios';
} else if (userAgent.match(/android/i)) {
classNames += ' os-android';
} else if (userAgent.match(/Win/i)) {
classNames += ' os-windows';
} else if (userAgent.match(/Mac/i)) {
classNames += ' os-mac';
} else if (userAgent.match(/Linux/i)) {
classNames += ' os-linux';
} else if (userAgent.match(/X11/i)) {
classNames += ' os-unix';
}
if ('ontouchstart' in document.documentElement) {
classNames += ' is-touchable';
}
$('html').addClass(classNames);
$window.resize(resetCssClass); $window.resize(resetCssClass);
resetCssClass(); resetCssClass();
}(window, jQuery)); }(window, jQuery));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册