smarter mobile detection (fix #255 and fix #487)

This commit is contained in:
Athou
2013-11-08 11:09:13 +01:00
parent 73323335cb
commit fc318ad211
6 changed files with 13 additions and 11 deletions

View File

@@ -18,6 +18,7 @@
<js minimize="false">/vendor/nginfinitescroll/*.js</js>
<js minimize="false">/vendor/spinjs/*.js</js>
<js minimize="false">/vendor/momentjs/*.js</js>
<js minimize="false">/vendor/devicejs/*.js</js>
<css minimize="false">/vendor/select2/*.css</css>
<css minimize="false">/vendor/bootstrap/*.css</css>

View File

@@ -23,8 +23,7 @@ module.service('MobileService', ['$state', function($state) {
this.rightMenu = !this.rightMenu;
$('body').toggleClass('right-menu-active');
};
var width = (window.innerWidth > 0) ? window.innerWidth : screen.width;
this.mobile = width < 979;
this.mobile = device.mobile() || device.tablet();
}]);
module.factory('ProfileService', ['$resource', function($resource) {

View File

@@ -1,4 +1,4 @@
@media ( max-width : 979px) {
html.mobile, html.tablet {
body {
padding-left: 5px;
padding-right: 5px;
@@ -10,7 +10,7 @@
.left-menu {
display: none !important;
}
.toolbar .hidden-desktop.btn-group {
.toolbar .toolbar-expand.btn-group {
display: inline-block !important;
}
.main-content {
@@ -62,7 +62,7 @@
margin-top: 5px;
margin-left: 0;
}
body.right-menu-active .toolbar .actions .visible-desktop {
body.right-menu-active .toolbar .actions {
display: inherit !important;
}
#uvTab {

View File

@@ -12,7 +12,7 @@
</div>
<div class="btn-group">
<button type="button" class="btn hidden-desktop" ng-click="MobileService.toggleLeftMenu()">
<button type="button" class="btn" ng-click="MobileService.toggleLeftMenu()" ng-if="MobileService.mobile">
<i class="icon-remove"></i> ${global.close}
</button>
</div>

View File

@@ -1,6 +1,6 @@
<div ng-controller="ToolbarCtrl">
<div class="form-horizontal">
<div class="btn-group hidden-desktop">
<div class="btn-group" ng-if="MobileService.mobile">
<button type="button" class="btn" ng-click="MobileService.toggleLeftMenu()">
<i class="icon-list-alt"></i>
</button>
@@ -33,14 +33,14 @@
</ul>
</div>
<div class="btn-group hidden-desktop">
<div class="btn-group toolbar-expand" ng-if="MobileService.mobile">
<button type="button" class="btn" ng-click="MobileService.toggleRightMenu()">
<i ng-class="{'icon-double-angle-right' : !MobileService.rightMenu, 'icon-double-angle-left': MobileService.rightMenu}"></i>
</button>
</div>
<div class="actions btn-group">
<div class="visible-desktop">
<div ng-if="!MobileService.mobile || MobileService.rightMenu">
<div class="btn-group read-mode" data-toggle="buttons-radio">
<button type="button" class="btn" ng-model="settingsService.settings.readingMode" btn-radio="'unread'">${toolbar.unread}</button>
<button type="button" class="btn" ng-model="settingsService.settings.readingMode" btn-radio="'all'">${toolbar.all}</button>
@@ -69,7 +69,7 @@
<li><a href="logout"><i class="icon-off"></i> ${toolbar.logout}</a></li>
</ul>
</div>
<form ng-submit="search()" class="btn-group input-append hidden-phone hidden-tablet">
<form ng-submit="search()" class="btn-group input-append" ng-if="!MobileService.mobile">
<input type="text" ng-model="keywords"></input>
<button class="btn" type="submit"><i class="icon-search"></i></button>
</form>
@@ -82,6 +82,6 @@
</div>
</div>
<div spinner shown="loading"></div>
<span class="hidden-phone hidden-tablet" ng-bind-html-unsafe="ServerService.announcement"></span>
<span ng-if="!MobileService.mobile" ng-bind-html-unsafe="ServerService.announcement"></span>
</div>
</div>

View File

@@ -0,0 +1,2 @@
/*! device.js 0.1.58 */
(function(){var a,b,c,d,e,f,g,h,i,j;a=window.device,window.device={},c=window.document.documentElement,j=window.navigator.userAgent.toLowerCase(),device.ios=function(){return device.iphone()||device.ipod()||device.ipad()},device.iphone=function(){return d("iphone")},device.ipod=function(){return d("ipod")},device.ipad=function(){return d("ipad")},device.android=function(){return d("android")},device.androidPhone=function(){return device.android()&&d("mobile")},device.androidTablet=function(){return device.android()&&!d("mobile")},device.blackberry=function(){return d("blackberry")||d("bb10")||d("rim")},device.blackberryPhone=function(){return device.blackberry()&&!d("tablet")},device.blackberryTablet=function(){return device.blackberry()&&d("tablet")},device.windows=function(){return d("windows")},device.windowsPhone=function(){return device.windows()&&d("phone")},device.windowsTablet=function(){return device.windows()&&d("touch")},device.fxos=function(){return d("(mobile; rv:")||d("(tablet; rv:")},device.fxosPhone=function(){return device.fxos()&&d("mobile")},device.fxosTablet=function(){return device.fxos()&&d("tablet")},device.mobile=function(){return device.androidPhone()||device.iphone()||device.ipod()||device.windowsPhone()||device.blackberryPhone()||device.fxosPhone()},device.tablet=function(){return device.ipad()||device.androidTablet()||device.blackberryTablet()||device.windowsTablet()||device.fxosTablet()},device.portrait=function(){return 90!==Math.abs(window.orientation)},device.landscape=function(){return 90===Math.abs(window.orientation)},device.noConflict=function(){return window.device=a,this},d=function(a){return-1!==j.indexOf(a)},f=function(a){var b;return b=new RegExp(a,"i"),c.className.match(b)},b=function(a){return f(a)?void 0:c.className+=" "+a},h=function(a){return f(a)?c.className=c.className.replace(a,""):void 0},device.ios()?device.ipad()?b("ios ipad tablet"):device.iphone()?b("ios iphone mobile"):device.ipod()&&b("ios ipod mobile"):device.android()?device.androidTablet()?b("android tablet"):b("android mobile"):device.blackberry()?device.blackberryTablet()?b("blackberry tablet"):b("blackberry mobile"):device.windows()?device.windowsTablet()?b("windows tablet"):device.windowsPhone()?b("windows mobile"):b("desktop"):device.fxos()?device.fxosTablet()?b("fxos tablet"):b("fxos mobile"):b("desktop"),e=function(){return device.landscape()?(h("portrait"),b("landscape")):(h("landscape"),b("portrait"))},i="onorientationchange"in window,g=i?"orientationchange":"resize",window.addEventListener?window.addEventListener(g,e,!1):window.attachEvent?window.attachEvent(g,e):window[g]=e,e()}).call(this);