Skip to content

Commit

Permalink
Updated to Angular 2.0.0-beta.14
Browse files Browse the repository at this point in the history
  • Loading branch information
akserg committed Apr 7, 2016
2 parents 7facced + 3921cf1 commit fc949d9
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 91 deletions.
48 changes: 24 additions & 24 deletions bundles/ng2-slim-loading-bar.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
System.registerDynamic("src/component", ["angular2/core", "angular2/common", "./service"], true, function($__require, exports, module) {
System.registerDynamic("src/component", ["angular2/core", "angular2/src/facade/lang", "angular2/common", "./service"], true, function($__require, exports, module) {
;
var define,
global = this,
Expand All @@ -20,6 +20,7 @@ System.registerDynamic("src/component", ["angular2/core", "angular2/common", "./
return Reflect.metadata(k, v);
};
var core_1 = $__require('angular2/core');
var lang_1 = $__require('angular2/src/facade/lang');
var common_1 = $__require('angular2/common');
var service_1 = $__require('./service');
var SlimLoadingBar = (function() {
Expand All @@ -35,7 +36,7 @@ System.registerDynamic("src/component", ["angular2/core", "angular2/common", "./
return this._progress;
},
set: function(value) {
if (value) {
if (lang_1.isPresent(value)) {
this._progress = value + '%';
}
},
Expand Down Expand Up @@ -63,7 +64,7 @@ System.registerDynamic("src/component", ["angular2/core", "angular2/common", "./
SlimLoadingBar = __decorate([core_1.Component({
selector: 'ng2-slim-loading-bar',
directives: [common_1.CORE_DIRECTIVES],
template: "\n<div class=\"slim-loading-bar\">\n <div class=\"slim-loading-bar-progress\" [style.width]=\"progress\" [style.backgroundColor]=\"color\" [style.color]=\"color\" \n [style.height]=\"height\" [style.opacity]=\"show ? '1' : '0'\"></div>\n</div>"
template: "\n<div class=\"slim-loading-bar\">\n <div class=\"slim-loading-bar-progress\" [style.width]=\"progress\" [style.backgroundColor]=\"color\" [style.color]=\"color\"\n [style.height]=\"height\" [style.opacity]=\"show ? '1' : '0'\"></div>\n</div>"
}), __metadata('design:paramtypes', [service_1.SlimLoadingBarService])], SlimLoadingBar);
return SlimLoadingBar;
})();
Expand Down Expand Up @@ -117,9 +118,8 @@ System.registerDynamic("src/service", ["angular2/core", "angular2/src/facade/lan
this._height = '2px';
this._color = 'firebrick';
this._visible = true;
this.intervalCounterId = 0;
this._intervalCounterId = 0;
this.interval = 500;
this.isPaused = false;
this.observable = new Observable_1.Observable(function(subscriber) {
_this.subscriber = subscriber;
});
Expand All @@ -130,6 +130,9 @@ System.registerDynamic("src/service", ["angular2/core", "angular2/src/facade/lan
},
set: function(value) {
if (lang_1.isPresent(value)) {
if (value > 0) {
this.visible = true;
}
this._progress = value;
this.emitEvent(new SlimLoadingBarEvent(SlimLoadingBarEventType.PROGRESS, this._progress));
}
Expand Down Expand Up @@ -189,38 +192,35 @@ System.registerDynamic("src/service", ["angular2/core", "angular2/src/facade/lan
if (onCompleted === void 0) {
onCompleted = null;
}
if (this.intervalCounterId) {
this.stop();
}
this._onCompleted = onCompleted;
this.intervalCounterId = setInterval(function() {
if (!_this.isPaused) {
_this.progress++;
if (_this.progress === 100) {
_this.complete();
}
this.stop();
this.visible = true;
this._intervalCounterId = setInterval(function() {
_this.progress++;
if (_this.progress === 100) {
_this.complete();
}
}, this.interval);
};
SlimLoadingBarService.prototype.pause = function() {
this.isPaused = !this.isPaused;
};
SlimLoadingBarService.prototype.stop = function() {
if (this.intervalCounterId) {
clearInterval(this.intervalCounterId);
this.intervalCounterId = null;
if (this._intervalCounterId) {
clearInterval(this._intervalCounterId);
this._intervalCounterId = null;
}
};
SlimLoadingBarService.prototype.reset = function() {
this.stop();
this.progress = 0;
};
SlimLoadingBarService.prototype.complete = function() {
var _this = this;
this.progress = 100;
if (this._onCompleted) {
this._onCompleted.call(this);
}
this.stop();
setTimeout(function() {
_this.visible = false;
setTimeout(function() {
_this.progress = 0;
}, 250);
}, 250);
};
SlimLoadingBarService = __decorate([core_1.Injectable(), __metadata('design:paramtypes', [])], SlimLoadingBarService);
return SlimLoadingBarService;
Expand Down
2 changes: 1 addition & 1 deletion bundles/ng2-slim-loading-bar.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,26 @@
"homepage": "https://github.com/akserg/ng2-slim-loading-bar",
"devDependencies": {
"angular2": "~2.0.0-beta.14",
"commitizen": "^2.7.6",
"cz-conventional-changelog": "^1.1.5",
"es6-promise": "~3.1.2",
"es6-shim": "~0.35.0",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.2",
"zone.js": "~0.6.6",
"cz-conventional-changelog": "^1.1.5",
"jasmine-core": "~2.3.4",
"karma": "~0.13.15",
"karma-chrome-launcher": "~0.2.2",
"karma-firefox-launcher": "~0.1.7",
"karma-jasmine": "~0.3.6",
"karma-typescript-preprocessor": "0.0.21",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.2",
"semantic-release": "^4.3.5",
"systemjs": "~0.19.6",
"systemjs-builder": "^0.15.6",
"tsd": "^0.6.5",
"typescript": "~1.7.3",
"typings": "^0.6.8",
"uglify-js": "^2.6.2"
"uglify-js": "^2.6.2",
"zone.js": "~0.6.6"
},
"config": {
"commitizen": {
Expand Down
17 changes: 9 additions & 8 deletions src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,43 @@
// https://github.com/akserg/ng2-slim-loading-bar

import {Component, Input, OnInit} from 'angular2/core';
import {isPresent} from 'angular2/src/facade/lang';
import {CORE_DIRECTIVES} from 'angular2/common';

import {SlimLoadingBarService, SlimLoadingBarEvent, SlimLoadingBarEventType} from './service';

/**
* A Toast component shows message with title and close button.
* A Slim Loading Bar component shows message loading progress bar on the top of web page or parent component.
*/
@Component({
selector: 'ng2-slim-loading-bar',
directives: [CORE_DIRECTIVES],
template: `
<div class="slim-loading-bar">
<div class="slim-loading-bar-progress" [style.width]="progress" [style.backgroundColor]="color" [style.color]="color"
<div class="slim-loading-bar-progress" [style.width]="progress" [style.backgroundColor]="color" [style.color]="color"
[style.height]="height" [style.opacity]="show ? '1' : '0'"></div>
</div>`
})
export class SlimLoadingBar implements OnInit {

private progressEl:HTMLDivElement;

private _progress: string = '0%';
@Input() set progress(value: string) {
if (value) {
if (isPresent(value)) {
this._progress = value + '%';
}
}
get progress(): string {
return this._progress;
}

@Input() color: string = 'firebrick';
@Input() height: string = '2px';
@Input() show: boolean = true;

constructor(private service:SlimLoadingBarService) {}

ngOnInit(): any {
this.service.observable.subscribe((event:SlimLoadingBarEvent) => {
if (event.type === SlimLoadingBarEventType.PROGRESS) {
Expand Down
Loading

0 comments on commit fc949d9

Please sign in to comment.