mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-27 12:48:49 +01:00
Merge remote-tracking branch 'origin/master'
Conflicts: src/app/theme/baCard/index.ts
This commit is contained in:
commit
673e2430c7
10 changed files with 165 additions and 4 deletions
43
src/app/theme/baCard/baCardBlur.directive.ts
Normal file
43
src/app/theme/baCard/baCardBlur.directive.ts
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import {Directive, ElementRef, HostListener} from 'angular2/core';
|
||||
import {BaCardBlurHelper} from './baCardBlurHelper.service';
|
||||
|
||||
import {BgMetrics} from './bgMetrics';
|
||||
|
||||
@Directive({
|
||||
selector: '[baCardBlur]',
|
||||
providers: [BaCardBlurHelper]
|
||||
})
|
||||
export class BaCardBlur {
|
||||
private _bodyBgSize:BgMetrics;
|
||||
|
||||
constructor(private _baCardBlurHelper:BaCardBlurHelper, private _el:ElementRef) {
|
||||
this._getBodyImageSizesOnBgLoad();
|
||||
this._recalculateCardStylesOnBgLoad();
|
||||
}
|
||||
|
||||
@HostListener('window:resize')
|
||||
_onWindowResize():void {
|
||||
this._bodyBgSize = this._baCardBlurHelper.getBodyBgImageSizes();
|
||||
this._recalculateCardStyle();
|
||||
}
|
||||
|
||||
private _getBodyImageSizesOnBgLoad():void {
|
||||
this._baCardBlurHelper.bodyBgLoad().subscribe(() => {
|
||||
this._bodyBgSize = this._baCardBlurHelper.getBodyBgImageSizes();
|
||||
});
|
||||
}
|
||||
|
||||
private _recalculateCardStylesOnBgLoad():void {
|
||||
this._baCardBlurHelper.bodyBgLoad().subscribe((event) => {
|
||||
setTimeout(this._recalculateCardStyle.bind(this));
|
||||
})
|
||||
}
|
||||
|
||||
private _recalculateCardStyle():void {
|
||||
if (!this._bodyBgSize) {
|
||||
return;
|
||||
}
|
||||
this._el.nativeElement.style.backgroundSize = Math.round(this._bodyBgSize.width) + 'px ' + Math.round(this._bodyBgSize.height) + 'px';
|
||||
this._el.nativeElement.style.backgroundPosition = Math.floor(this._bodyBgSize.positionX) + 'px ' + Math.floor(this._bodyBgSize.positionY) + 'px';
|
||||
}
|
||||
}
|
||||
54
src/app/theme/baCard/baCardBlurHelper.service.ts
Normal file
54
src/app/theme/baCard/baCardBlurHelper.service.ts
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
import {Injectable} from 'angular2/core'
|
||||
import {BgMetrics} from './bgMetrics';
|
||||
import {Subject} from 'rxjs/Subject';
|
||||
|
||||
@Injectable()
|
||||
export class BaCardBlurHelper {
|
||||
private image:HTMLImageElement;
|
||||
private imageLoadSubject:Subject<void>;
|
||||
|
||||
constructor() {
|
||||
this._genBgImage();
|
||||
this._genImageLoadSubject();
|
||||
}
|
||||
|
||||
private _genBgImage():void {
|
||||
this.image = new Image();
|
||||
let computedStyle = getComputedStyle(document.body, ':before');
|
||||
this.image.src = computedStyle.backgroundImage.replace(/url\((['"])?(.*?)\1\)/gi, '$2');
|
||||
}
|
||||
|
||||
private _genImageLoadSubject():void {
|
||||
this.imageLoadSubject = new Subject<void>();
|
||||
this.image.onerror = () => {
|
||||
this.imageLoadSubject.error();
|
||||
this.imageLoadSubject.complete();
|
||||
};
|
||||
this.image.onload = () => {
|
||||
this.imageLoadSubject.next(null);
|
||||
this.imageLoadSubject.complete();
|
||||
};
|
||||
}
|
||||
|
||||
public bodyBgLoad():Subject<void> {
|
||||
return this.imageLoadSubject;
|
||||
}
|
||||
|
||||
public getBodyBgImageSizes():BgMetrics {
|
||||
let elemW = document.documentElement.clientWidth;
|
||||
let elemH = document.documentElement.clientHeight;
|
||||
if(elemW <= 640) return;
|
||||
let imgRatio = (this.image.height / this.image.width); // original img ratio
|
||||
let containerRatio = (elemH / elemW); // container ratio
|
||||
|
||||
let finalHeight, finalWidth;
|
||||
if (containerRatio > imgRatio) {
|
||||
finalHeight = elemH;
|
||||
finalWidth = (elemH / imgRatio);
|
||||
} else {
|
||||
finalWidth = elemW;
|
||||
finalHeight = (elemW * imgRatio);
|
||||
}
|
||||
return { width: finalWidth, height: finalHeight, positionX: (elemW - finalWidth)/2, positionY: (elemH - finalHeight)/2};
|
||||
}
|
||||
}
|
||||
6
src/app/theme/baCard/bgMetrics.ts
Normal file
6
src/app/theme/baCard/bgMetrics.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
export interface BgMetrics {
|
||||
width:number;
|
||||
height:number;
|
||||
positionX:number;
|
||||
positionY:number;
|
||||
}
|
||||
2
src/app/theme/baCard/index.ts
Normal file
2
src/app/theme/baCard/index.ts
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
export * from './baCard.component';
|
||||
export * from './baCardBlur.directive';
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
import {Component, ViewEncapsulation, Input} from 'angular2/core';
|
||||
|
||||
import {BaCardBlur} from './baCardBlur.directive';
|
||||
|
||||
@Component({
|
||||
selector: 'ba-card',
|
||||
styles: [require('./baCard.scss')],
|
||||
directives: [BaCardBlur],
|
||||
template: require('./baCard.html'),
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<div class="card {{cardType}} {{baCardClass || ''}}" zoom-in ba-panel-blur>
|
||||
<div class="card {{cardType}} card-blur {{baCardClass || ''}}" zoom-in baCardBlur>
|
||||
<div *ngIf="title" class="card-header clearfix">
|
||||
<h3 class="card-title">{{title}}</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<ng-content></ng-content>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@mixin overridecardBg($color, $borderColor, $dropdownColor) {
|
||||
@mixin overrideCardBg($color, $borderColor, $dropdownColor) {
|
||||
.card.card-blur, .card.card-blur:hover {
|
||||
border-color: $borderColor;
|
||||
background-color: $color;
|
||||
|
|
|
|||
52
src/app/theme/sass/skins/_02_transparent.scss
Normal file
52
src/app/theme/sass/skins/_02_transparent.scss
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
body.badmin-transparent {
|
||||
&.mobile{
|
||||
background: none;
|
||||
.body-bg{
|
||||
display: block;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
@include main-background();
|
||||
background-attachment: inherit;
|
||||
}
|
||||
.panel-blur {
|
||||
background: transparent;
|
||||
}
|
||||
}
|
||||
@include overrideColors(#fff);
|
||||
@include overrideCardBg(rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.9));
|
||||
.default-color {
|
||||
color: $default-text !important;;
|
||||
}
|
||||
.card.card-blur {
|
||||
background-attachment: fixed;
|
||||
@include scrollbars(.4em, rgba(0, 0, 0, 0.7), rgba(255, 255, 255, 0.8));
|
||||
border-radius: 5px;
|
||||
color: $default;
|
||||
.card-header {
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.12);
|
||||
box-shadow: 0px 1px 0px 0px rgba(255, 255, 255, 0.12);
|
||||
transform: translate3d(0,0,0);
|
||||
}
|
||||
.card-body {
|
||||
transform: translate3d(0,0,0);
|
||||
}
|
||||
}
|
||||
.btn-default {
|
||||
color: $default;
|
||||
}
|
||||
.form-control, .bootstrap-tagsinput input {
|
||||
@include placeholderStyle($default, 0.7);
|
||||
background-color: rgba(0, 0, 0, .15);
|
||||
border-radius: 5px;
|
||||
color: $default;
|
||||
}
|
||||
.form-control[disabled], .form-control[readonly], fieldset[disabled] .form-control {
|
||||
@include placeholderStyle($default, 0.5);
|
||||
}
|
||||
.irs-grid-text {
|
||||
color: $default;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
@import "sass/conf/conf";
|
||||
@import "sass/bootstrap-overrides/overrides";
|
||||
@import "sass/skins/02_transparent";
|
||||
@import "sass/blur-admin-theme";
|
||||
@import "sass/typography";
|
||||
@import "sass/buttons";
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<body class="badmin-transparent">
|
||||
|
||||
<app>
|
||||
<div id="preloader">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue