From 0d625761be2c150d2e7593fd9e2c854e55d3ae76 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Wed, 12 Mar 2014 17:11:13 -0400 Subject: [PATCH] fixing bug introduced @ da0355ef79e0e9d108899336c003a1c043dd85f1 (multiple widget areas defined = explosion) --- public/src/ajaxify.js | 37 +++++++++++++++++++------------------ public/src/forum/topic.js | 25 +++++++++++++++++++------ 2 files changed, 38 insertions(+), 24 deletions(-) diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index 1ebfb4ddbe..9325a88be2 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -165,22 +165,26 @@ var ajaxify = {}; numLocations = widgetLocations.length; - function renderWidget(err, renderedWidgets) { - if (area.html()) { - 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')); - }); + function renderWidgets(location) { + var area = $('#content [widget-area="' + location + '"]'); + + socket.emit('widgets.render', {template: tpl_url + '.tpl', url: url, location: location}, function(err, renderedWidgets) { + if (area.html()) { + 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')); + }); + } } - } - checkCallback(); + checkCallback(); + }); } function checkCallback() { @@ -192,10 +196,7 @@ var ajaxify = {}; for (var i in widgetLocations) { if (widgetLocations.hasOwnProperty(i)) { - var location = widgetLocations, - area = $('#content [widget-area="' + location + '"]'); - - socket.emit('widgets.render', {template: tpl_url + '.tpl', url: url, location: location}, renderWidget); + renderWidgets(widgetLocations[i]); } } diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index c261bd3c12..b3e596448e 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -1,3 +1,6 @@ +"use strict"; +/*global define, templates, app, bootbox, socket, translator, config, ajaxify, RELATIVE_PATH*/ + define(['composer', 'forum/pagination'], function(composer, pagination) { var Topic = {}, infiniteLoaderActive = false, @@ -51,9 +54,17 @@ define(['composer', 'forum/pagination'], function(composer, pagination) { showBottomPostBar(); - if (thread_state.locked === '1') set_locked_state(true); - if (thread_state.deleted === '1') set_delete_state(true); - if (thread_state.pinned === '1') set_pinned_state(true); + if (thread_state.locked === '1') { + set_locked_state(true); + } + + if (thread_state.deleted === '1') { + set_delete_state(true); + } + + if (thread_state.pinned === '1') { + set_pinned_state(true); + } if (expose_tools === '1') { var moveThreadModal = $('#move_thread_modal'); @@ -218,10 +229,12 @@ define(['composer', 'forum/pagination'], function(composer, pagination) { app.alertSuccess(translated); }); + function removePost() { + $(this).remove(); + } + for(var i=0; i