refactored translator system to be a require.js module, and not a global

This commit is contained in:
Julian Lam
2015-03-31 15:11:38 -04:00
parent b65f456d70
commit 47a7ab15be
41 changed files with 128 additions and 108 deletions

View File

@@ -4,11 +4,19 @@ var ajaxify = ajaxify || {};
$(document).ready(function() {
/*global app, templates, utils, socket, translator, config, RELATIVE_PATH*/
/*global app, templates, utils, socket, config, RELATIVE_PATH*/
var location = document.location || window.location,
rootUrl = location.protocol + '//' + (location.hostname || location.host) + (location.port ? ':' + location.port : ''),
apiXHR = null;
apiXHR = null,
translator;
// Dumb hack to fool ajaxify into thinking translator is still a global
// When ajaxify is migrated to a require.js module, then this can be merged into the "define" call
require(['translator'], function(_translator) {
translator = _translator;
});
$(window).on('popstate', function (ev) {
ev = ev.originalEvent;
@@ -49,11 +57,9 @@ $(document).ready(function() {
app.template = data.template.name;
translator.load(config.defaultLang, data.template.name);
renderTemplate(url, data.template.name, data, callback);
require(['search'], function(search) {
require(['translator', 'search'], function(translator, search) {
translator.load(config.defaultLang, data.template.name);
renderTemplate(url, data.template.name, data, callback);
search.topicDOM.end();
});
});