From dee1333e06575fe242a3e627a2e9ec7df843810f Mon Sep 17 00:00:00 2001 From: KostyaDanovsky Date: Thu, 12 May 2016 17:16:20 +0300 Subject: [PATCH] refactor(layout): fix switching to blur theme --- .../components/baPanel/baPanel.directive.js | 5 ++-- src/app/theme/theme.run.js | 19 +++++++-------- src/app/theme/theme.service.js | 24 +++++++++++++++++++ src/index.html | 2 +- src/sass/app/_form.scss | 2 +- .../theme/bootstrap-overrides/_panel.scss | 12 ++++------ src/sass/theme/conf/_mixins.scss | 11 --------- 7 files changed, 43 insertions(+), 32 deletions(-) create mode 100644 src/app/theme/theme.service.js diff --git a/src/app/theme/components/baPanel/baPanel.directive.js b/src/app/theme/components/baPanel/baPanel.directive.js index 61b2295..6bf8848 100644 --- a/src/app/theme/components/baPanel/baPanel.directive.js +++ b/src/app/theme/components/baPanel/baPanel.directive.js @@ -12,10 +12,11 @@ .directive('baPanel', baPanel); /** @ngInject */ - function baPanel(baPanel) { + function baPanel(baPanel, layoutTheme) { return angular.extend({}, baPanel, { template: function(el, attrs) { - var res = '
'; + var res = '
'; res += baPanel.template(el, attrs); res += '
'; return res; diff --git a/src/app/theme/theme.run.js b/src/app/theme/theme.run.js index 1d3b8ec..1db3900 100644 --- a/src/app/theme/theme.run.js +++ b/src/app/theme/theme.run.js @@ -9,21 +9,20 @@ .run(themeRun); /** @ngInject */ - function themeRun($timeout, $rootScope, layoutTheme, layoutPaths, preloader, $q, baSidebarService) { - - $rootScope.$isMobile = (/android|webos|iphone|ipad|ipod|blackberry|windows phone/).test(navigator.userAgent.toLowerCase()); - $rootScope.$blurTheme = layoutTheme.blur; - + function themeRun($timeout, $rootScope, layoutPaths, preloader, $q, baSidebarService, themeLayoutSettings) { var whatToWait = [ preloader.loadAmCharts(), $timeout(3000) ]; - 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')); + var theme = themeLayoutSettings; + if (theme.blur) { + if (theme.mobile) { + 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 () { diff --git a/src/app/theme/theme.service.js b/src/app/theme/theme.service.js new file mode 100644 index 0000000..0f6e4fb --- /dev/null +++ b/src/app/theme/theme.service.js @@ -0,0 +1,24 @@ +/** + * Created by k.danovsky on 12.05.2016. + */ + +(function () { + 'use strict'; + + angular.module('BlurAdmin.theme') + .service('themeLayoutSettings', themeLayoutSettings); + + /** @ngInject */ + function themeLayoutSettings(layoutTheme) { + var isMobile = (/android|webos|iphone|ipad|ipod|blackberry|windows phone/).test(navigator.userAgent.toLowerCase()); + var mobileClass = isMobile ? 'mobile' : ''; + var blurClass = layoutTheme.blur ? 'blur-theme' : ''; + angular.element(document.body).addClass(mobileClass).addClass(blurClass); + + return { + blur: layoutTheme.blur, + mobile: isMobile, + } + } + +})(); \ No newline at end of file diff --git a/src/index.html b/src/index.html index b946a4b..669aa55 100644 --- a/src/index.html +++ b/src/index.html @@ -24,7 +24,7 @@ - +
diff --git a/src/sass/app/_form.scss b/src/sass/app/_form.scss index 45a30f6..0ff4447 100644 --- a/src/sass/app/_form.scss +++ b/src/sass/app/_form.scss @@ -345,7 +345,7 @@ label.custom-input-danger { } .input-group-addon { background-color: $color; - color: $default; + color: $label-text; } } diff --git a/src/sass/theme/bootstrap-overrides/_panel.scss b/src/sass/theme/bootstrap-overrides/_panel.scss index fc47dd4..0ed448f 100644 --- a/src/sass/theme/bootstrap-overrides/_panel.scss +++ b/src/sass/theme/bootstrap-overrides/_panel.scss @@ -40,13 +40,11 @@ $panel-heading-font-size: 16px; } } -.blur-theme { - .panel.panel-blur { - $blurredBgUrl: $images-root + 'blur-bg-blurred.jpg'; - background: url($blurredBgUrl); - transition: none; - background-attachment: fixed; - } +.panel.panel-blur { + $blurredBgUrl: $images-root + 'blur-bg-blurred.jpg'; + background: url($blurredBgUrl); + transition: none; + background-attachment: fixed; } .panel { diff --git a/src/sass/theme/conf/_mixins.scss b/src/sass/theme/conf/_mixins.scss index bf34aae..560b74e 100644 --- a/src/sass/theme/conf/_mixins.scss +++ b/src/sass/theme/conf/_mixins.scss @@ -115,14 +115,3 @@ color: darken($color, 20); } } - -@mixin overridePanelBg($color, $borderColor, $dropdownColor) { - .panel.panel-blur, .panel.panel-blur:hover { - border-color: $borderColor; - background-color: $color; - } - - .progress { - background: $color; - } -} \ No newline at end of file