From 0a072e664ea0013db53fba4f87f3bdfc8584fc21 Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 30 Mar 2016 15:39:56 +0300 Subject: [PATCH] fix(mobile): detect mobile bu userAgent --- .../baPanel/baPanelBlur.directive.js | 18 ++++++++------- src/app/theme/theme.run.js | 22 +++++++++++++------ src/index.html | 2 +- src/sass/theme/_layout.scss | 5 ----- .../theme/bootstrap-overrides/_panel.scss | 6 ----- src/sass/theme/skins/_02_transparent.scss | 6 +++++ 6 files changed, 32 insertions(+), 27 deletions(-) diff --git a/src/app/theme/components/baPanel/baPanelBlur.directive.js b/src/app/theme/components/baPanel/baPanelBlur.directive.js index ad340a5..c3bf907 100644 --- a/src/app/theme/components/baPanel/baPanelBlur.directive.js +++ b/src/app/theme/components/baPanel/baPanelBlur.directive.js @@ -9,7 +9,7 @@ .directive('baPanelBlur', baPanelBlur); /** @ngInject */ - function baPanelBlur(baPanelBlurHelper, $window, $document) { + function baPanelBlur(baPanelBlurHelper, $window, $rootScope) { var bodyBgSize; baPanelBlurHelper.bodyBgLoad().then(function() { @@ -23,14 +23,16 @@ return { restrict: 'A', link: function($scope, elem) { - baPanelBlurHelper.bodyBgLoad().then(function() { - setTimeout(recalculatePanelStyle); - }); - $window.addEventListener('resize', recalculatePanelStyle); + if(!$rootScope.$isMobile) { + baPanelBlurHelper.bodyBgLoad().then(function () { + setTimeout(recalculatePanelStyle); + }); + $window.addEventListener('resize', recalculatePanelStyle); - $scope.$on('$destroy', function() { - $window.removeEventListener('resize', recalculatePanelStyle); - }); + $scope.$on('$destroy', function () { + $window.removeEventListener('resize', recalculatePanelStyle); + }); + } function recalculatePanelStyle() { if (!bodyBgSize) { diff --git a/src/app/theme/theme.run.js b/src/app/theme/theme.run.js index b9e2ef6..014faaa 100644 --- a/src/app/theme/theme.run.js +++ b/src/app/theme/theme.run.js @@ -6,22 +6,30 @@ 'use strict'; angular.module('BlurAdmin.theme') - .run(themeRun); + .run(themeRun); /** @ngInject */ function themeRun($timeout, $rootScope, layoutSizes, layoutPaths, preloader, $q) { - $q.all([ - preloader.loadImg(layoutPaths.images.root + 'blur-bg.jpg'), - preloader.loadImg(layoutPaths.images.root + 'blur-bg-blurred.jpg'), + $rootScope.$isMobile = (/android|webos|iphone|ipad|ipod|blackberry|windows phone/).test(navigator.userAgent.toLowerCase()); + var whatToWait = [ preloader.loadAmCharts(), $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 () { - if(!$rootScope.$pageFinishedLoading){ + if (!$rootScope.$pageFinishedLoading) { $rootScope.$pageFinishedLoading = true; } }, 7000); diff --git a/src/index.html b/src/index.html index 96dcc32..1163c71 100644 --- a/src/index.html +++ b/src/index.html @@ -24,7 +24,7 @@ - +
diff --git a/src/sass/theme/_layout.scss b/src/sass/theme/_layout.scss index 9f135e8..5ab5b2f 100644 --- a/src/sass/theme/_layout.scss +++ b/src/sass/theme/_layout.scss @@ -18,11 +18,6 @@ body { @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) { diff --git a/src/sass/theme/bootstrap-overrides/_panel.scss b/src/sass/theme/bootstrap-overrides/_panel.scss index 44e7093..98b7968 100644 --- a/src/sass/theme/bootstrap-overrides/_panel.scss +++ b/src/sass/theme/bootstrap-overrides/_panel.scss @@ -82,12 +82,6 @@ $panel-heading-font-size: 16px; transition: none; } -@media (max-width: 640px) { - .panel-blur { - background: transparent; - } -} - .panel-primary { > .panel-heading { color: $primary; diff --git a/src/sass/theme/skins/_02_transparent.scss b/src/sass/theme/skins/_02_transparent.scss index d8b9f17..01c9ec9 100644 --- a/src/sass/theme/skins/_02_transparent.scss +++ b/src/sass/theme/skins/_02_transparent.scss @@ -1,4 +1,10 @@ body.badmin-transparent { + &.mobile{ + background-image: url($images-root + 'blur-bg-mobile.jpg'); + .panel-blur { + background: transparent; + } + } @include overrideColors(#fff); @include overridePanelBg(rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.9)); .default-color {