2014-08-31 23:22:56 +02:00
|
|
|
var App = App || {};
|
|
|
|
|
2014-10-09 21:41:46 +02:00
|
|
|
App.Bootstrap = function(auth, router, promise, presenterManager) {
|
2014-09-03 09:10:26 +02:00
|
|
|
|
2015-06-28 10:07:11 +02:00
|
|
|
promise.wait(presenterManager.init())
|
|
|
|
.then(function() {
|
|
|
|
promise.wait(auth.tryLoginFromCookie())
|
|
|
|
.then(startRouting)
|
|
|
|
.fail(function(error) {
|
|
|
|
promise.wait(auth.loginAnonymous())
|
|
|
|
.then(startRouting)
|
|
|
|
.fail(function() {
|
|
|
|
console.log(arguments);
|
|
|
|
window.alert('Fatal authentication error');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}).fail(function() {
|
|
|
|
console.log(arguments);
|
|
|
|
});
|
2014-08-31 23:22:56 +02:00
|
|
|
|
2015-06-28 10:07:11 +02:00
|
|
|
function startRouting() {
|
|
|
|
try {
|
|
|
|
router.start();
|
|
|
|
} catch (err) {
|
|
|
|
console.log(err);
|
|
|
|
}
|
|
|
|
}
|
2014-08-31 23:22:56 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2014-10-09 21:41:46 +02:00
|
|
|
App.DI.registerSingleton('bootstrap', ['auth', 'router', 'promise', 'presenterManager'], App.Bootstrap);
|
2014-09-08 22:02:28 +02:00
|
|
|
App.DI.registerManual('jQuery', function() { return window.$; });
|
2014-10-02 23:44:04 +02:00
|
|
|
App.DI.registerManual('pathJs', function() { return window.pathjs; });
|
2014-09-08 22:02:28 +02:00
|
|
|
App.DI.registerManual('_', function() { return window._; });
|
2014-09-12 19:33:27 +02:00
|
|
|
App.DI.registerManual('mousetrap', function() { return window.Mousetrap; });
|
2014-10-05 20:22:45 +02:00
|
|
|
App.DI.registerManual('marked', function() { return window.marked; });
|
2014-10-18 18:06:22 +02:00
|
|
|
App.DI.registerManual('nprogress', function() { return window.NProgress; });
|
2014-09-01 00:22:17 +02:00
|
|
|
App.DI.get('bootstrap');
|