Commit 6774586f authored by Tomas Pettersson's avatar Tomas Pettersson 🏸

added please wait dialog

parent f74f4c62
......@@ -12,7 +12,7 @@ module.exports = function(grunt) {
overrides : {
"stwkit" : {
"main" : [
"src/stwkit.js", "src/components/cards.js", "src/components/cards.css"
"src/stwkit.js", "src/components/cards.js", "src/components/cards.css", "src/components/pleasewait.js"
]
},
"uikit-stw": {
......
......@@ -62,6 +62,7 @@
<script src="../bower_components/intro.js/intro.js"></script>
<script src="../src/stwkit.js"></script>
<script src="../src/components/cards.js"></script>
<script src="../src/components/pleasewait.js"></script>
<!-- endbower -->
<script>
......
/// <reference path="../def/uikit.d.ts" />
var PleaseWait = (function () {
function PleaseWait() {
this.StartMilliseconds = 0;
this.ElapsedMilliseconds = 0;
}
PleaseWait.prototype.start = function () {
var self = this;
self.StartMilliseconds = new Date().getTime();
self.wait = true;
setTimeout(function () {
if (self.wait)
self.modal = self.pleaseWaitModal();
}, 500);
};
PleaseWait.prototype.stop = function () {
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();
}
}
};
PleaseWait.prototype.pleaseWaitModal = function () {
return UIkit.modal.blockUI('<div class="uk-modal-spinner"></div><div class="uk-margin-botttom"><b>Please wait...</b></div>');
};
return PleaseWait;
}());
//# sourceMappingURL=pleasewait.js.map
\ No newline at end of file
{"version":3,"file":"pleasewait.js","sourceRoot":"","sources":["pleasewait.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAE1C;IAMI;QACI,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAC;QAC3B,IAAI,CAAC,mBAAmB,GAAG,CAAC,CAAC;IACjC,CAAC;IACM,0BAAK,GAAZ;QACI,IAAI,IAAI,GAAG,IAAI,CAAC;QAChB,IAAI,CAAC,iBAAiB,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;QAC9C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,UAAU,CAAC;YACP,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;gBAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QACvD,CAAC,EAAE,GAAG,CAAC,CAAC;IACZ,CAAC;IACM,yBAAI,GAAX;QACI,IAAI,IAAI,GAAG,IAAI,CAAC;QAChB,IAAI,CAAC,mBAAmB,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,iBAAiB,CAAC;QACzE,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;QAClB,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;YACb,IAAI,QAAQ,GAAG,IAAI,GAAG,IAAI,CAAC,mBAAmB,CAAC,CAAC,qBAAqB;YACrE,EAAE,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC;gBACf,UAAU,CAAC;oBACP,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;gBACtB,CAAC,EAAE,QAAQ,CAAC,CAAC;YACjB,CAAC;YAAC,IAAI,CAAC,CAAC;gBACJ,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;YACtB,CAAC;QACL,CAAC;IACL,CAAC;IAEO,oCAAe,GAAvB;QACI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,gGAAgG,CAAC,CAAC;IACjI,CAAC;IACL,iBAAC;AAAD,CAAC,AArCD,IAqCC"}
\ No newline at end of file
/// <reference path="../def/uikit.d.ts" />
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('<div class="uk-modal-spinner"></div><div class="uk-margin-botttom"><b>Please wait...</b></div>');
}
}
......@@ -5,7 +5,8 @@
"sourceMap" : true
},
"files": [
"src/components/cards.ts"
"src/components/cards.ts",
"src/components/pleasewait.ts"
],
"exclude": [
"node_modules",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment