mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-21 19:59:21 +00:00
Show banners
This commit is contained in:
parent
ebf6cf2fc3
commit
1cb1ec2b3f
41
assets/css/components/menuBar/banner.css
Normal file
41
assets/css/components/menuBar/banner.css
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/**
|
||||||
|
* Global banner
|
||||||
|
*
|
||||||
|
* @author Pierre Hubert
|
||||||
|
*/
|
||||||
|
|
||||||
|
.banner {
|
||||||
|
padding: 1px 15px;
|
||||||
|
text-align: left;
|
||||||
|
min-height: unset !important;
|
||||||
|
margin-bottom: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.banner button {
|
||||||
|
right: unset !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.banner a {
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content-wrapper + .content-wrapper,
|
||||||
|
.content-wrapper + div + .content-wrapper,
|
||||||
|
.content-wrapper + div + div + .content-wrapper,
|
||||||
|
.content-wrapper + div + div + div + .content-wrapper {
|
||||||
|
padding-top: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 767px) {
|
||||||
|
.banner.content-wrapper {
|
||||||
|
margin-top: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content-wrapper + .content-wrapper,
|
||||||
|
.content-wrapper + div + .content-wrapper,
|
||||||
|
.content-wrapper + div + div + .content-wrapper,
|
||||||
|
.content-wrapper + div + div + div + .content-wrapper {
|
||||||
|
margin-top: 0px !important;
|
||||||
|
padding-top: 2px !important;
|
||||||
|
}
|
||||||
|
}
|
@ -7,5 +7,5 @@
|
|||||||
.box-password-forgotten {
|
.box-password-forgotten {
|
||||||
max-width: 350px;
|
max-width: 350px;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
margin-top: 20px;
|
margin-top: 30px;
|
||||||
}
|
}
|
@ -121,4 +121,14 @@ ComunicWeb.common.langs = {
|
|||||||
|
|
||||||
return string;
|
return string;
|
||||||
},
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get current language
|
||||||
|
*
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
function currLang() {
|
||||||
|
return ComunicWeb.common.langs.current();
|
||||||
}
|
}
|
@ -252,7 +252,7 @@ const Page = {
|
|||||||
(document.body.className.includes("sidebar-collapse") ? " sidebar-collapse " : "");
|
(document.body.className.includes("sidebar-collapse") ? " sidebar-collapse " : "");
|
||||||
|
|
||||||
//We load the menubar
|
//We load the menubar
|
||||||
ComunicWeb.components.menuBar.common.display();
|
MenuBar.display();
|
||||||
|
|
||||||
//Bottom
|
//Bottom
|
||||||
ComunicWeb.components.bottom.main.display();
|
ComunicWeb.components.bottom.main.display();
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* @author Pierre HUBERT
|
* @author Pierre HUBERT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ComunicWeb.components.menuBar.authenticated = {
|
const AuthenticatedMenuBar = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dropdown menu links list
|
* Dropdown menu links list
|
||||||
@ -28,8 +28,8 @@ ComunicWeb.components.menuBar.authenticated = {
|
|||||||
//Dark theme
|
//Dark theme
|
||||||
{
|
{
|
||||||
innerLang: "menu_bar_action_dark_theme",
|
innerLang: "menu_bar_action_dark_theme",
|
||||||
onclick: function(b){ComunicWeb.components.menuBar.authenticated.darkThemeButtonClicked(true, b)},
|
onclick: function(b){AuthenticatedMenuBar.darkThemeButtonClicked(true, b)},
|
||||||
oninit: function(b){ComunicWeb.components.menuBar.authenticated.darkThemeButtonClicked(false, b)},
|
oninit: function(b){AuthenticatedMenuBar.darkThemeButtonClicked(false, b)},
|
||||||
icon: "fa-sun-o"
|
icon: "fa-sun-o"
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ ComunicWeb.components.menuBar.authenticated = {
|
|||||||
*/
|
*/
|
||||||
addElements: function(container){
|
addElements: function(container){
|
||||||
|
|
||||||
// Site logo
|
// Site name
|
||||||
createElem2({
|
createElem2({
|
||||||
appendTo: container,
|
appendTo: container,
|
||||||
type: "a",
|
type: "a",
|
||||||
@ -112,6 +112,13 @@ ComunicWeb.components.menuBar.authenticated = {
|
|||||||
|
|
||||||
//Add dropdown menu
|
//Add dropdown menu
|
||||||
this.addDropdown(navbarRightElemList);
|
this.addDropdown(navbarRightElemList);
|
||||||
|
|
||||||
|
// Banner
|
||||||
|
const banner = MenubarBanner.addBanner(undefined)
|
||||||
|
if(banner) {
|
||||||
|
container.parentNode.insertBefore(banner, container.nextElementSibling)
|
||||||
|
banner.classList.add("content-wrapper")
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
71
assets/js/components/menuBar/banner.js
Normal file
71
assets/js/components/menuBar/banner.js
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
/**
|
||||||
|
* Menu bar banner
|
||||||
|
*
|
||||||
|
* @author Pierre Hubert
|
||||||
|
*/
|
||||||
|
|
||||||
|
let hasClosedBanner = false;
|
||||||
|
|
||||||
|
const MenubarBanner = {
|
||||||
|
/**
|
||||||
|
* Add menubar banner if required
|
||||||
|
*
|
||||||
|
* @param {HTMLElement} target Target element
|
||||||
|
* @returns {HTMLElement} The banner (if it was created)
|
||||||
|
*/
|
||||||
|
addBanner: function(target) {
|
||||||
|
if(hasClosedBanner ||
|
||||||
|
!ServerConfig.conf.banner ||
|
||||||
|
!ServerConfig.conf.banner.enabled &&
|
||||||
|
ServerConfig.conf.banner.expire < ComunicDate.time())
|
||||||
|
return;
|
||||||
|
|
||||||
|
const banner = ServerConfig.conf.banner;
|
||||||
|
|
||||||
|
const rootEl = createElem2({
|
||||||
|
appendTo: target,
|
||||||
|
type: "div",
|
||||||
|
class: "banner alert alert-dismissible alert-" +(banner.nature == "information" ? "info" : (banner.nature == "success" ? "success" : "danger"))
|
||||||
|
})
|
||||||
|
|
||||||
|
// Close button
|
||||||
|
createElem2({
|
||||||
|
appendTo: rootEl,
|
||||||
|
type: "button",
|
||||||
|
class: "close",
|
||||||
|
elemType: "button",
|
||||||
|
innerHTML: "x",
|
||||||
|
onclick: () => {
|
||||||
|
rootEl.remove();
|
||||||
|
hasClosedBanner = true;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// icon
|
||||||
|
createElem2({
|
||||||
|
appendTo: rootEl,
|
||||||
|
type: "i",
|
||||||
|
class: "icon fa "+(banner.nature == "information" ? "fa-info" : (banner.nature == "success" ? "fa-check" : "fa-warning"))
|
||||||
|
})
|
||||||
|
|
||||||
|
// message
|
||||||
|
createElem2({
|
||||||
|
appendTo: rootEl,
|
||||||
|
type: "span",
|
||||||
|
innerHTML: banner.message.hasOwnProperty(currLang()) ? banner.message[currLang()] : banner.message["en"]
|
||||||
|
})
|
||||||
|
|
||||||
|
// link
|
||||||
|
if (banner.link) {
|
||||||
|
const link = createElem2({
|
||||||
|
appendTo: rootEl,
|
||||||
|
type: "a",
|
||||||
|
href: banner.link,
|
||||||
|
innerHTML: tr("Learn more")
|
||||||
|
})
|
||||||
|
link.target = "_blank";
|
||||||
|
}
|
||||||
|
|
||||||
|
return rootEl;
|
||||||
|
}
|
||||||
|
};
|
@ -4,7 +4,7 @@
|
|||||||
* @author Pierre HUBERT
|
* @author Pierre HUBERT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ComunicWeb.components.menuBar.common = {
|
const MenuBar = {
|
||||||
/**
|
/**
|
||||||
* Display menu bar
|
* Display menu bar
|
||||||
*
|
*
|
||||||
@ -61,11 +61,11 @@ ComunicWeb.components.menuBar.common = {
|
|||||||
//Call specific menu
|
//Call specific menu
|
||||||
if(signed_in()){
|
if(signed_in()){
|
||||||
//Call authenticated menubar
|
//Call authenticated menubar
|
||||||
ComunicWeb.components.menuBar.authenticated.addElements(menuContainer);
|
AuthenticatedMenuBar.addElements(menuContainer);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//Call not-logged-in menubar
|
//Call not-logged-in menubar
|
||||||
ComunicWeb.components.menuBar.notAuthenticated.addElements(menuContainer);
|
NotAuthenticatedMenuBar.addElements(menuContainer);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* @author Pierre HUBERT
|
* @author Pierre HUBERT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ComunicWeb.components.menuBar.notAuthenticated = {
|
const NotAuthenticatedMenuBar = {
|
||||||
/**
|
/**
|
||||||
* Add not-authenticated user specific elements
|
* Add not-authenticated user specific elements
|
||||||
*
|
*
|
||||||
@ -124,5 +124,7 @@ ComunicWeb.components.menuBar.notAuthenticated = {
|
|||||||
//Block form
|
//Block form
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MenubarBanner.addBanner(menuHeader)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -78,6 +78,9 @@ ComunicWeb.pages.login = {
|
|||||||
//Check if we have to display a login failed message
|
//Check if we have to display a login failed message
|
||||||
if(additionnalData.loginFailedMessage)
|
if(additionnalData.loginFailedMessage)
|
||||||
ComunicWeb.pages.login.displayLoginError();
|
ComunicWeb.pages.login.displayLoginError();
|
||||||
|
|
||||||
|
// Add menu banner
|
||||||
|
MenubarBanner.addBanner(byId("login_banner"))
|
||||||
};
|
};
|
||||||
|
|
||||||
//Apply template
|
//Apply template
|
||||||
|
9
assets/js/typings/ServerConfig.d.ts
vendored
9
assets/js/typings/ServerConfig.d.ts
vendored
@ -41,6 +41,14 @@ declare interface AccountInformationPolicy {
|
|||||||
max_location_length: number,
|
max_location_length: number,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare interface Banner {
|
||||||
|
enabled: boolean,
|
||||||
|
expire ?: number,
|
||||||
|
nature: "information"|"warning"|"success",
|
||||||
|
message: Map<string, string>,
|
||||||
|
link ?: string,
|
||||||
|
}
|
||||||
|
|
||||||
declare interface StaticServerConfig {
|
declare interface StaticServerConfig {
|
||||||
terms_url: string,
|
terms_url: string,
|
||||||
privacy_policy_url: string,
|
privacy_policy_url: string,
|
||||||
@ -50,4 +58,5 @@ declare interface StaticServerConfig {
|
|||||||
data_conservation_policy: DataConservationPolicySettings,
|
data_conservation_policy: DataConservationPolicySettings,
|
||||||
conversations_policy: ConversationPolicy,
|
conversations_policy: ConversationPolicy,
|
||||||
account_info_policy: AccountInformationPolicy,
|
account_info_policy: AccountInformationPolicy,
|
||||||
|
banner?: Banner,
|
||||||
}
|
}
|
@ -5,6 +5,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="login-box-body">
|
<div class="login-box-body">
|
||||||
|
|
||||||
|
<!-- Global banner -->
|
||||||
|
<div id="login_banner"></div>
|
||||||
|
|
||||||
<!-- Login message -->
|
<!-- Login message -->
|
||||||
<p class="login-box-msg">{login_top_msg}</p>
|
<p class="login-box-msg">{login_top_msg}</p>
|
||||||
|
|
||||||
|
@ -197,7 +197,8 @@ class Dev {
|
|||||||
|
|
||||||
//Components stylesheets
|
//Components stylesheets
|
||||||
//Menubar stylesheet
|
//Menubar stylesheet
|
||||||
"css/components/menuBar.css",
|
"css/components/menuBar/base.css",
|
||||||
|
"css/components/menuBar/banner.css",
|
||||||
|
|
||||||
//Language picker stylesheet
|
//Language picker stylesheet
|
||||||
"css/components/languagePicker.css",
|
"css/components/languagePicker.css",
|
||||||
@ -387,6 +388,7 @@ class Dev {
|
|||||||
"js/components/menuBar/common.js",
|
"js/components/menuBar/common.js",
|
||||||
"js/components/menuBar/notAuthenticated.js",
|
"js/components/menuBar/notAuthenticated.js",
|
||||||
"js/components/menuBar/authenticated.js",
|
"js/components/menuBar/authenticated.js",
|
||||||
|
"js/components/menuBar/banner.js",
|
||||||
|
|
||||||
// Main side bar
|
// Main side bar
|
||||||
"js/components/sidebar/main.js",
|
"js/components/sidebar/main.js",
|
||||||
|
Loading…
Reference in New Issue
Block a user