Added message when loading an animation from Service

This commit is contained in:
juliandescottes 2012-08-30 16:30:22 +02:00
parent 110bc050b2
commit 509ffcea2a
2 changed files with 22 additions and 9 deletions

View File

@ -153,6 +153,7 @@ ul, li {
border-bottom: 0; border-bottom: 0;
font-weight: bold; font-weight: bold;
font-size: 14px; font-size: 14px;
z-index: 10000;
} }
/* Force apparition of scrollbars on leopard */ /* Force apparition of scrollbars on leopard */

View File

@ -55,6 +55,7 @@
var frameId = this.getFrameIdFromUrl(); var frameId = this.getFrameIdFromUrl();
if (frameId) { if (frameId) {
this.displayMessage("Loading animation with id : [" + frameId + "]");
this.loadFramesheetFromService(frameId); this.loadFramesheetFromService(frameId);
} else { } else {
this.finishInit(); this.finishInit();
@ -86,10 +87,12 @@
xhr.onload = function(e) { xhr.onload = function(e) {
frameSheet.deserialize(this.responseText); frameSheet.deserialize(this.responseText);
piskel.removeMessage();
piskel.finishInit(); piskel.finishInit();
}; };
xhr.onerror = function () { xhr.onerror = function () {
piskel.removeMessage();
piskel.finishInit(); piskel.finishInit();
}; };
@ -98,16 +101,25 @@
initLocalStorageBackup: function() { initLocalStorageBackup: function() {
if(window.localStorage && window.localStorage['snapShot']) { if(window.localStorage && window.localStorage['snapShot']) {
var reloadLink = "<a href='#' onclick='piskel.restoreFromLocalStorage()'>reload</a>";
var discardLink = "<a href='#' onclick='piskel.cleanLocalStorage()'>discard</a>";
this.displayMessage("Non saved version found. " + reloadLink + " or " + discardLink);
}
},
displayMessage : function (content) {
var message = document.createElement('div'); var message = document.createElement('div');
message.id = "user-message"; message.id = "user-message";
message.className = "user-message"; message.className = "user-message";
var reloadLink = "<a href='#' onclick='piskel.restoreFromLocalStorage()'>reload</a>"; message.innerHTML = content;
var discardLink = "<a href='#' onclick='piskel.cleanLocalStorage()'>discard</a>"; message.onclick = this.removeMessage;
message.innerHTML = "Non saved version found. " + reloadLink + " or " + discardLink;
message.onclick = function() {
message.parentNode.removeChild(message);
};
document.body.appendChild(message); document.body.appendChild(message);
},
removeMessage : function () {
var message = $("user-message");
if (message) {
message.parentNode.removeChild(message);
} }
}, },