aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/styles/prosilver/template/ajax.js
diff options
context:
space:
mode:
authorNathan Guse <nathaniel.guse@gmail.com>2013-12-30 12:20:22 -0800
committerNathan Guse <nathaniel.guse@gmail.com>2013-12-30 12:20:22 -0800
commit821f737560330827ded1fd5eabead6ac23087e24 (patch)
tree9c5247e2a0e93d15ef5fcf2a95b36cc6441897df /phpBB/styles/prosilver/template/ajax.js
parentb186d31ce6b0502898e93cfa5e69e2d0da0758d0 (diff)
parentd76ec60ee15c1fafbb4212eda77b842e793108d0 (diff)
downloadforums-821f737560330827ded1fd5eabead6ac23087e24.tar
forums-821f737560330827ded1fd5eabead6ac23087e24.tar.gz
forums-821f737560330827ded1fd5eabead6ac23087e24.tar.bz2
forums-821f737560330827ded1fd5eabead6ac23087e24.tar.xz
forums-821f737560330827ded1fd5eabead6ac23087e24.zip
Merge pull request #1890 from prototech/ticket/12034
[ticket/12034] AJAXify notifications popup.
Diffstat (limited to 'phpBB/styles/prosilver/template/ajax.js')
-rw-r--r--phpBB/styles/prosilver/template/ajax.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js
index 28656d47d3..1d70adc48d 100644
--- a/phpBB/styles/prosilver/template/ajax.js
+++ b/phpBB/styles/prosilver/template/ajax.js
@@ -106,6 +106,47 @@ phpbb.addAjaxCallback('mark_topics_read', function(res, update_topic_links) {
phpbb.closeDarkenWrapper(3000);
});
+// This callback will mark all notifications read
+phpbb.addAjaxCallback('notification.mark_all_read', function(res) {
+ if (typeof res.success !== 'undefined') {
+ phpbb.markNotifications($('#notification_list li.bg2'), 0);
+ phpbb.closeDarkenWrapper(3000);
+ }
+});
+
+// This callback will mark a notification read
+phpbb.addAjaxCallback('notification.mark_read', function(res) {
+ if (typeof res.success !== 'undefined') {
+ var unreadCount = Number($('#notification_list_button strong').html()) - 1;
+ phpbb.markNotifications($(this).parent('li.bg2'), unreadCount);
+ }
+});
+
+/**
+ * Mark notification popup rows as read.
+ *
+ * @param {jQuery} el jQuery object(s) to mark read.
+ * @param {int} unreadCount The new unread notifications count.
+ */
+phpbb.markNotifications = function(el, unreadCount) {
+ // Remove the unread status.
+ el.removeClass('bg2');
+ el.find('a.mark_read').remove();
+
+ // Update the notification link to the real URL.
+ el.each(function() {
+ var link = $(this).find('a');
+ link.attr('href', link.attr('data-real-url'));
+ });
+
+ // Update the unread count.
+ $('#notification_list_button strong').html(unreadCount);
+ // Remove the Mark all read link if there are no unread notifications.
+ if (!unreadCount) {
+ $('#mark_all_notifications').remove();
+ }
+};
+
// This callback finds the post from the delete link, and removes it.
phpbb.addAjaxCallback('post_delete', function() {
var el = $(this),