///
module STWkit {
export class PleaseWait {
public StartMilliseconds: number;
public ElapsedMilliseconds: number;
private wait: boolean;
private modal: any;
constructor() {
this.StartMilliseconds = 0;
this.ElapsedMilliseconds = 0;
}
public start() {
var self = this;
self.StartMilliseconds = new Date().getTime();
self.wait = true;
setTimeout(function () {
if (self.wait) self.modal = self.pleaseWaitModal();
}, 500);
}
public stop() {
var self = this;
this.ElapsedMilliseconds = new Date().getTime() - this.StartMilliseconds;
self.wait = false;
if (self.modal) {
var timeLeft = 2000 - self.ElapsedMilliseconds; // wait minimum 2 sec
if (timeLeft > 0) {
setTimeout(function () {
self.modal.hide();
}, timeLeft);
} else {
self.modal.hide();
}
}
}
private pleaseWaitModal() {
return UIkit.modal.blockUI('
Please wait...
');
}
}
}