Skip to content

Node.js based forum software built for the modern web

render widgets upon ajaxify - this widget feetorez iz completified!

psychobunnyc0df95b2dce0
diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js
index b5b8a258f1..ffaa39a189 100644
--- a/public/src/ajaxify.js
+++ b/public/src/ajaxify.js
@@ -93,7 +93,7 @@ var ajaxify = {};
translator.load(tpl_url);
- jQuery('#footer, #content').removeClass('hide').addClass('ajaxifying');
+ $('#footer, #content').removeClass('hide').addClass('ajaxifying');
templates.flush();
templates.load_template(function () {
@@ -110,11 +110,27 @@ var ajaxify = {};
app.processPage();
- jQuery('#content, #footer').stop(true, true).removeClass('ajaxifying');
- ajaxify.initialLoad = false;
+ var widgetLocations = [];
- app.refreshTitle(url);
- $(window).trigger('action:ajaxify.end', { url: url });
+ require(['vendor/async'], function(async) {
+ $('#content [widget-area]').each(function() {
+ widgetLocations.push(this.getAttribute('widget-area'));
+ });
+
+ async.each(widgetLocations, function(location, next) {
+ var area = $('#content [widget-area="' + location + '"]');
+
+ socket.emit('widgets.render', {template: tpl_url + '.tpl', location: location}, function(err, renderedWidgets) {
+ area.html(templates.prepare(area.html()).parse({widgets: renderedWidgets})).removeClass('hidden');
+ });
+ });
+
+ $('#content, #footer').stop(true, true).removeClass('ajaxifying');
+ ajaxify.initialLoad = false;
+
+ app.refreshTitle(url);
+ $(window).trigger('action:ajaxify.end', { url: url });
+ });
}, url);
return true;
diff --git a/public/templates/home.tpl b/public/templates/home.tpl
index b852449f21..0d64db4a35 100644
--- a/public/templates/home.tpl
+++ b/public/templates/home.tpl
@@ -2,6 +2,14 @@
{motd}
</div>
+<div widget-area="motd" class="hidden">
+ <!-- BEGIN widgets -->
+ <div class="well">
+ {widgets.html}
+ </div>
+ <!-- END widgets -->
+</div>
+
<div class="row home" itemscope itemtype="http://www.schema.org/ItemList">
<!-- BEGIN categories -->
<div class="{categories.class}">