More changes on init procedure.

This commit is contained in:
Lars Jung 2012-10-11 15:05:10 +02:00
parent a087e96d69
commit 69ffcc2d32

View file

@ -16,52 +16,42 @@
// app
// ---
(function ($) {
(function () {
'use strict';
/*global amplify, jQuery, Modernizr, moment, _ */
// `jQuery`, `moment` and `underscore` are itself functions,
// so they have to be wrapped to not be handled as constructors.
modulejs.define('amplify', amplify);
modulejs.define('$', function () { return jQuery; });
modulejs.define('modernizr', Modernizr);
modulejs.define('moment', function () { return moment; });
modulejs.define('_', function () { return _; });
// @include "inc/**/*.js"
var filename = 'client/js/scripts.js',
$scriptTag = $('script[src$="' + filename + '"]'),
src = $scriptTag.attr('src'),
mode = $scriptTag.data('mode'),
appHref = src.substr(0, src.length - filename.length),
run = function (config) {
/*global amplify, Base64, jQuery, Modernizr, moment, _ */
// `jQuery`, `moment` and `underscore` are itself functions,
// so they have to be wrapped to not be handled as constructors.
modulejs.define('config', config);
modulejs.define('amplify', amplify);
modulejs.define('$', function () { return jQuery; });
modulejs.define('modernizr', Modernizr);
modulejs.define('moment', function () { return moment; });
modulejs.define('_', function () { return _; });
$(function () { modulejs.require('main'); });
};
var $ = jQuery,
filename = 'client/js/scripts.js',
$script = $('script[src$="' + filename + '"]'),
mode = $script.data('mode');
if (mode === 'info') {
modulejs.define('$', function () { return jQuery; });
$(function () { modulejs.require('info'); });
} else if (mode === 'php') {
$.getJSON('.', {
action: 'get',
options: true,
types: true,
langs: true,
server: true
}, run);
$.getJSON('.', {action: 'get', options: true, types: true, langs: true, server: true}, function (config) {
modulejs.define('config', config);
$(function () { modulejs.require('main'); });
});
} else if (mode === 'aai') {
var loadJson = function (href) {
var src = $script.attr('src'),
appHref = src.substr(0, src.length - filename.length),
loadJson = function (href) {
var deferred = $.Deferred();
@ -80,18 +70,21 @@
loadJson(appHref + 'conf/langs.json')
).done(function (options, types, langs) {
run({
options: options,
types: types,
langs: langs,
server: {
backend: mode,
api: false,
name: 'apache',
version: null
}
});
var config = {
options: options,
types: types,
langs: langs,
server: {
backend: mode,
api: false,
name: 'apache',
version: null
}
};
modulejs.define('config', config);
$(function () { modulejs.require('main'); });
});
}
}(jQuery));
}());