mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
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
This commit is contained in:
commit
3701d83ecb
5 changed files with 134 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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 -->
|
||||
|
||||
|
|
|
@ -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 -->
|
||||
|
|
|
@ -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>'));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue