aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/styles/prosilver/template/ajax.js
diff options
context:
space:
mode:
authorCesar G <prototech91@gmail.com>2013-11-23 20:11:49 -0800
committerCesar G <prototech91@gmail.com>2013-12-30 11:12:15 -0800
commitf4b832a27d128ec84142dfe6133dc6ba96b8d3a9 (patch)
tree02716fb3c67019d8f4749faa7ce554334cff9fa5 /phpBB/styles/prosilver/template/ajax.js
parentbe67124dc7d5461c9b085e4dc3f32ece87e4b1aa (diff)
downloadforums-f4b832a27d128ec84142dfe6133dc6ba96b8d3a9.tar
forums-f4b832a27d128ec84142dfe6133dc6ba96b8d3a9.tar.gz
forums-f4b832a27d128ec84142dfe6133dc6ba96b8d3a9.tar.bz2
forums-f4b832a27d128ec84142dfe6133dc6ba96b8d3a9.tar.xz
forums-f4b832a27d128ec84142dfe6133dc6ba96b8d3a9.zip
[ticket/12034] AJAXify notifications popup.
PHPBB3-12034
Diffstat (limited to 'phpBB/styles/prosilver/template/ajax.js')
-rw-r--r--phpBB/styles/prosilver/template/ajax.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js
index 28656d47d3..38f9f80b44 100644
--- a/phpBB/styles/prosilver/template/ajax.js
+++ b/phpBB/styles/prosilver/template/ajax.js
@@ -106,6 +106,50 @@ 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') {
+ var unreadRows = $('#notification_list li.bg2');
+
+ // Remove the unread status.
+ unreadRows.removeClass('bg2');
+ unreadRows.find('a.mark_read').remove();
+
+ // Update the notification link to the real URL.
+ unreadRows.each(function() {
+ var link = $(this).find('a');
+ link.attr('href', link.attr('data-real-url'));
+ });
+ // Set the unread count to 0.
+ $('#notification_list_button strong').html(0);
+ // Remove the Mark all read link
+ $('#mark_all_notifications').remove();
+
+ phpbb.closeDarkenWrapper(3000);
+ }
+});
+
+// This callback will mark a notification read
+phpbb.addAjaxCallback('notification.mark_read', function(res) {
+ if (typeof res.success !== 'undefined') {
+ var el = $(this),
+ unreadCountEl = $('#notification_list_button strong'),
+ unreadCount = Number(unreadCountEl.html()),
+ link = el.siblings('a');
+
+ // Remove the unread status.
+ el.parent('li.bg2').removeClass('bg2');
+ el.remove();
+ link.attr('href', link.attr('data-real-url'));
+ // Update the unread count
+ unreadCountEl.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),