fix(mobile): detect mobile bu userAgent

pull/3/head
alex 2016-03-30 15:39:56 +03:00
parent fdd0fc8623
commit 0a072e664e
6 changed files with 32 additions and 27 deletions

View File

@ -9,7 +9,7 @@
.directive('baPanelBlur', baPanelBlur); .directive('baPanelBlur', baPanelBlur);
/** @ngInject */ /** @ngInject */
function baPanelBlur(baPanelBlurHelper, $window, $document) { function baPanelBlur(baPanelBlurHelper, $window, $rootScope) {
var bodyBgSize; var bodyBgSize;
baPanelBlurHelper.bodyBgLoad().then(function() { baPanelBlurHelper.bodyBgLoad().then(function() {
@ -23,14 +23,16 @@
return { return {
restrict: 'A', restrict: 'A',
link: function($scope, elem) { link: function($scope, elem) {
baPanelBlurHelper.bodyBgLoad().then(function() { if(!$rootScope.$isMobile) {
setTimeout(recalculatePanelStyle); baPanelBlurHelper.bodyBgLoad().then(function () {
}); setTimeout(recalculatePanelStyle);
$window.addEventListener('resize', recalculatePanelStyle); });
$window.addEventListener('resize', recalculatePanelStyle);
$scope.$on('$destroy', function() { $scope.$on('$destroy', function () {
$window.removeEventListener('resize', recalculatePanelStyle); $window.removeEventListener('resize', recalculatePanelStyle);
}); });
}
function recalculatePanelStyle() { function recalculatePanelStyle() {
if (!bodyBgSize) { if (!bodyBgSize) {

View File

@ -6,22 +6,30 @@
'use strict'; 'use strict';
angular.module('BlurAdmin.theme') angular.module('BlurAdmin.theme')
.run(themeRun); .run(themeRun);
/** @ngInject */ /** @ngInject */
function themeRun($timeout, $rootScope, layoutSizes, layoutPaths, preloader, $q) { function themeRun($timeout, $rootScope, layoutSizes, layoutPaths, preloader, $q) {
$q.all([ $rootScope.$isMobile = (/android|webos|iphone|ipad|ipod|blackberry|windows phone/).test(navigator.userAgent.toLowerCase());
preloader.loadImg(layoutPaths.images.root + 'blur-bg.jpg'), var whatToWait = [
preloader.loadImg(layoutPaths.images.root + 'blur-bg-blurred.jpg'),
preloader.loadAmCharts(), preloader.loadAmCharts(),
$timeout(3000) $timeout(3000)
]).then(function(){ ];
$rootScope.$pageFinishedLoading = true;
if ($rootScope.$isMobile) {
whatToWait.unshift(preloader.loadImg(layoutPaths.images.root + 'blur-bg-mobile.jpg'));
} else {
whatToWait.unshift(preloader.loadImg(layoutPaths.images.root + 'blur-bg.jpg'));
whatToWait.unshift(preloader.loadImg(layoutPaths.images.root + 'blur-bg-blurred.jpg'));
}
$q.all(whatToWait).then(function () {
$rootScope.$pageFinishedLoading = true;
}); });
$timeout(function () { $timeout(function () {
if(!$rootScope.$pageFinishedLoading){ if (!$rootScope.$pageFinishedLoading) {
$rootScope.$pageFinishedLoading = true; $rootScope.$pageFinishedLoading = true;
} }
}, 7000); }, 7000);

View File

@ -24,7 +24,7 @@
<!-- endinject --> <!-- endinject -->
<!-- endbuild --> <!-- endbuild -->
</head> </head>
<body> <body ng-class="{'mobile' : $isMobile}">
<main ng-if="$pageFinishedLoading" ng-class="{ 'menu-collapsed': $isMenuCollapsed }"> <main ng-if="$pageFinishedLoading" ng-class="{ 'menu-collapsed': $isMenuCollapsed }">
<sidebar></sidebar> <sidebar></sidebar>

View File

@ -18,11 +18,6 @@ body {
@include main-background(); @include main-background();
} }
@media (max-width: 640px) {
body {
background-image: url($images-root + 'blur-bg-mobile.jpg');
}
}
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none)
{ {

View File

@ -82,12 +82,6 @@ $panel-heading-font-size: 16px;
transition: none; transition: none;
} }
@media (max-width: 640px) {
.panel-blur {
background: transparent;
}
}
.panel-primary { .panel-primary {
> .panel-heading { > .panel-heading {
color: $primary; color: $primary;

View File

@ -1,4 +1,10 @@
body.badmin-transparent { body.badmin-transparent {
&.mobile{
background-image: url($images-root + 'blur-bg-mobile.jpg');
.panel-blur {
background: transparent;
}
}
@include overrideColors(#fff); @include overrideColors(#fff);
@include overridePanelBg(rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.9)); @include overridePanelBg(rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.9));
.default-color { .default-color {