|
|
@ -42,8 +42,8 @@ var ajaxify = {};
|
|
|
|
|
|
|
|
|
|
|
|
$(window).trigger('action:ajaxify.start', {url: url});
|
|
|
|
$(window).trigger('action:ajaxify.start', {url: url});
|
|
|
|
|
|
|
|
|
|
|
|
if ($('#content').hasClass('ajaxifying')) {
|
|
|
|
if ($('#content').hasClass('ajaxifying') && apiXHR) {
|
|
|
|
templates.cancelRequest();
|
|
|
|
apiXHR.abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Remove trailing slash
|
|
|
|
// Remove trailing slash
|
|
|
@ -59,7 +59,7 @@ var ajaxify = {};
|
|
|
|
hash = window.location.hash ? window.location.hash : '';
|
|
|
|
hash = window.location.hash ? window.location.hash : '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (ajaxify.isTemplateAvailable(tpl_url) && !ajaxify.forceRefresh(tpl_url)) {
|
|
|
|
if (ajaxify.isTemplateAvailable(tpl_url) && !!!templatesConfig.force_refresh[tpl_url]) {
|
|
|
|
ajaxify.currentPage = tpl_url;
|
|
|
|
ajaxify.currentPage = tpl_url;
|
|
|
|
|
|
|
|
|
|
|
|
if (window.history && window.history.pushState) {
|
|
|
|
if (window.history && window.history.pushState) {
|
|
|
@ -83,10 +83,10 @@ var ajaxify = {};
|
|
|
|
|
|
|
|
|
|
|
|
translator.load(tpl_url);
|
|
|
|
translator.load(tpl_url);
|
|
|
|
|
|
|
|
|
|
|
|
ajaxify.fadeOut();
|
|
|
|
$('#footer, #content').removeClass('hide').addClass('ajaxifying');
|
|
|
|
|
|
|
|
|
|
|
|
ajaxify.variables.flush();
|
|
|
|
ajaxify.variables.flush();
|
|
|
|
ajaxify.getData(function () {
|
|
|
|
ajaxify.loadData(function () {
|
|
|
|
ajaxify.loadScript(tpl_url);
|
|
|
|
ajaxify.loadScript(tpl_url);
|
|
|
|
|
|
|
|
|
|
|
|
if (typeof callback === 'function') {
|
|
|
|
if (typeof callback === 'function') {
|
|
|
@ -96,7 +96,7 @@ var ajaxify = {};
|
|
|
|
app.processPage();
|
|
|
|
app.processPage();
|
|
|
|
|
|
|
|
|
|
|
|
ajaxify.renderWidgets(tpl_url, url, function(err) {
|
|
|
|
ajaxify.renderWidgets(tpl_url, url, function(err) {
|
|
|
|
ajaxify.fadeIn();
|
|
|
|
$('#content, #footer').stop(true, true).removeClass('ajaxifying');
|
|
|
|
ajaxify.initialLoad = false;
|
|
|
|
ajaxify.initialLoad = false;
|
|
|
|
|
|
|
|
|
|
|
|
app.refreshTitle(url);
|
|
|
|
app.refreshTitle(url);
|
|
|
@ -126,28 +126,10 @@ var ajaxify = {};
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
ajaxify.cancelRequest = function() {
|
|
|
|
|
|
|
|
if (apiXHR) {
|
|
|
|
|
|
|
|
apiXHR.abort();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ajaxify.isTemplateAvailable = function(tpl) {
|
|
|
|
ajaxify.isTemplateAvailable = function(tpl) {
|
|
|
|
return $.inArray(tpl + '.tpl', availableTemplates) !== -1;
|
|
|
|
return $.inArray(tpl + '.tpl', availableTemplates) !== -1;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
ajaxify.forceRefresh = function(tpl) {
|
|
|
|
|
|
|
|
return !!templatesConfig.force_refresh[tpl];
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ajaxify.fadeIn = function() {
|
|
|
|
|
|
|
|
$('#content, #footer').stop(true, true).removeClass('ajaxifying');
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ajaxify.fadeOut = function() {
|
|
|
|
|
|
|
|
$('#footer, #content').removeClass('hide').addClass('ajaxifying');
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ajaxify.getTemplateMapping = function(url) {
|
|
|
|
ajaxify.getTemplateMapping = function(url) {
|
|
|
|
var tpl_url = ajaxify.getCustomTemplateMapping(url.split('?')[0]);
|
|
|
|
var tpl_url = ajaxify.getCustomTemplateMapping(url.split('?')[0]);
|
|
|
|
|
|
|
|
|
|
|
@ -190,7 +172,7 @@ var ajaxify = {};
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
ajaxify.getData = function(callback, url, template) {
|
|
|
|
ajaxify.loadData = function(callback, url, template) {
|
|
|
|
var location = document.location || window.location,
|
|
|
|
var location = document.location || window.location,
|
|
|
|
api_url = (url === '' || url === '/') ? 'home' : url,
|
|
|
|
api_url = (url === '' || url === '/') ? 'home' : url,
|
|
|
|
tpl_url = ajaxify.getCustomTemplateMapping(api_url.split('?')[0]);
|
|
|
|
tpl_url = ajaxify.getCustomTemplateMapping(api_url.split('?')[0]);
|
|
|
@ -224,7 +206,7 @@ var ajaxify = {};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
error: function(data, textStatus) {
|
|
|
|
error: function(data, textStatus) {
|
|
|
|
$('#content, #footer').stop(true, true).removeClass('ajaxifying');
|
|
|
|
$('#content, #footer').stop(true, true).removeClass('ajaxifying');
|
|
|
|
if (data && data.status == 404) {
|
|
|
|
if (data && data.status === 404) {
|
|
|
|
return ajaxify.go('404');
|
|
|
|
return ajaxify.go('404');
|
|
|
|
} else if (data && data.status === 403) {
|
|
|
|
} else if (data && data.status === 403) {
|
|
|
|
return ajaxify.go('403');
|
|
|
|
return ajaxify.go('403');
|
|
|
|