Created specific js file for conversations dropdown

This commit is contained in:
Pierre 2018-02-24 14:03:20 +01:00
parent afd92d4e06
commit c584197b38
4 changed files with 107 additions and 90 deletions

View File

@ -608,6 +608,13 @@ var ComunicWeb = {
*/ */
utils:{ utils:{
//TODO : implement //TODO : implement
},
/**
* Unread conversations list dropdown
*/
unreadDropdown: {
//TODO : implementd
} }
}, },

View File

@ -0,0 +1,97 @@
/**
* List of unread conversations dropdown
*
* @author Pierre HUERT
*/
ComunicWeb.components.conversations.unreadDropdown = {
/**
* Display unread conversations dropdown
*
* @param {HTMLElement} target The target of the conversations dropdown
* @return {HTMLElement} The HTML element that contains the number of unread conversations
*/
display_dropdown: function(target){
//Create the button
var dropdown = createElem2({
appendTo: target,
type: "li",
class: "dropdown messages-menu"
});
//Add dropdown toggle
var dropdownToggle = createElem2({
appendTo: dropdown,
type: "a",
class: "dropdown-toggle",
href: "#",
innerHTML: '<i class="fa fa-comments-o"></i>'
});
dropdownToggle.setAttribute("data-toggle", "dropdown");
//Add conversations number
var conversationsNumber = createElem2({
appendTo: dropdownToggle,
type: "span",
class: "label label-danger",
innerHTML: "0"
});
//Add dropdown menu
var dropdownMenu = createElem2({
appendTo: dropdown,
type: "ul",
class: "dropdown-menu"
});
//Add dropdown header
var dropdownHeader = createElem2({
appendTo: dropdownMenu,
type: "li",
class: "header",
innerHTML: "Unread conversations"
});
//Add conversations list
var conversationsListContener = createElem2({
appendTo: dropdownMenu,
type: "li"
});
var conversationsList = createElem2({
appendTo: conversationsListContener,
type: "ul",
class: "menu"
});
//Add dropdown bottom
var dropdownBottom = createElem2({
appendTo: dropdownMenu,
type: "li",
class: "footer"
});
//Add a button to offer the user to delete all his conversations
var openConversations = createElem2({
appendTo: dropdownBottom,
type: "a",
href: "#",
innerHTML: " "
});
//Enable slimscroll
$(conversationsList).slimScroll({
height: '100%'
});
//Refresh the unread conversations list if the user click the dropdown button
dropdownToggle.onclick = function(){
ComunicWeb.components.conversations.dropdown.refresh_list_conversations(conversationsList);
}
//Return the number of conversations target
return conversationsNumber;
},
}

View File

@ -17,7 +17,7 @@ ComunicWeb.components.notifications.dropdown = {
var notifs_number_elem = this.display_notifications_dropdown(target); var notifs_number_elem = this.display_notifications_dropdown(target);
//Display the number of unread conversations //Display the number of unread conversations
var conversations_number_elem = this.display_conversations_dropdown(target); var conversations_number_elem = ComunicWeb.components.conversations.unreadDropdown.display_dropdown(target);
//Initialize service //Initialize service
ComunicWeb.components.notifications.service.init(notifs_number_elem, true, conversations_number_elem); ComunicWeb.components.notifications.service.init(notifs_number_elem, true, conversations_number_elem);
@ -191,93 +191,5 @@ ComunicWeb.components.notifications.dropdown = {
}); });
},
/**
* Display unread conversations dropdown
*
* @param {HTMLElement} target The target of the conversations dropdown
* @return {HTMLElement} The HTML element that contains the number of unread conversations
*/
display_conversations_dropdown: function(target){
//Create the button
var dropdown = createElem2({
appendTo: target,
type: "li",
class: "dropdown messages-menu"
});
//Add dropdown toggle
var dropdownToggle = createElem2({
appendTo: dropdown,
type: "a",
class: "dropdown-toggle",
href: "#",
innerHTML: '<i class="fa fa-comments-o"></i>'
});
dropdownToggle.setAttribute("data-toggle", "dropdown");
//Add conversations number
var conversationsNumber = createElem2({
appendTo: dropdownToggle,
type: "span",
class: "label label-danger",
innerHTML: "0"
});
//Add dropdown menu
var dropdownMenu = createElem2({
appendTo: dropdown,
type: "ul",
class: "dropdown-menu"
});
//Add dropdown header
var dropdownHeader = createElem2({
appendTo: dropdownMenu,
type: "li",
class: "header",
innerHTML: "Unread conversations"
});
//Add conversations list
var conversationsListContener = createElem2({
appendTo: dropdownMenu,
type: "li"
});
var conversationsList = createElem2({
appendTo: conversationsListContener,
type: "ul",
class: "menu"
});
//Add dropdown bottom
var dropdownBottom = createElem2({
appendTo: dropdownMenu,
type: "li",
class: "footer"
});
//Add a button to offer the user to delete all his conversations
var openConversations = createElem2({
appendTo: dropdownBottom,
type: "a",
href: "#",
innerHTML: " "
});
//Enable slimscroll
$(conversationsList).slimScroll({
height: '100%'
});
//Refresh the unread conversations list if the user click the dropdown button
dropdownToggle.onclick = function(){
ComunicWeb.components.conversations.dropdown.refresh_list_conversations(conversationsList);
} }
//Return the number of conversations target
return conversationsNumber;
},
} }

View File

@ -222,6 +222,7 @@ class Dev {
"js/components/conversations/service.js", "js/components/conversations/service.js",
"js/components/conversations/cachingOpened.js", "js/components/conversations/cachingOpened.js",
"js/components/conversations/utils.js", "js/components/conversations/utils.js",
"js/components/conversations/unreadDropdown.js",
//User selector //User selector
"js/components/userSelect/userSelect.js", "js/components/userSelect/userSelect.js",