From cf4ff4675d8deb19684b4bf55a340d943459f2b4 Mon Sep 17 00:00:00 2001 From: Pierre Date: Thu, 25 May 2017 13:50:32 +0200 Subject: [PATCH] Created dropdown menu for authenticated users --- assets/js/common/functionsSchema.js | 13 ++++- assets/js/common/shorcuts.js | 5 ++ assets/js/components/menuBar/authenticated.js | 56 +++++++++++++++++++ assets/js/components/menuBar/common.js | 5 +- corePage/config/dev.config.php | 1 + 5 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 assets/js/common/shorcuts.js create mode 100644 assets/js/components/menuBar/authenticated.js diff --git a/assets/js/common/functionsSchema.js b/assets/js/common/functionsSchema.js index 3124e667..45192e5e 100644 --- a/assets/js/common/functionsSchema.js +++ b/assets/js/common/functionsSchema.js @@ -3,6 +3,10 @@ * * @author Pierre HUBERT */ + +/** + * ComunicWeb main object + */ var ComunicWeb = { /** @@ -336,7 +340,14 @@ var ComunicWeb = { */ notAuthenticated: { //TODO : implement - } + }, + + /** + * Menubar for authenticated users complements + */ + authenticated:{ + //TODO : implement + }, }, /** diff --git a/assets/js/common/shorcuts.js b/assets/js/common/shorcuts.js new file mode 100644 index 00000000..f64996d8 --- /dev/null +++ b/assets/js/common/shorcuts.js @@ -0,0 +1,5 @@ +/** + * This file contains shorcuts to ease access of common functions + * + * @author Pierre HUBERT + */ diff --git a/assets/js/components/menuBar/authenticated.js b/assets/js/components/menuBar/authenticated.js new file mode 100644 index 00000000..56be577e --- /dev/null +++ b/assets/js/components/menuBar/authenticated.js @@ -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 + } +}; \ No newline at end of file diff --git a/assets/js/components/menuBar/common.js b/assets/js/components/menuBar/common.js index 9a129b95..9669db24 100644 --- a/assets/js/components/menuBar/common.js +++ b/assets/js/components/menuBar/common.js @@ -99,10 +99,11 @@ ComunicWeb.components.menuBar.common = { //Call specific menu if(userLoggedIn){ - //Not implemented yet + //Call authenticated menubar + ComunicWeb.components.menuBar.authenticated.addElements(containerElem); } else{ - //Call not-logged-in menu + //Call not-logged-in menubar ComunicWeb.components.menuBar.notAuthenticated.addElements(containerElem); } }, diff --git a/corePage/config/dev.config.php b/corePage/config/dev.config.php index d7ae054c..262a07d4 100644 --- a/corePage/config/dev.config.php +++ b/corePage/config/dev.config.php @@ -61,6 +61,7 @@ $config['JSfiles'] = array( "%PATH_ASSETS%js/components/mailCaching.js", "%PATH_ASSETS%js/components/menuBar/common.js", "%PATH_ASSETS%js/components/menuBar/notAuthenticated.js", + "%PATH_ASSETS%js/components/menuBar/authenticated.js", //User scripts "%PATH_ASSETS%js/user/loginTokens.js",