2017-05-25 11:50:32 +00:00
|
|
|
/**
|
|
|
|
* Menubar for authenticated users complements
|
|
|
|
*
|
|
|
|
* @author Pierre HUBERT
|
|
|
|
*/
|
|
|
|
|
|
|
|
ComunicWeb.components.menuBar.authenticated = {
|
|
|
|
/**
|
|
|
|
* Add authenticated user specific elements
|
|
|
|
*
|
|
|
|
* @param {HTMLElement} container The container element of the Menubar
|
|
|
|
*/
|
|
|
|
addElements: function(container){
|
|
|
|
//Create an auto-collapsed element
|
|
|
|
var navbarCollapse = createElem("div", container);
|
|
|
|
navbarCollapse.id = "navbar-collapse";
|
|
|
|
navbarCollapse.className = "navbar-collapse pull-right collapse";
|
|
|
|
|
|
|
|
//Create navbar elements list
|
|
|
|
var navbarElemList = createElem("ul", navbarCollapse);
|
|
|
|
navbarElemList.className = "nav navbar-nav";
|
|
|
|
|
2017-05-25 13:06:01 +00:00
|
|
|
//Add user name
|
|
|
|
this.addUserName(navbarElemList);
|
|
|
|
|
2017-05-25 11:50:32 +00:00
|
|
|
//Add dropdown menu
|
|
|
|
this.addDropdown(navbarElemList);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add dropdown menu
|
|
|
|
*
|
|
|
|
* @param {HTMLElement} navbarElem The target navbarlist element
|
2017-05-25 13:06:01 +00:00
|
|
|
* @return {HTMLElement} The dropdown content element
|
2017-05-25 11:50:32 +00:00
|
|
|
*/
|
|
|
|
addDropdown: function(navbarElem){
|
|
|
|
//Create dropdown menu
|
|
|
|
var dropdown = createElem("li", navbarElem);
|
|
|
|
dropdown.className = "dropdown";
|
|
|
|
|
|
|
|
//Add dropdown button
|
|
|
|
var dropdownButton = createElem("a", dropdown);
|
|
|
|
dropdownButton.className = "dropdown-toggle";
|
|
|
|
dropdownButton.setAttribute("data-toggle", "dropdown");
|
2017-05-25 12:06:37 +00:00
|
|
|
|
|
|
|
//Add dropdown button icon
|
|
|
|
var dropdownButtonIcon = createElem("i", dropdownButton);
|
|
|
|
dropdownButtonIcon.className = "fa fa-gear";
|
|
|
|
|
2017-05-25 13:06:01 +00:00
|
|
|
//Add space
|
2017-05-25 12:06:37 +00:00
|
|
|
dropdownButton.innerHTML += " ";
|
|
|
|
|
|
|
|
//Add dropdown button arrow
|
|
|
|
var dropdownButtonArrow = createElem("span", dropdownButton);
|
|
|
|
dropdownButtonArrow.className = "caret";
|
2017-05-25 11:50:32 +00:00
|
|
|
|
|
|
|
//Create dropdown menu content
|
|
|
|
var dropdownContent = createElem("ul", dropdown);
|
|
|
|
dropdownContent.className = "dropdown-menu"
|
|
|
|
dropdownContent.setAttribute("role", "menu");
|
|
|
|
|
|
|
|
//Add logout link
|
|
|
|
var logoutButton = createElem("li", dropdownContent);
|
|
|
|
var logoutButtonLink = createElem("a", logoutButton);
|
|
|
|
logoutButtonLink.innerHTML = "Logout";
|
2017-05-25 11:57:38 +00:00
|
|
|
logoutButton.onclick = function(){openPage("logout")};
|
2017-05-25 13:06:01 +00:00
|
|
|
|
|
|
|
//Return dropdown content element
|
|
|
|
return dropdownContent;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add user name element
|
|
|
|
*
|
|
|
|
* @param {HTMLElement} navbarElem The target navbarlist element
|
|
|
|
* @return {HTMLElement} The user element
|
|
|
|
*/
|
|
|
|
addUserName: function(navbarElem){
|
|
|
|
//Create user element
|
|
|
|
var userelement = createElem("li", navbarElem);
|
|
|
|
userelement.className = "user-menu";
|
|
|
|
|
|
|
|
//Add user link element
|
|
|
|
var userlinkelement = createElem("a", userelement);
|
|
|
|
|
|
|
|
//Add user image
|
|
|
|
var userimage = createElem("img", userlinkelement);
|
|
|
|
userimage.className = "user-image";
|
|
|
|
userimage.src = ComunicWeb.__config.assetsURL + "img/defaultAvatar.png";
|
|
|
|
|
|
|
|
//Add user name
|
|
|
|
var userNameElem = createElem("span", userlinkelement);
|
|
|
|
userNameElem.className = "hidden-xs";
|
|
|
|
userNameElem.innerHTML = "Loading...";
|
|
|
|
|
|
|
|
//Make a request to get informations about the user
|
|
|
|
|
|
|
|
},
|
2017-05-25 11:50:32 +00:00
|
|
|
};
|