ComunicWeb/assets/js/components/notifications/dropdown.js

60 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-02-18 18:12:17 +00:00
/**
* Notifications menu bar dropdown
*
* @author Pierre HUBERT
*/
ComunicWeb.components.notifications.dropdown = {
/**
* Display notifications dropdown
*
* @param {HTMLElement} target The target of the notification dropdown
*/
display: function(target){
//Create the button
var dropdown = createElem2({
appendTo: target,
type: "li",
class: "dropdown notifications-menu"
});
//Add dropdown toggle
var dropdownToggle = createElem2({
appendTo: dropdown,
type: "a",
class: "dropdown-toggle",
href: "#",
innerHTML: '<i class="fa fa-bell-o"></i>'
});
2018-02-18 18:16:48 +00:00
dropdownToggle.setAttribute("data-toggle", "dropdown");
2018-02-18 18:12:17 +00:00
//Add notification number
var notificationsNumber = createElem2({
appendTo: dropdownToggle,
type: "span",
class: "label label-danger",
innerHTML: "0"
});
//Add dropdown menu
2018-02-18 18:16:48 +00:00
var dropdownMenu = createElem2({
appendTo: dropdown,
type: "ul",
class: "dropdown-menu"
});
//Add dropdown header
var dropdownHeader = createElem2({
appendTo: dropdownMenu,
type: "li",
class: "header",
innerHTML: "Notifications"
});
2018-02-18 18:12:17 +00:00
2018-02-19 08:39:00 +00:00
//Initialize service
ComunicWeb.components.notifications.service.init(notificationsNumber, true);
2018-02-18 18:12:17 +00:00
},
}