Begin to draw side bar (add user logo)

This commit is contained in:
Pierre HUBERT 2019-05-11 16:43:55 +02:00
parent b436c1aabd
commit 356d70651b
8 changed files with 111 additions and 1 deletions

View File

@ -7,7 +7,7 @@
/** /**
* <a> elements * <a> elements
*/ */
a { a, .cursor-pointer {
cursor: pointer; cursor: pointer;
} }

View File

@ -5,6 +5,7 @@
*/ */
#incognito-block { #incognito-block {
z-index: 900;
position: fixed; position: fixed;
left: 10px; left: 10px;
bottom: 54px; bottom: 54px;

View File

@ -587,6 +587,19 @@ var ComunicWeb = {
}, },
}, },
/**
* Sidebar
*/
sideBar: {
/**
* Main sidebar file
*/
main: {
//TODO : implement
}
},
/** /**
* Pages bottom * Pages bottom
*/ */

View File

@ -258,6 +258,9 @@ ComunicWeb.common.page = {
//We load specific components for logged in users //We load specific components for logged in users
if(ComunicWeb.user.userLogin.getUserLoginState()){ if(ComunicWeb.user.userLogin.getUserLoginState()){
// Sidebar
ComunicWeb.components.sideBar.main.show();
//We load friends list (if user is logged in) //We load friends list (if user is logged in)
ComunicWeb.components.friends.bar.display(); ComunicWeb.components.friends.bar.display();

View File

@ -120,6 +120,18 @@ function getMultipleUsersInfos(usersID, afterGetUserInfos, forceRequest){
ComunicWeb.user.userInfos.getMultipleUsersInfos(usersID, afterGetUserInfos, forceRequest); ComunicWeb.user.userInfos.getMultipleUsersInfos(usersID, afterGetUserInfos, forceRequest);
} }
/**
* Get information about a single user
*
* @param {int} userID User on which to make request
* @param {function} afterGetUserInfo What to do once users informations are available
* @param {Boolean} forceRequest Force the request to be made
* @return {Boolean} True for a success
*/
function getUserInfo(usersID, afterGetUserInfo, forceRequest){
ComunicWeb.user.userInfos.getUserInfos(usersID, afterGetUserInfo, forceRequest);
}
/** /**
* Display message on browser console * Display message on browser console
* *

View File

@ -43,6 +43,7 @@ function createElem(nodeType, appendTo){
* @info {String} innerLang Specify the key of the lang to use to fill the element * @info {String} innerLang Specify the key of the lang to use to fill the element
* @info {String} innerHTMLprefix Specify prefix to add at the begining of the content of the element * @info {String} innerHTMLprefix Specify prefix to add at the begining of the content of the element
* @info {boolean} disabled Set whether the field should be disabled or not (input only) * @info {boolean} disabled Set whether the field should be disabled or not (input only)
* @info {HTMLElement[]} children Children for the new object
* @return {HTMLElement} The newly created element * @return {HTMLElement} The newly created element
*/ */
function createElem2(infos){ function createElem2(infos){
@ -122,6 +123,12 @@ function createElem2(infos){
if(infos.disabled) if(infos.disabled)
infos.disabled = true; infos.disabled = true;
if(infos.children){
infos.children.forEach(function(i){
newElem.appendChild(i);
});
}
//Return newly created element //Return newly created element
return newElem; return newElem;
} }

View File

@ -0,0 +1,71 @@
/**
* Sidebar main script file
*
* @author Pierre HUBERT
*/
ComunicWeb.components.sideBar.main = {
show: function() {
if(byId("main-sidebar")) return;
var sideBar = createElem2({
appendTo: byId("wrapper"),
type: "aside",
class: "main-sidebar"
});
var section = createElem2({
appendTo: sideBar,
type: "section",
class: "sidebar"
});
// User panel
var userPanel = createElem2({
appendTo: section,
type: "div",
class: "user-panel"
});
getUserInfo(userID(), function(info){
if(info.error)
return userPanel.innerHTML = "Error!";
// User account image
createElem2({
appendTo: userPanel,
type: "div",
class: "pull-left image cursor-pointer",
internalHref: userIDorPath(info),
children: [
createElem2({
type: "img",
class: "img-circle",
src: info.accountImage
})
],
});
// User name
createElem2({
appendTo: userPanel,
type: "div",
class: "pull-left info",
children: [
createElem2({
type: "p",
class: "cursor-pointer",
innerHTML: userFullName(info),
internalHref: userIDorPath(info),
}),
createElem2({
type: "a",
innerHTML: "Settings",
internalHref: "settings",
}),
]
});
});
}
}

View File

@ -353,6 +353,9 @@ class Dev {
"js/components/menuBar/notAuthenticated.js", "js/components/menuBar/notAuthenticated.js",
"js/components/menuBar/authenticated.js", "js/components/menuBar/authenticated.js",
// Main side bar
"js/components/sidebar/main.js",
//Bottom view //Bottom view
"js/components/bottom/links.js", "js/components/bottom/links.js",
"js/components/bottom/main.js", "js/components/bottom/main.js",