diff --git a/src/app/theme/baCard/baCard.component.ts b/src/app/theme/baCard/baCard.component.ts
index f96c438c..2665eab9 100644
--- a/src/app/theme/baCard/baCard.component.ts
+++ b/src/app/theme/baCard/baCard.component.ts
@@ -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
})
diff --git a/src/app/theme/baCard/baCard.html b/src/app/theme/baCard/baCard.html
index a597ca69..badaeb55 100644
--- a/src/app/theme/baCard/baCard.html
+++ b/src/app/theme/baCard/baCard.html
@@ -1,8 +1,8 @@
-
+
\ No newline at end of file
+
diff --git a/src/app/theme/baCard/baCardBlur.directive.ts b/src/app/theme/baCard/baCardBlur.directive.ts
index e5ae3f6f..bbdf3cb2 100644
--- a/src/app/theme/baCard/baCardBlur.directive.ts
+++ b/src/app/theme/baCard/baCardBlur.directive.ts
@@ -22,15 +22,15 @@ export class BaCardBlur {
}
private _getBodyImageSizesOnBgLoad():void {
- this._baCardBlurHelper.bodyBgLoad().then(function() {
+ this._baCardBlurHelper.bodyBgLoad().subscribe(() => {
this._bodyBgSize = this._baCardBlurHelper.getBodyBgImageSizes();
});
}
private _recalculateCardStylesOnBgLoad():void {
- this._baCardBlurHelper.bodyBgLoad().then(() => {
- setTimeout(this._recalculateCardStyle);
- });
+ this._baCardBlurHelper.bodyBgLoad().subscribe((event) => {
+ setTimeout(this._recalculateCardStyle.bind(this));
+ })
}
private _recalculateCardStyle():void {
diff --git a/src/app/theme/baCard/baCardBlurHelper.service.ts b/src/app/theme/baCard/baCardBlurHelper.service.ts
index 69cb7a9d..2893f7f1 100644
--- a/src/app/theme/baCard/baCardBlurHelper.service.ts
+++ b/src/app/theme/baCard/baCardBlurHelper.service.ts
@@ -1,15 +1,15 @@
import {Injectable} from 'angular2/core'
-
import {BgMetrics} from './bgMetrics';
+import {Subject} from 'rxjs/Subject';
@Injectable()
export class BaCardBlurHelper {
private image:HTMLImageElement;
- private imageLoadDeferred = Promise.defer(); //TODO: Promises or Observables refactor
+ private imageLoadSubject:Subject;
constructor() {
this._genBgImage();
- this._setImageLoadResolves()
+ this._genImageLoadSubject();
}
private _genBgImage():void {
@@ -18,17 +18,20 @@ export class BaCardBlurHelper {
this.image.src = computedStyle.backgroundImage.replace(/url\((['"])?(.*?)\1\)/gi, '$2');
}
- private _setImageLoadResolves():void {
+ private _genImageLoadSubject():void {
+ this.imageLoadSubject = new Subject();
this.image.onerror = () => {
- this.imageLoadDeferred.reject();
+ this.imageLoadSubject.error();
+ this.imageLoadSubject.complete();
};
this.image.onload = () => {
- this.imageLoadDeferred.resolve();
+ this.imageLoadSubject.next(null);
+ this.imageLoadSubject.complete();
};
}
- public bodyBgLoad():Promise {
- return this.imageLoadDeferred.promise;
+ public bodyBgLoad():Subject {
+ return this.imageLoadSubject;
}
public getBodyBgImageSizes():BgMetrics {