detangle loader, add configuration MIDI.soundfontUrl to set the base-path to your soundfonts
This commit is contained in:
parent
f723a45652
commit
d0cf6085d7
9 changed files with 51 additions and 55 deletions
|
@ -120,18 +120,17 @@ widgets.Loader = function (configure) {
|
|||
ctx.shadowColor = "rgba(0, 0, 0, 0.5)";
|
||||
|
||||
/// Public functions.
|
||||
this.messageId;
|
||||
this.messages = {};
|
||||
this.message = function (message, onstart) {
|
||||
if (!this.interval) return this.start(onstart, message);
|
||||
if (this.messageId) return this.update(this.messageId, message);
|
||||
return this.messageId = this.add({
|
||||
return this.add({
|
||||
message: message,
|
||||
onstart: onstart
|
||||
});
|
||||
};
|
||||
|
||||
this.update = function(id, message, percent) {
|
||||
if (!id) for (var id in this.messages);
|
||||
var item = this.messages[id];
|
||||
item.message = message;
|
||||
if (typeof(percent) === "number") item.span.innerHTML = percent + "%";
|
||||
|
@ -188,7 +187,6 @@ widgets.Loader = function (configure) {
|
|||
this.span.appendChild(container);
|
||||
this.span.style.display = "block";
|
||||
this.update(item.seed, message);
|
||||
this.center();
|
||||
/// Escape event loop.
|
||||
if (conf.onstart) {
|
||||
window.setTimeout(conf.onstart, 50);
|
||||
|
@ -224,7 +222,7 @@ widgets.Loader = function (configure) {
|
|||
|
||||
this.start = function (onstart, message) {
|
||||
if (!(message || configure.message)) return;
|
||||
return this.messageId = this.add({
|
||||
return this.add({
|
||||
message: message || configure.message,
|
||||
onstart: onstart
|
||||
});
|
||||
|
@ -258,14 +256,13 @@ widgets.Loader = function (configure) {
|
|||
canvas.style.top = (height / 2) + "px";
|
||||
canvas.style.width = (size) + "px";
|
||||
canvas.style.height = (size) + "px";
|
||||
that.span.style.left = ((width + size) / 2 - that.span.offsetWidth / 2) + "px";
|
||||
that.span.style.top = (height / 2 + size - 10) + "px";
|
||||
};
|
||||
|
||||
var style = document.createElement("style");
|
||||
style.innerHTML = '\
|
||||
.loader { color: #fff; position: fixed; left: 0; top: 0; width: 100%; height: 100%; z-index: 100000; opacity: 0; display: none; }\
|
||||
.loader span.message { font-family: monospace; font-size: 14px; opacity: 1; display: none; border-radius: 10px; padding: 0px; width: 300px; text-align: center; position: absolute; z-index: 10000; }\
|
||||
.loader span.message { line-height: 1.5em; font-family: monospace; font-size: 14px; margin: auto; opacity: 1; display: none; border-radius: 10px; padding: 0px; width: 300px; text-align: center; position: absolute; z-index: 10000; left: 0; right: 0; }\
|
||||
.loader span.message div { border-bottom: 1px solid #222; padding: 5px 10px; clear: both; text-align: left; opacity: 1; }\
|
||||
.loader span.message div:last-child { border-bottom: none; }\
|
||||
';
|
||||
|
@ -277,7 +274,7 @@ widgets.Loader = function (configure) {
|
|||
}, 1);
|
||||
window.setTimeout(function() { // wait for opacity=0 before removing the element.
|
||||
item.container.parentNode.removeChild(item.container);
|
||||
}, 10);
|
||||
}, 250);
|
||||
};
|
||||
var renderAnimation = function () {
|
||||
var timestamp = (new Date()).getTime();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue