|
|
@ -24,17 +24,18 @@ $(document).ready(function() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function onAjaxError(err, url, callback, quiet) {
|
|
|
|
function onAjaxError(err, url, callback, quiet) {
|
|
|
|
var data = err.data, textStatus = err.textStatus;
|
|
|
|
var data = err.data,
|
|
|
|
|
|
|
|
textStatus = err.textStatus;
|
|
|
|
$('#content, #footer').removeClass('ajaxifying');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (data) {
|
|
|
|
if (data) {
|
|
|
|
if (data.status === 404) {
|
|
|
|
if (data.status === 404 || data.status === 500) {
|
|
|
|
return ajaxify.go('404');
|
|
|
|
$('#footer, #content').removeClass('hide').addClass('ajaxifying');
|
|
|
|
|
|
|
|
return renderTemplate(url, data.status.toString(), data.responseJSON, (new Date()).getTime(), callback);
|
|
|
|
} else if (data.status === 401) {
|
|
|
|
} else if (data.status === 401) {
|
|
|
|
app.alertError('[[global:please_log_in]]');
|
|
|
|
app.alertError('[[global:please_log_in]]');
|
|
|
|
return ajaxify.go('login');
|
|
|
|
return ajaxify.go('login');
|
|
|
|
} else if (data.status === 403) {
|
|
|
|
} else if (data.status === 403) {
|
|
|
|
|
|
|
|
$('#content, #footer').removeClass('ajaxifying');
|
|
|
|
app.alertError('[[error:no-privileges]]');
|
|
|
|
app.alertError('[[error:no-privileges]]');
|
|
|
|
} else if (data.status === 302) {
|
|
|
|
} else if (data.status === 302) {
|
|
|
|
return ajaxify.go(data.responseJSON.slice(1), callback, quiet);
|
|
|
|
return ajaxify.go(data.responseJSON.slice(1), callback, quiet);
|
|
|
@ -56,10 +57,8 @@ $(document).ready(function() {
|
|
|
|
apiXHR.abort();
|
|
|
|
apiXHR.abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Remove trailing slash
|
|
|
|
// Remove relative path and trailing slash
|
|
|
|
url = url.replace(/\/$/, "");
|
|
|
|
url = ajaxify.removeRelativePath(url.replace(/\/$/, ''));
|
|
|
|
|
|
|
|
|
|
|
|
url = ajaxify.removeRelativePath(url);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var tpl_url = ajaxify.getTemplateMapping(url);
|
|
|
|
var tpl_url = ajaxify.getTemplateMapping(url);
|
|
|
|
|
|
|
|
|
|
|
@ -80,8 +79,8 @@ $(document).ready(function() {
|
|
|
|
translator.load(config.defaultLang, tpl_url);
|
|
|
|
translator.load(config.defaultLang, tpl_url);
|
|
|
|
|
|
|
|
|
|
|
|
$('#footer, #content').removeClass('hide').addClass('ajaxifying');
|
|
|
|
$('#footer, #content').removeClass('hide').addClass('ajaxifying');
|
|
|
|
var animationDuration = parseFloat($('#content').css('transition-duration')) || 0.2,
|
|
|
|
|
|
|
|
startTime = (new Date()).getTime();
|
|
|
|
var startTime = (new Date()).getTime();
|
|
|
|
|
|
|
|
|
|
|
|
ajaxify.variables.flush();
|
|
|
|
ajaxify.variables.flush();
|
|
|
|
ajaxify.loadData(url, function(err, data) {
|
|
|
|
ajaxify.loadData(url, function(err, data) {
|
|
|
@ -89,48 +88,54 @@ $(document).ready(function() {
|
|
|
|
return onAjaxError(err, url, callback, quiet);
|
|
|
|
return onAjaxError(err, url, callback, quiet);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$(window).trigger('action:ajaxify.loadingTemplates', {});
|
|
|
|
renderTemplate(url, tpl_url, data, startTime, callback);
|
|
|
|
|
|
|
|
|
|
|
|
templates.parse(tpl_url, data, function(template) {
|
|
|
|
require(['search'], function(search) {
|
|
|
|
translator.translate(template, function(translatedTemplate) {
|
|
|
|
search.topicDOM.end();
|
|
|
|
setTimeout(function() {
|
|
|
|
});
|
|
|
|
$('#content').html(translatedTemplate);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
ajaxify.variables.parse();
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ajaxify.widgets.render(tpl_url, url, function() {
|
|
|
|
return false;
|
|
|
|
$(window).trigger('action:ajaxify.end', {url: url});
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(window).trigger('action:ajaxify.contentLoaded', {url: url});
|
|
|
|
function renderTemplate(url, tpl_url, data, startTime, callback) {
|
|
|
|
|
|
|
|
var animationDuration = parseFloat($('#content').css('transition-duration')) || 0.2;
|
|
|
|
|
|
|
|
$(window).trigger('action:ajaxify.loadingTemplates', {});
|
|
|
|
|
|
|
|
|
|
|
|
ajaxify.loadScript(tpl_url);
|
|
|
|
templates.parse(tpl_url, data, function(template) {
|
|
|
|
|
|
|
|
translator.translate(template, function(translatedTemplate) {
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
|
|
|
$('#content').html(translatedTemplate);
|
|
|
|
|
|
|
|
|
|
|
|
if (typeof callback === 'function') {
|
|
|
|
ajaxify.variables.parse();
|
|
|
|
callback();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.processPage();
|
|
|
|
ajaxify.widgets.render(tpl_url, url, function() {
|
|
|
|
|
|
|
|
$(window).trigger('action:ajaxify.end', {url: url});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$('#content, #footer').removeClass('ajaxifying');
|
|
|
|
$(window).trigger('action:ajaxify.contentLoaded', {url: url});
|
|
|
|
ajaxify.initialLoad = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.refreshTitle(url);
|
|
|
|
ajaxify.loadScript(tpl_url);
|
|
|
|
}, animationDuration * 1000 - ((new Date()).getTime() - startTime));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
if (typeof callback === 'function') {
|
|
|
|
});
|
|
|
|
callback();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
require(['search'], function(search) {
|
|
|
|
app.processPage();
|
|
|
|
search.topicDOM.end();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
$('#content, #footer').removeClass('ajaxifying');
|
|
|
|
}
|
|
|
|
ajaxify.initialLoad = false;
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
app.refreshTitle(url);
|
|
|
|
};
|
|
|
|
}, animationDuration * 1000 - ((new Date()).getTime() - startTime));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ajaxify.removeRelativePath = function(url) {
|
|
|
|
ajaxify.removeRelativePath = function(url) {
|
|
|
|
if (url.indexOf(RELATIVE_PATH.slice(1)) === 0) {
|
|
|
|
if (url.indexOf(RELATIVE_PATH.slice(1)) === 0) {
|
|
|
|