Skip to content

Node.js based forum software built for the modern web

closes #5116

barisusakli600082adc7f8
diff --git a/package.json b/package.json
index b2e8413fb7..eabc1a2aa0 100644
--- a/package.json
+++ b/package.json
@@ -60,9 +60,9 @@
"nodebb-plugin-soundpack-default": "0.1.6",
"nodebb-plugin-spam-be-gone": "0.4.10",
"nodebb-rewards-essentials": "0.0.9",
- "nodebb-theme-lavender": "3.0.14",
- "nodebb-theme-persona": "4.1.61",
- "nodebb-theme-vanilla": "5.1.41",
+ "nodebb-theme-lavender": "3.0.15",
+ "nodebb-theme-persona": "4.1.62",
+ "nodebb-theme-vanilla": "5.1.42",
"nodebb-widget-essentials": "2.0.12",
"nodemailer": "2.0.0",
"nodemailer-sendmail-transport": "1.0.0",
diff --git a/public/src/widgets.js b/public/src/widgets.js
index ede518db4d..8d4eb10e1f 100644
--- a/public/src/widgets.js
+++ b/public/src/widgets.js
@@ -5,11 +5,11 @@
ajaxify.widgets = {};
ajaxify.widgets.reposition = function (location) {
- $('body [no-widget-class]').each(function () {
+ $('body [has-widget-class]').each(function () {
var $this = $(this);
- if ($this.attr('no-widget-target') === location) {
+ if ($this.attr('has-widget-target') === location) {
$this.removeClass();
- $this.addClass($this.attr('no-widget-class'));
+ $this.addClass($this.attr('has-widget-class'));
}
});
};
@@ -20,7 +20,7 @@
return callback();
}
- var widgetLocations = ['sidebar', 'footer', 'header'], numLocations;
+ var widgetLocations = ['sidebar', 'footer', 'header'];
$('#content [widget-area]').each(function () {
var location = $(this).attr('widget-area');
@@ -29,71 +29,61 @@
}
});
- numLocations = widgetLocations.length;
-
- if (!numLocations) {
- ajaxify.widgets.reposition();
- }
-
- function renderWidgets(locations) {
- $.get(config.relative_path + '/api/widgets/render' + (config['cache-buster'] ? '?v=' + config['cache-buster'] : ''), {
- locations: locations,
- template: template + '.tpl',
- url: url,
- isMobile: utils.isMobile()
- }, function (renderedAreas) {
- for (var x = 0; x < renderedAreas.length; ++x) {
- var renderedWidgets = renderedAreas[x].widgets,
- location = renderedAreas[x].location,
- html = '';
-
- for (var i = 0; i < renderedWidgets.length; ++i) {
- html += templates.parse(renderedWidgets[i].html, {});
- }
-
- var area = $('#content [widget-area="' + location + '"]');
+ $.get(config.relative_path + '/api/widgets/render' + (config['cache-buster'] ? '?v=' + config['cache-buster'] : ''), {
+ locations: widgetLocations,
+ template: template + '.tpl',
+ url: url,
+ isMobile: utils.isMobile()
+ }, function (renderedAreas) {
+ for (var x = 0; x < renderedAreas.length; ++x) {
+ var renderedWidgets = renderedAreas[x].widgets;
+ var location = renderedAreas[x].location;
+ var html = '';
+
+ for (var i = 0; i < renderedWidgets.length; ++i) {
+ html += templates.parse(renderedWidgets[i].html, {});
+ }
- if (!area.length && window.location.pathname.indexOf('/admin') === -1 && renderedWidgets.length) {
- if (location === 'footer' && !$('#content [widget-area="footer"]').length) {
- $('#content').append($('<div class="row"><div widget-area="footer" class="col-xs-12"></div></div>'));
- } else if (location === 'sidebar' && !$('#content [widget-area="sidebar"]').length) {
- if ($('[component="account/cover"]').length) {
- $('[component="account/cover"]').nextAll().wrapAll($('<div class="row"><div class="col-lg-9 col-xs-12"></div><div widget-area="sidebar" class="col-lg-3 col-xs-12"></div></div></div>'));
- } else if ($('[component="groups/cover"]').length) {
- $('[component="groups/cover"]').nextAll().wrapAll($('<div class="row"><div class="col-lg-9 col-xs-12"></div><div widget-area="sidebar" class="col-lg-3 col-xs-12"></div></div></div>'));
- } else {
- $('#content > *').wrapAll($('<div class="row"><div class="col-lg-9 col-xs-12"></div><div widget-area="sidebar" class="col-lg-3 col-xs-12"></div></div></div>'));
- }
- } else if (location === 'header' && !$('#content [widget-area="header"]').length) {
- $('#content').prepend($('<div class="row"><div widget-area="header" class="col-xs-12"></div></div>'));
+ var area = $('#content [widget-area="' + location + '"]');
+
+ if (!area.length && window.location.pathname.indexOf('/admin') === -1 && renderedWidgets.length) {
+ if (location === 'footer' && !$('#content [widget-area="footer"]').length) {
+ $('#content').append($('<div class="row"><div widget-area="footer" class="col-xs-12"></div></div>'));
+ } else if (location === 'sidebar' && !$('#content [widget-area="sidebar"]').length) {
+ if ($('[component="account/cover"]').length) {
+ $('[component="account/cover"]').nextAll().wrapAll($('<div class="row"><div class="col-lg-9 col-xs-12"></div><div widget-area="sidebar" class="col-lg-3 col-xs-12"></div></div></div>'));
+ } else if ($('[component="groups/cover"]').length) {
+ $('[component="groups/cover"]').nextAll().wrapAll($('<div class="row"><div class="col-lg-9 col-xs-12"></div><div widget-area="sidebar" class="col-lg-3 col-xs-12"></div></div></div>'));
+ } else {
+ $('#content > *').wrapAll($('<div class="row"><div class="col-lg-9 col-xs-12"></div><div widget-area="sidebar" class="col-lg-3 col-xs-12"></div></div></div>'));
}
-
- area = $('#content [widget-area="' + location + '"]');
+ } else if (location === 'header' && !$('#content [widget-area="header"]').length) {
+ $('#content').prepend($('<div class="row"><div widget-area="header" class="col-xs-12"></div></div>'));
}
- area.html(html);
+ area = $('#content [widget-area="' + location + '"]');
+ }
- if (!renderedWidgets.length) {
- area.addClass('hidden');
- ajaxify.widgets.reposition(location);
- }
+ area.html(html);
+
+ if (renderedWidgets.length) {
+ area.removeClass('hidden');
+ ajaxify.widgets.reposition(location);
}
+ }
- var widgetAreas = $('#content [widget-area]');
- widgetAreas.find('img:not(.not-responsive)').addClass('img-responsive');
- widgetAreas.find('.timeago').timeago();
- widgetAreas.find('img[title].teaser-pic,img[title].user-img').each(function () {
- $(this).tooltip({
- placement: 'top',
- title: $(this).attr('title')
- });
+ var widgetAreas = $('#content [widget-area]');
+ widgetAreas.find('img:not(.not-responsive)').addClass('img-responsive');
+ widgetAreas.find('.timeago').timeago();
+ widgetAreas.find('img[title].teaser-pic,img[title].user-img').each(function () {
+ $(this).tooltip({
+ placement: 'top',
+ title: $(this).attr('title')
});
- $(window).trigger('action:widgets.loaded', {});
-
- callback(renderedAreas);
});
- }
+ $(window).trigger('action:widgets.loaded', {});
- renderWidgets(widgetLocations);
+ callback(renderedAreas);
+ });
};
}(ajaxify || {}));