Refactor js init sequence.

This commit is contained in:
Lars Jung 2015-04-18 00:38:28 +02:00
parent b1b5e37ab6
commit 5f2a7985d8
5 changed files with 34 additions and 33 deletions

View file

@ -0,0 +1,30 @@
modulejs.define('boot', ['$'], function ($) {
if ($('html').hasClass('no-browser')) {
return;
}
var module = $('script[data-module]').data('module');
var data = {action: 'get', setup: true, options: true, types: true, theme: true, langs: true};
var url;
if (module === 'index') {
url = '.';
} else if (module === 'info') {
data.updatecmds = true;
url = 'server/php/index.php';
} else {
return;
}
$.ajax({
url: url,
data: data,
type: 'POST',
dataType: 'json'
}).done(function (config) {
modulejs.define('config', config);
$(function () { modulejs.require('main/' + module); });
});
});