mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 23:15:48 +01:00
moved widget rendering code into ajaxify.renderWidgets
This commit is contained in:
@@ -110,38 +110,12 @@ var ajaxify = {};
|
|||||||
|
|
||||||
app.processPage();
|
app.processPage();
|
||||||
|
|
||||||
var widgetLocations = [];
|
ajaxify.renderWidgets(tpl_url, url, location, function(err) {
|
||||||
|
$('#content, #footer').stop(true, true).removeClass('ajaxifying');
|
||||||
|
ajaxify.initialLoad = false;
|
||||||
|
|
||||||
require(['vendor/async'], function(async) {
|
app.refreshTitle(url);
|
||||||
$('#content [widget-area]').each(function() {
|
$(window).trigger('action:ajaxify.end', { url: url });
|
||||||
widgetLocations.push($(this).attr('widget-area'));
|
|
||||||
});
|
|
||||||
|
|
||||||
async.each(widgetLocations, function(location, next) {
|
|
||||||
var area = $('#content [widget-area="' + location + '"]');
|
|
||||||
|
|
||||||
socket.emit('widgets.render', {template: tpl_url + '.tpl', url: url, location: location}, function(err, renderedWidgets) {
|
|
||||||
area.html(templates.prepare(area.html()).parse({
|
|
||||||
widgets: renderedWidgets
|
|
||||||
})).removeClass('hidden');
|
|
||||||
|
|
||||||
if (!renderedWidgets.length) {
|
|
||||||
$('body [no-widget-class]').each(function() {
|
|
||||||
var $this = $(this);
|
|
||||||
$this.removeClass();
|
|
||||||
$this.addClass($this.attr('no-widget-class'));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
next(err);
|
|
||||||
});
|
|
||||||
}, function(err) {
|
|
||||||
$('#content, #footer').stop(true, true).removeClass('ajaxifying');
|
|
||||||
ajaxify.initialLoad = false;
|
|
||||||
|
|
||||||
app.refreshTitle(url);
|
|
||||||
$(window).trigger('action:ajaxify.end', { url: url });
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}, url);
|
}, url);
|
||||||
|
|
||||||
@@ -151,6 +125,39 @@ var ajaxify = {};
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ajaxify.renderWidgets = function(tpl_url, url, location, callback) {
|
||||||
|
var widgetLocations = [];
|
||||||
|
|
||||||
|
require(['vendor/async'], function(async) {
|
||||||
|
$('#content [widget-area]').each(function() {
|
||||||
|
widgetLocations.push($(this).attr('widget-area'));
|
||||||
|
});
|
||||||
|
|
||||||
|
async.each(widgetLocations, function(location, next) {
|
||||||
|
var area = $('#content [widget-area="' + location + '"]');
|
||||||
|
|
||||||
|
socket.emit('widgets.render', {template: tpl_url + '.tpl', url: url, location: location}, function(err, renderedWidgets) {
|
||||||
|
area.html(templates.prepare(area.html()).parse({
|
||||||
|
widgets: renderedWidgets
|
||||||
|
})).removeClass('hidden');
|
||||||
|
|
||||||
|
if (!renderedWidgets.length) {
|
||||||
|
$('body [no-widget-class]').each(function() {
|
||||||
|
var $this = $(this);
|
||||||
|
$this.removeClass();
|
||||||
|
$this.addClass($this.attr('no-widget-class'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
next(err);
|
||||||
|
});
|
||||||
|
}, function(err) {
|
||||||
|
callback(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
ajaxify.refresh = function() {
|
ajaxify.refresh = function() {
|
||||||
ajaxify.go(ajaxify.currentPage);
|
ajaxify.go(ajaxify.currentPage);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user