Skip to content

Commit

Permalink
refactor(layout): fix switching to blur theme
Browse files Browse the repository at this point in the history
  • Loading branch information
KostyaDanovsky committed May 13, 2016
1 parent db01a0b commit dee1333
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 32 deletions.
5 changes: 3 additions & 2 deletions src/app/theme/components/baPanel/baPanel.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<div class="panel panel-blur full-invisible ' + (attrs.baPanelClass || '') + '" zoom-in>';
var res = '<div class="panel ' + (layoutTheme.blur ? 'panel-blur' : '') + ' full-invisible ' + (attrs.baPanelClass || '');
res += '" zoom-in ' + (layoutTheme.blur ? 'ba-panel-blur' : '') + '>';
res += baPanel.template(el, attrs);
res += '</div>';
return res;
Expand Down
19 changes: 9 additions & 10 deletions src/app/theme/theme.run.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
24 changes: 24 additions & 0 deletions src/app/theme/theme.service.js
Original file line number Diff line number Diff line change
@@ -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,
}
}

})();
2 changes: 1 addition & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<!-- endinject -->
<!-- endbuild -->
</head>
<body ng-class="{'mobile' : $isMobile, 'blur-theme': $blurTheme}">
<body>
<div class="body-bg"></div>
<main ng-if="$pageFinishedLoading" ng-class="{ 'menu-collapsed': $baSidebarService.isMenuCollapsed() }">

Expand Down
2 changes: 1 addition & 1 deletion src/sass/app/_form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ label.custom-input-danger {
}
.input-group-addon {
background-color: $color;
color: $default;
color: $label-text;
}
}

Expand Down
12 changes: 5 additions & 7 deletions src/sass/theme/bootstrap-overrides/_panel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 0 additions & 11 deletions src/sass/theme/conf/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit dee1333

Please sign in to comment.