Skip to content
Snippets Groups Projects
Commit df589e8a authored by Jay Friendly's avatar Jay Friendly
Browse files

Issue #2969720: Update page title with unread thread count

parent 39854b0a
No related branches found
No related tags found
No related merge requests found
......@@ -38,6 +38,32 @@ Drupal.PrivateMessageNotificationBlock = {};
}
notificationWrapper.find(".private-message-page-link").text(unreadThreadCount);
// Get the current page title.
var pageTitle = $("title").text();
// Check if there are any unread threads.
if (unreadThreadCount) {
// Check if the unread thread count is already in the page title.
if (pageTitle.match(/^\(\d+\)\s/)) {
// Update the unread thread count in the page title.
pageTitle = pageTitle.replace(/^\(\d+\)\s/, "(" + unreadThreadCount + ") ");
}
else {
// Add the unread thread count to the URL.
pageTitle = "(" + unreadThreadCount + ") " + pageTitle;
}
}
// No unread messages.
else {
// Check if thread count currently exists in the page title.
if (pageTitle.match(/^\(\d+\)\s/)) {
// Remove the unread thread count from the page title.
pageTitle = pageTitle.replace(/^\(\d+\)\s/, "");
}
}
// Set the updated title.
$("title").text(pageTitle);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment