mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/10954] Mark forums read without popup or page refresh
PHPBB3-10954
This commit is contained in:
parent
9420647c43
commit
7ce009f2e2
4 changed files with 49 additions and 7 deletions
|
@ -61,12 +61,25 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
|
|||
{
|
||||
markread('all', false, false, request_var('mark_time', 0));
|
||||
|
||||
if (!$request->is_ajax())
|
||||
{
|
||||
trigger_error(
|
||||
$user->lang['FORUMS_MARKED'] . '<br /><br />' .
|
||||
sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect . '">', '</a>')
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Tell the ajax script what language vars need to be replaced
|
||||
$data = array(
|
||||
'NO_UNREAD_POSTS' => $user->lang['NO_UNREAD_POSTS'],
|
||||
'UNREAD_POSTS' => $user->lang['UNREAD_POSTS']
|
||||
);
|
||||
$json_response = new phpbb_json_response();
|
||||
$json_response->send($data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
trigger_error(sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
|
||||
}
|
||||
|
@ -313,9 +326,22 @@ 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())
|
||||
{
|
||||
trigger_error($user->lang['FORUMS_MARKED'] . '<br /><br />' . $message);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Tell the ajax script what language vars need to be replaced
|
||||
$data = array(
|
||||
'NO_UNREAD_POSTS' => $user->lang['NO_UNREAD_POSTS'],
|
||||
'UNREAD_POSTS' => $user->lang['UNREAD_POSTS']
|
||||
);
|
||||
$json_response = new phpbb_json_response();
|
||||
$json_response->send($data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>');
|
||||
meta_refresh(3, $redirect);
|
||||
|
|
|
@ -2,6 +2,22 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
// This callback will mark all forum icons read
|
||||
phpbb.add_ajax_callback('mark_forums_read', function(res) {
|
||||
var read_title = res.NO_UNREAD_POSTS;
|
||||
var unread_title = res.UNREAD_POSTS;
|
||||
|
||||
$('li.row dl.forum_unread').each(function(e) {
|
||||
$(this).removeClass('forum_unread').addClass('forum_read');
|
||||
$(this).children('dt[title=' + unread_title + ']').attr('title', read_title);
|
||||
});
|
||||
|
||||
$('li.row dl.forum_unread_subforum').each(function(e) {
|
||||
$(this).removeClass('forum_unread_subforum').addClass('forum_read_subforum');
|
||||
$(this).children('dt[title=' + unread_title + ']').attr('title', read_title);
|
||||
});
|
||||
});
|
||||
|
||||
// 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 -->
|
||||
|
|
Loading…
Add table
Reference in a new issue