Created dropdown menu for authenticated users

This commit is contained in:
Pierre 2017-05-25 13:50:32 +02:00
parent f80c2aca0e
commit cf4ff4675d
5 changed files with 77 additions and 3 deletions

View File

@ -3,6 +3,10 @@
* *
* @author Pierre HUBERT * @author Pierre HUBERT
*/ */
/**
* ComunicWeb main object
*/
var ComunicWeb = { var ComunicWeb = {
/** /**
@ -336,7 +340,14 @@ var ComunicWeb = {
*/ */
notAuthenticated: { notAuthenticated: {
//TODO : implement //TODO : implement
} },
/**
* Menubar for authenticated users complements
*/
authenticated:{
//TODO : implement
},
}, },
/** /**

View File

@ -0,0 +1,5 @@
/**
* This file contains shorcuts to ease access of common functions
*
* @author Pierre HUBERT
*/

View File

@ -0,0 +1,56 @@
/**
* 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";
//Add dropdown menu
this.addDropdown(navbarElemList);
},
/**
* Add dropdown menu
*
* @param {HTMLElement} navbarElem The target navbarlist element
* @return {Boolean} True for a success
*/
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");
dropdownButton.innerHTML = "Menu";
//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";
logoutButton.onclick
}
};

View File

@ -99,10 +99,11 @@ ComunicWeb.components.menuBar.common = {
//Call specific menu //Call specific menu
if(userLoggedIn){ if(userLoggedIn){
//Not implemented yet //Call authenticated menubar
ComunicWeb.components.menuBar.authenticated.addElements(containerElem);
} }
else{ else{
//Call not-logged-in menu //Call not-logged-in menubar
ComunicWeb.components.menuBar.notAuthenticated.addElements(containerElem); ComunicWeb.components.menuBar.notAuthenticated.addElements(containerElem);
} }
}, },

View File

@ -61,6 +61,7 @@ $config['JSfiles'] = array(
"%PATH_ASSETS%js/components/mailCaching.js", "%PATH_ASSETS%js/components/mailCaching.js",
"%PATH_ASSETS%js/components/menuBar/common.js", "%PATH_ASSETS%js/components/menuBar/common.js",
"%PATH_ASSETS%js/components/menuBar/notAuthenticated.js", "%PATH_ASSETS%js/components/menuBar/notAuthenticated.js",
"%PATH_ASSETS%js/components/menuBar/authenticated.js",
//User scripts //User scripts
"%PATH_ASSETS%js/user/loginTokens.js", "%PATH_ASSETS%js/user/loginTokens.js",