Embed: show an error when CSS failed to load
This commit is contained in:
parent
b9eb03a599
commit
c17cfe9595
3 changed files with 23 additions and 12 deletions
16
embed/controls.js
vendored
16
embed/controls.js
vendored
|
@ -93,14 +93,20 @@ function MistUI(MistVideo,structure) {
|
||||||
|
|
||||||
//apply skin CSS
|
//apply skin CSS
|
||||||
var uid = MistUtil.createUnique();
|
var uid = MistUtil.createUnique();
|
||||||
var toload = MistVideo.skin.css.length;
|
var loaded = 0;
|
||||||
if (toload) { container.style.opacity = "0"; }
|
if (MistVideo.skin.css.length) { container.style.opacity = 0; }
|
||||||
for (var i in MistVideo.skin.css) {
|
for (var i in MistVideo.skin.css) {
|
||||||
var style = MistVideo.skin.css[i];
|
var style = MistVideo.skin.css[i];
|
||||||
style.callback = function(css) {
|
style.callback = function(css) {
|
||||||
this.textContent = MistUtil.css.prependClass(css,uid,true);
|
if (css == "/*Failed to load*/") {
|
||||||
toload--;
|
this.textContent = css;
|
||||||
if (toload <= 0) {
|
MistVideo.showError("Failed to load CSS from "+this.getAttribute("data-source"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.textContent = MistUtil.css.prependClass(css,uid,true);
|
||||||
|
}
|
||||||
|
loaded++;
|
||||||
|
if (MistVideo.skin.css.length <= loaded) {
|
||||||
container.style.opacity = "";
|
container.style.opacity = "";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -418,7 +418,9 @@ MistSkins["default"] = {
|
||||||
//remove all the things when unmuted
|
//remove all the things when unmuted
|
||||||
var fu = function(){
|
var fu = function(){
|
||||||
if (!MistVideo.video.muted) {
|
if (!MistVideo.video.muted) {
|
||||||
MistVideo.container.removeChild(largeMutedButton);
|
if (largeMutedButton.parentNode) {
|
||||||
|
MistVideo.container.removeChild(largeMutedButton);
|
||||||
|
}
|
||||||
MistVideo.video.removeEventListener("volumechange",fu);
|
MistVideo.video.removeEventListener("volumechange",fu);
|
||||||
document.body.removeEventListener("click",i);
|
document.body.removeEventListener("click",i);
|
||||||
MistVideo.video.removeEventListener("mouseenter",f);
|
MistVideo.video.removeEventListener("mouseenter",f);
|
||||||
|
@ -2621,10 +2623,10 @@ function MistSkin(MistVideo) {
|
||||||
|
|
||||||
//load css
|
//load css
|
||||||
var styles = [];
|
var styles = [];
|
||||||
var toload = 0;
|
|
||||||
for (var i in this.css) {
|
for (var i in this.css) {
|
||||||
if (typeof this.css[i] == "string") {
|
if (typeof this.css[i] == "string") {
|
||||||
styles.push(MistUtil.css.load(MistVideo.urlappend(this.css[i]),this.colors));
|
var a = MistUtil.css.load(MistVideo.urlappend(this.css[i]),this.colors);
|
||||||
|
styles.push(a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.css = styles; //overwrite
|
this.css = styles; //overwrite
|
||||||
|
|
|
@ -363,9 +363,7 @@ var MistUtil = {
|
||||||
callback(xhr.response);
|
callback(xhr.response);
|
||||||
}
|
}
|
||||||
else if (errorCallback) {
|
else if (errorCallback) {
|
||||||
xhr.onerror = function() {
|
errorCallback(xhr);
|
||||||
errorCallback(xhr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (errorCallback) {
|
if (errorCallback) {
|
||||||
|
@ -461,7 +459,12 @@ var MistUtil = {
|
||||||
}
|
}
|
||||||
cache[url] = d;
|
cache[url] = d;
|
||||||
},function(){
|
},function(){
|
||||||
throw "Failed to load CSS from "+url;
|
var d = "/*Failed to load*/";
|
||||||
|
for (var i in cache[url]) {
|
||||||
|
cache[url][i](d);
|
||||||
|
}
|
||||||
|
cache[url] = d;
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue