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 // app
// --- // ---
(function ($) { (function () {
'use strict'; '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" // @include "inc/**/*.js"
var filename = 'client/js/scripts.js', var $ = jQuery,
$scriptTag = $('script[src$="' + filename + '"]'), filename = 'client/js/scripts.js',
src = $scriptTag.attr('src'), $script = $('script[src$="' + filename + '"]'),
mode = $scriptTag.data('mode'), mode = $script.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'); });
};
if (mode === 'info') { if (mode === 'info') {
modulejs.define('$', function () { return jQuery; });
$(function () { modulejs.require('info'); }); $(function () { modulejs.require('info'); });
} else if (mode === 'php') { } else if (mode === 'php') {
$.getJSON('.', { $.getJSON('.', {action: 'get', options: true, types: true, langs: true, server: true}, function (config) {
action: 'get',
options: true, modulejs.define('config', config);
types: true, $(function () { modulejs.require('main'); });
langs: true, });
server: true
}, run);
} else if (mode === 'aai') { } 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(); var deferred = $.Deferred();
@ -80,18 +70,21 @@
loadJson(appHref + 'conf/langs.json') loadJson(appHref + 'conf/langs.json')
).done(function (options, types, langs) { ).done(function (options, types, langs) {
run({ var config = {
options: options, options: options,
types: types, types: types,
langs: langs, langs: langs,
server: { server: {
backend: mode, backend: mode,
api: false, api: false,
name: 'apache', name: 'apache',
version: null version: null
} }
}); };
modulejs.define('config', config);
$(function () { modulejs.require('main'); });
}); });
} }
}(jQuery)); }());