mirror of
https://github.com/pierre42100/ComunicWeb
synced 2025-06-19 12:25:16 +00:00
Display the number of notifications on page title.
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user