mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 12:09:21 +00:00
Display the number of notifications on page title.
This commit is contained in:
parent
d49b04e6fb
commit
46bb22b17b
@ -228,6 +228,22 @@ var ComunicWeb = {
|
||||
getAndShowJSONtemplate: function(targetElem, templateURI, additionalData, afterParsingJSONtemplate, cleanContainer){},
|
||||
},
|
||||
|
||||
/**
|
||||
* Page title management
|
||||
*/
|
||||
pageTitle: {
|
||||
|
||||
/**
|
||||
* Set a new title to the page
|
||||
*/
|
||||
setTitle: function(title){},
|
||||
|
||||
/**
|
||||
* Set new number of notifications
|
||||
*/
|
||||
setNotificationsNumber: function(number){}
|
||||
},
|
||||
|
||||
/**
|
||||
* Functions to check data input in forms
|
||||
*/
|
||||
|
@ -196,7 +196,7 @@ ComunicWeb.common.page = {
|
||||
}
|
||||
|
||||
//Change page title
|
||||
document.title = pageInfos.pageTitle;
|
||||
ComunicWeb.common.pageTitle.setTitle(pageInfos.pageTitle);
|
||||
|
||||
//Change page URL, if required
|
||||
if(additionnalData.no_url_update ? !additionnalData.no_url_update : true)
|
||||
|
53
assets/js/common/pageTitle.js
Normal file
53
assets/js/common/pageTitle.js
Normal file
@ -0,0 +1,53 @@
|
||||
/**
|
||||
* Page title management
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
|
||||
ComunicWeb.common.pageTitle = {
|
||||
|
||||
/**
|
||||
* Current page title
|
||||
*/
|
||||
_curr_title: "Comunic",
|
||||
|
||||
/**
|
||||
* Current number of notifications
|
||||
*/
|
||||
_curr_notifications_number: 0,
|
||||
|
||||
/**
|
||||
* Set a new title to the page
|
||||
*
|
||||
* @param {string} title The new title for the page
|
||||
*/
|
||||
setTitle: function(title){
|
||||
this._curr_title = title;
|
||||
this.__refresh();
|
||||
},
|
||||
|
||||
/**
|
||||
* Set new number of notifications
|
||||
*
|
||||
* @param {number} number The new number of notifications
|
||||
*/
|
||||
setNotificationsNumber: function(number){
|
||||
this._curr_notifications_number = number;
|
||||
this.__refresh();
|
||||
},
|
||||
|
||||
/**
|
||||
* Refresh document title
|
||||
*/
|
||||
__refresh: function(){
|
||||
let title = "";
|
||||
|
||||
if(this._curr_notifications_number > 0)
|
||||
title += "(" + this._curr_notifications_number + ") ";
|
||||
|
||||
title += this._curr_title;
|
||||
|
||||
document.title = title;
|
||||
}
|
||||
|
||||
}
|
@ -22,8 +22,11 @@ ComunicWeb.components.notifications.service = {
|
||||
var interval = setInterval(function(){
|
||||
|
||||
//Auto-remove interval if the target has been removed
|
||||
if(!target.isConnected)
|
||||
if(!target.isConnected){
|
||||
ComunicWeb.common.pageTitle.setNotificationsNumber(0);
|
||||
return clearInterval(interval);
|
||||
}
|
||||
|
||||
|
||||
//Get the number of notifications from the API
|
||||
ComunicWeb.components.notifications.interface.getAllUnread(function(response){
|
||||
@ -55,6 +58,8 @@ ComunicWeb.components.notifications.service = {
|
||||
|
||||
}
|
||||
|
||||
//Update page title too
|
||||
ComunicWeb.common.pageTitle.setNotificationsNumber(response.notifications + response.conversations);
|
||||
});
|
||||
|
||||
}, 2000);
|
||||
|
@ -14,7 +14,7 @@ ComunicWeb.pages.groups.pages.create = {
|
||||
open: function(target){
|
||||
|
||||
//Update page title
|
||||
document.title = "Create a group";
|
||||
ComunicWeb.common.pageTitle.setTitle("Create a group");
|
||||
|
||||
//Create page container
|
||||
var pageContainer = createElem2({
|
||||
|
@ -62,7 +62,7 @@ ComunicWeb.pages.groups.pages.forbidden = {
|
||||
display: function(id, result, target){
|
||||
|
||||
//Update page title
|
||||
document.title = result.name;
|
||||
ComunicWeb.common.pageTitle.setTitle(result.name);
|
||||
|
||||
//Create a box to contain information about registration
|
||||
var box = createElem2({
|
||||
|
@ -49,7 +49,7 @@ ComunicWeb.pages.groups.pages.group = {
|
||||
display: function(id, info, target){
|
||||
|
||||
//Update page title
|
||||
document.title = info.name;
|
||||
ComunicWeb.common.pageTitle.setTitle(info.name);
|
||||
|
||||
//Create page row
|
||||
var pageRow = createElem2({
|
||||
|
@ -61,7 +61,7 @@ ComunicWeb.pages.groups.pages.members = {
|
||||
*/
|
||||
applyGroupInfo: function(id, info, target){
|
||||
|
||||
document.title = info.name + " - Members";
|
||||
ComunicWeb.common.pageTitle.setTitle(info.name + " - Members");
|
||||
|
||||
//Append the title of the group
|
||||
createElem2({
|
||||
|
@ -92,7 +92,7 @@ ComunicWeb.pages.groups.pages.settings = {
|
||||
*/
|
||||
display: function(id, settings, target){
|
||||
|
||||
document.title = settings.name + " - Settings";
|
||||
ComunicWeb.common.pageTitle.setTitle(settings.name + " - Settings");
|
||||
|
||||
//Create form container
|
||||
var formContainer = createElem2({
|
||||
|
@ -14,7 +14,7 @@ ComunicWeb.pages.home.landingPage = {
|
||||
ComunicWeb.debug.logMessage("Open home landing page.");
|
||||
|
||||
//Change page title
|
||||
document.title = "Comunic, a transparent social network";
|
||||
ComunicWeb.common.pageTitle.setTitle("Comunic, a transparent social network");
|
||||
|
||||
//Prepare additional data
|
||||
var additionalData = {
|
||||
|
@ -20,6 +20,9 @@ ComunicWeb.pages.logout = {
|
||||
//Perform logout
|
||||
ComunicWeb.user.userLogin.logoutUser();
|
||||
|
||||
//Reset notifications number
|
||||
ComunicWeb.common.pageTitle.setNotificationsNumber(0);
|
||||
|
||||
//Clean all caches
|
||||
ComunicWeb.common.system.reset(true, "home");
|
||||
|
||||
|
@ -52,7 +52,7 @@ ComunicWeb.pages.settings.main = {
|
||||
var section = ComunicWeb.pages.settings.sectionsList[section];
|
||||
|
||||
//Update document title
|
||||
document.title += " - " + section.title;
|
||||
ComunicWeb.common.pageTitle.setTitle("Settings - " + section.title);
|
||||
|
||||
//Call handler
|
||||
eval(section.handler + "(args, rightArea);");
|
||||
|
@ -72,7 +72,7 @@ ComunicWeb.pages.userPage.accessForbidden = {
|
||||
showBasicInfos: function(userInfos, target){
|
||||
|
||||
//Update page title
|
||||
document.title = userInfos.firstName + " " + userInfos.lastName;
|
||||
ComunicWeb.common.pageTitle.setTitle(userInfos.firstName + " " + userInfos.lastName);
|
||||
|
||||
//Create box root
|
||||
var boxRoot = createElem2({
|
||||
|
@ -121,7 +121,7 @@ ComunicWeb.pages.userPage.main = {
|
||||
displayUserPage: function(infos, params, target){
|
||||
|
||||
//Update page title
|
||||
document.title = infos.firstName + " " + infos.lastName;
|
||||
ComunicWeb.common.pageTitle.setTitle(infos.firstName + " " + infos.lastName);
|
||||
|
||||
//Create the section class content
|
||||
var sectionContent = createElem2({
|
||||
|
@ -288,6 +288,7 @@ class Dev {
|
||||
"js/common/jsFiles.js",
|
||||
"js/common/debug.js",
|
||||
"js/common/page.js",
|
||||
"js/common/pageTitle.js",
|
||||
"js/common/notifications.js",
|
||||
"js/common/formChecker.js",
|
||||
"js/common/date.js",
|
||||
|
Loading…
Reference in New Issue
Block a user