Mask app on restart and shutdown

This commit is contained in:
Ruud committed 2011-11-11 17:38:52 +01:00
1 parent 668b95353f
commit dc58859596
5 files changed
+59 -11

No files matched your search

+46 -1
View File
@@ -109,11 +109,56 @@ var CouchPotato = new Class({
},
shutdown: function(){
Api.request('app.shutdown');
var self = this;
self.blockPage('You have shutdown. This is what suppose to happen ;)');
Api.request('app.shutdown', {
'onComplete': self.blockPage.bind(self)
});
self.checkAvailable();
},
restart: function(){
var self = this;
self.blockPage('Restarting... please wait. If this takes to long, something must have gone wrong.');
Api.request('app.restart');
self.checkAvailable();
},
checkAvailable: function(){
var self = this;
Api.request('app.available', {
'onFailure': function(){
self.checkAvailable.delay(1000, self);
self.fireEvent('unload');
},
'onSuccess': function(){
self.unBlockPage();
self.fireEvent('load');
}
});
},
blockPage: function(message){
var self = this;
if(!self.mask){
var body = $(document.body);
self.mask = new Spinner(document.body, {
'message': new Element('div').adopt(
new Element('h1', {'text': 'Unavailable.'}),
new Element('div', {'text': message || 'Something must have crashed.. check the logs ;)'})
)
});
}
self.mask.show();
},
unBlockPage: function(){
var self = this;
self.mask.hide();
}
});