diff options
| -rw-r--r-- | phpBB/includes/functions_display.php | 28 | ||||
| -rw-r--r-- | phpBB/styles/prosilver/template/ajax.js | 88 | ||||
| -rw-r--r-- | phpBB/styles/prosilver/template/index_body.html | 2 | ||||
| -rw-r--r-- | phpBB/styles/prosilver/template/viewforum_body.html | 6 | ||||
| -rw-r--r-- | phpBB/viewforum.php | 14 | 
5 files changed, 134 insertions, 4 deletions
diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 73129803ee..cd4c901b58 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -61,6 +61,20 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod  		{  			markread('all', false, false, request_var('mark_time', 0)); +			if ($request->is_ajax()) +			{ +				// Tell the ajax script what language vars and URL need to be replaced +				$data = array( +					'NO_UNREAD_POSTS'	=> $user->lang['NO_UNREAD_POSTS'], +					'UNREAD_POSTS'		=> $user->lang['UNREAD_POSTS'], +					'U_MARK_FORUMS'		=> ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums&mark_time=' . time()) : '', +					'MESSAGE_TITLE'		=> $user->lang['INFORMATION'], +					'MESSAGE_TEXT'		=> $user->lang['FORUMS_MARKED'] +				); +				$json_response = new phpbb_json_response(); +				$json_response->send($data); +			} +  			trigger_error(  				$user->lang['FORUMS_MARKED'] . '<br /><br />' .  				sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect . '">', '</a>') @@ -313,6 +327,20 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod  			$message = sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect . '">', '</a>');  			meta_refresh(3, $redirect); +			if ($request->is_ajax()) +			{ +				// Tell the ajax script what language vars and URL need to be replaced +				$data = array( +					'NO_UNREAD_POSTS'	=> $user->lang['NO_UNREAD_POSTS'], +					'UNREAD_POSTS'		=> $user->lang['UNREAD_POSTS'], +					'U_MARK_FORUMS'		=> ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . '&f=' . $root_data['forum_id'] . '&mark=forums&mark_time=' . time()) : '', +					'MESSAGE_TITLE'		=> $user->lang['INFORMATION'], +					'MESSAGE_TEXT'		=> $user->lang['FORUMS_MARKED'] +				); +				$json_response = new phpbb_json_response(); +				$json_response->send($data); +			} +  			trigger_error($user->lang['FORUMS_MARKED'] . '<br /><br />' . $message);  		}  		else 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), diff --git a/phpBB/styles/prosilver/template/index_body.html b/phpBB/styles/prosilver/template/index_body.html index 6babbf5997..0682abffed 100644 --- a/phpBB/styles/prosilver/template/index_body.html +++ b/phpBB/styles/prosilver/template/index_body.html @@ -8,7 +8,7 @@  	<!-- IF S_DISPLAY_SEARCH -->  		<li><a href="{U_SEARCH_UNANSWERED}">{L_SEARCH_UNANSWERED}</a><!-- IF S_LOAD_UNREADS --> • <a href="{U_SEARCH_UNREAD}">{L_SEARCH_UNREAD}</a><!-- ENDIF --><!-- IF S_USER_LOGGED_IN --> • <a href="{U_SEARCH_NEW}">{L_SEARCH_NEW}</a><!-- ENDIF --> • <a href="{U_SEARCH_ACTIVE_TOPICS}">{L_SEARCH_ACTIVE_TOPICS}</a></li>  	<!-- ENDIF --> -	<!-- IF not S_IS_BOT and U_MARK_FORUMS --><li class="rightside"><a href="{U_MARK_FORUMS}" accesskey="m" data-ajax="true">{L_MARK_FORUMS_READ}</a></li><!-- ENDIF --> +	<!-- IF not S_IS_BOT and U_MARK_FORUMS --><li class="rightside"><a href="{U_MARK_FORUMS}" accesskey="m" data-ajax="mark_forums_read" data-overlay="false">{L_MARK_FORUMS_READ}</a></li><!-- ENDIF -->  </ul>  <!-- ENDIF --> diff --git a/phpBB/styles/prosilver/template/viewforum_body.html b/phpBB/styles/prosilver/template/viewforum_body.html index a3239602ae..b47c13d573 100644 --- a/phpBB/styles/prosilver/template/viewforum_body.html +++ b/phpBB/styles/prosilver/template/viewforum_body.html @@ -28,7 +28,7 @@  <!-- IF S_HAS_SUBFORUM -->  <!-- IF not S_IS_BOT and U_MARK_FORUMS -->  <ul class="linklist"> -	<li class="rightside"><a href="{U_MARK_FORUMS}">{L_MARK_SUBFORUMS_READ}</a></li> +	<li class="rightside"><a href="{U_MARK_FORUMS}" data-ajax="mark_forums_read" data-overlay="false">{L_MARK_SUBFORUMS_READ}</a></li>  </ul>  <!-- ENDIF -->  	<!-- INCLUDE forumlist_body.html --> @@ -57,7 +57,7 @@  	<!-- IF .pagination or TOTAL_POSTS or TOTAL_TOPICS -->  		<div class="pagination"> -			<!-- IF not S_IS_BOT and U_MARK_TOPICS --><a href="{U_MARK_TOPICS}" accesskey="m" data-ajax="true">{L_MARK_TOPICS_READ}</a> • <!-- ENDIF --> +			<!-- IF not S_IS_BOT and U_MARK_TOPICS --><a href="{U_MARK_TOPICS}" accesskey="m" data-ajax="mark_topics_read" data-overlay="false">{L_MARK_TOPICS_READ}</a> • <!-- ENDIF -->  			<!-- IF TOTAL_TOPICS -->{TOTAL_TOPICS} • <!-- ENDIF -->  			<!-- IF .pagination -->  				<!-- INCLUDE pagination.html --> @@ -211,7 +211,7 @@  		<!-- IF PAGE_NUMBER or TOTAL_POSTS or TOTAL_TOPICS -->  		<div class="pagination"> -			<!-- IF TOTAL_TOPICS and not S_IS_BOT and U_MARK_TOPICS --><a href="{U_MARK_TOPICS}">{L_MARK_TOPICS_READ}</a> •  <!-- ENDIF --> +			<!-- IF TOTAL_TOPICS and not S_IS_BOT and U_MARK_TOPICS --><a href="{U_MARK_TOPICS}" data-ajax="mark_topics_read" data-overlay="false">{L_MARK_TOPICS_READ}</a> •  <!-- ENDIF -->  			<!-- IF TOTAL_POSTS and not NEWEST_USER --> {TOTAL_POSTS}<!-- ELSEIF TOTAL_TOPICS and not NEWEST_USER --> {TOTAL_TOPICS} • <!-- ENDIF -->  			<!-- IF TOTAL_USERS -->{TOTAL_USERS} • <!-- ENDIF -->  			<!-- IF .pagination --> diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 83e5d4caa5..5fed514a12 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -181,6 +181,20 @@ if ($mark_read == 'topics')  	$redirect_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id);  	meta_refresh(3, $redirect_url); +	if ($request->is_ajax()) +	{ +		// Tell the ajax script what language vars and URL need to be replaced +		$data = array( +			'NO_UNREAD_POSTS'	=> $user->lang['NO_UNREAD_POSTS'], +			'UNREAD_POSTS'		=> $user->lang['UNREAD_POSTS'], +			'U_MARK_TOPICS'		=> ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . "&f=$forum_id&mark=topics&mark_time=" . time()) : '', +			'MESSAGE_TITLE'		=> $user->lang['INFORMATION'], +			'MESSAGE_TEXT'		=> $user->lang['TOPICS_MARKED'] +		); +		$json_response = new phpbb_json_response(); +		$json_response->send($data); +	} +  	trigger_error($user->lang['TOPICS_MARKED'] . '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect_url . '">', '</a>'));  }  | 
