aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/styles/prosilver/template/ajax.js
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2012-12-19 21:05:33 -0500
committerOleg Pudeyev <oleg@bsdpower.com>2012-12-19 21:05:33 -0500
commit3701d83ecbd358c2ac78b74e314ddb74ce7d1812 (patch)
treec9cb0aa52991595e98c3942c82e8ea22db8d8d89 /phpBB/styles/prosilver/template/ajax.js
parente444f5bf2a8b30aefb3700ce358d2a6be66c8cb5 (diff)
parentdaf9de689a41dddae97152a21cc9bc894b48666f (diff)
downloadforums-3701d83ecbd358c2ac78b74e314ddb74ce7d1812.tar
forums-3701d83ecbd358c2ac78b74e314ddb74ce7d1812.tar.gz
forums-3701d83ecbd358c2ac78b74e314ddb74ce7d1812.tar.bz2
forums-3701d83ecbd358c2ac78b74e314ddb74ce7d1812.tar.xz
forums-3701d83ecbd358c2ac78b74e314ddb74ce7d1812.zip
Merge PR #1133 branch 'marc1706/ticket/10954' into develop
# By Marc Alexander # Via Marc Alexander * marc1706/ticket/10954: [ticket/10954] Add missing semi-colon [ticket/10954] Make sure to mark subforums unread and add small fixes [ticket/10954] Miscellaneous coding fixes [ticket/10954] Use quotes in attribute selectors and reduce use of each [ticket/10954] Change currentObject to $this for consistency [ticket/10954] Use function for closing alert popup [ticket/10954] Simplify marking forums read and fix topic marking [ticket/10954] Join array of class names instead of creating a string [ticket/10954] Fix coding guidelines infractions [ticket/10954] Change behavior of marking topics/forums [ticket/10954] Fix scope of current_object [ticket/10954] Only call $(this) once and reduce number of DOM traversals [ticket/10954] Modify is_ajax check for consistency [ticket/10954] Mark topics read without popup [ticket/10954] Mark forums read without popup or page refresh
Diffstat (limited to 'phpBB/styles/prosilver/template/ajax.js')
-rw-r--r--phpBB/styles/prosilver/template/ajax.js88
1 files changed, 88 insertions, 0 deletions
diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js
index fa31d3268f..6637df4c3d 100644
--- a/phpBB/styles/prosilver/template/ajax.js
+++ b/phpBB/styles/prosilver/template/ajax.js
@@ -2,6 +2,94 @@
"use strict";
+/**
+* Close popup alert after a specified delay
+*
+* @param int Delay in ms until darkenwrapper's click event is triggered
+*/
+phpbb.closeDarkenWrapper = function(delay) {
+ setTimeout(function() {
+ $('#darkenwrapper').trigger('click');
+ }, delay);
+};
+
+// This callback will mark all forum icons read
+phpbb.add_ajax_callback('mark_forums_read', function(res) {
+ var readTitle = res.NO_UNREAD_POSTS;
+ var unreadTitle = res.UNREAD_POSTS;
+ var iconsArray = {
+ 'forum_unread': 'forum_read',
+ 'forum_unread_subforum': 'forum_read_subforum',
+ 'forum_unread_locked': 'forum_read_locked',
+ };
+
+ $('li.row').find('dl[class*="forum_unread"]').each(function() {
+ var $this = $(this);
+
+ $.each(iconsArray, function(unreadClass, readClass) {
+ if ($this.hasClass(unreadClass)) {
+ $this.removeClass(unreadClass).addClass(readClass);
+ }
+ });
+ $this.children('dt[title="' + unreadTitle + '"]').attr('title', readTitle);
+ });
+
+ // Mark subforums read
+ $('a.subforum[class*="unread"]').removeClass('unread').addClass('read');
+
+ // Update mark forums read links
+ $('[data-ajax="mark_forums_read"]').attr('href', res.U_MARK_FORUMS);
+
+ phpbb.closeDarkenWrapper(3000);
+});
+
+// This callback will mark all topic icons read
+phpbb.add_ajax_callback('mark_topics_read', function(res) {
+ var readTitle = res.NO_UNREAD_POSTS;
+ var unreadTitle = res.UNREAD_POSTS;
+ var iconsArray = {
+ 'global_unread': 'global_read',
+ 'announce_unread': 'announce_read',
+ 'sticky_unread': 'sticky_read',
+ 'topic_unread': 'topic_read'
+ };
+ var iconsState = ['', '_hot', '_hot_mine', '_locked', '_locked_mine', '_mine'];
+ var unreadClassSelectors = '';
+ var classMap = {};
+ var classNames = [];
+
+ $.each(iconsArray, function(unreadClass, readClass) {
+ $.each(iconsState, function(key, value) {
+ // Only topics can be hot
+ if ((value == '_hot' || value == '_hot_mine') && unreadClass != 'topic_unread') {
+ return true;
+ }
+ classMap[unreadClass + value] = readClass + value;
+ classNames.push(unreadClass + value);
+ });
+ });
+
+ unreadClassSelectors = '.' + classNames.join(',.');
+
+ $('li.row').find(unreadClassSelectors).each(function() {
+ var $this = $(this);
+ $.each(classMap, function(unreadClass, readClass) {
+ if ($this.hasClass(unreadClass)) {
+ $this.removeClass(unreadClass).addClass(readClass);
+ }
+ });
+ $this.children('dt[title="' + unreadTitle + '"]').attr('title', readTitle);
+ });
+
+ // Remove link to first unread post
+ $('a').has('span.icon_topic_newest').remove();
+
+ // Update mark topics read links
+ $('[data-ajax="mark_topics_read"]').attr('href', res.U_MARK_TOPICS);
+
+ phpbb.closeDarkenWrapper(3000);
+});
+
// This callback finds the post from the delete link, and removes it.
phpbb.add_ajax_callback('post_delete', function() {
var el = $(this),