Browse Source

Stop to use window.alert() for load errors

Load errors are now shown as simple inline messages, replacing the
loader. This avoids annoying browser alert windows.
pull/305/head
Simon Eisenmann 9 years ago
parent
commit
a51131b3e3
  1. 9
      src/styles/global/_loader.scss
  2. 2
      static/css/main.min.css
  3. 22
      static/js/main.js

9
src/styles/global/_loader.scss

@ -36,6 +36,15 @@ @@ -36,6 +36,15 @@
transition-property: opacity;
z-index: 20000;
&.fake-alert {
background: none;
color: white;
font-weight: bold;
text-align: center;
font-size: 1.5em;
line-height: 1.1em;
}
&.done {
opacity: 0;
}

2
static/css/main.min.css vendored

File diff suppressed because one or more lines are too long

22
static/js/main.js

@ -148,17 +148,21 @@ require.config({ @@ -148,17 +148,21 @@ require.config({
window.debug(debugDefault && true);
}());
function fakeAlert(text) {
var loader = document.getElementById("loader");
loader.className = "fake-alert";
if (loader) {
loader.innerHTML = text;
} else {
window.alert(text);
}
}
require.onError = (function() {
var retrying = false;
return function(err) {
if (retrying) {
console.error("Error while loading " + err.requireType, err.requireModules);
return;
}
if (err.requireType === "timeout" || err.requireType === "scripterror") {
window.alert('Failed to load application. Confirm to retry.');
retrying = true;
document.location.reload(true);
console.error("Error while loading " + err.requireType, err.requireModules);
fakeAlert('Failed to load app!');
} else {
throw err;
}
@ -293,5 +297,5 @@ if (Object.create) { @@ -293,5 +297,5 @@ if (Object.create) {
});
} else {
window.alert("Your browser does not support this application. Please update your browser to the latest version.");
fakeAlert("Your browser does not support this application. Please update your browser to the latest version.");
}

Loading…
Cancel
Save