szurubooru/public_html/js/Presenters/HttpErrorPresenter.js

49 lines
949 B
JavaScript
Raw Normal View History

2014-10-18 12:37:01 +02:00
var App = App || {};
App.Presenters = App.Presenters || {};
App.Presenters.HttpErrorPresenter = function(
jQuery,
promise,
util,
topNavigationPresenter) {
var $el = jQuery('#content');
var templates = {};
function init(params, loaded) {
topNavigationPresenter.changeTitle('Error ' + params.error);
if (params.error === 404) {
promise.wait(util.promiseTemplate('404'))
.then(function(template) {
templates.errorPage = template;
reinit(params, loaded);
}).fail(function() {
console.log(arguments);
loaded();
});
} else {
console.log('Not supported.');
loaded();
}
}
function reinit(params, loaded) {
render();
loaded();
}
function render() {
$el.html(templates.errorPage());
}
return {
init: init,
reinit: reinit,
render: render,
};
};
App.DI.register('httpErrorPresenter', ['jQuery', 'promise', 'util', 'topNavigationPresenter'], App.Presenters.HttpErrorPresenter);