diff --git a/assets/js/common/functionsSchema.js b/assets/js/common/functionsSchema.js index e1f21977..fba0296d 100644 --- a/assets/js/common/functionsSchema.js +++ b/assets/js/common/functionsSchema.js @@ -608,6 +608,13 @@ var ComunicWeb = { */ utils:{ //TODO : implement + }, + + /** + * Unread conversations list dropdown + */ + unreadDropdown: { + //TODO : implementd } }, diff --git a/assets/js/components/conversations/unreadDropdown.js b/assets/js/components/conversations/unreadDropdown.js new file mode 100644 index 00000000..0135b760 --- /dev/null +++ b/assets/js/components/conversations/unreadDropdown.js @@ -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: '' + }); + 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; + }, + +} \ No newline at end of file diff --git a/assets/js/components/notifications/dropdown.js b/assets/js/components/notifications/dropdown.js index fb93db16..b3da84c9 100644 --- a/assets/js/components/notifications/dropdown.js +++ b/assets/js/components/notifications/dropdown.js @@ -17,7 +17,7 @@ ComunicWeb.components.notifications.dropdown = { var notifs_number_elem = this.display_notifications_dropdown(target); //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 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: '' - }); - 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; - }, + } } \ No newline at end of file diff --git a/system/config/dev.config.php b/system/config/dev.config.php index 3ac3b3db..2798017e 100644 --- a/system/config/dev.config.php +++ b/system/config/dev.config.php @@ -222,6 +222,7 @@ class Dev { "js/components/conversations/service.js", "js/components/conversations/cachingOpened.js", "js/components/conversations/utils.js", + "js/components/conversations/unreadDropdown.js", //User selector "js/components/userSelect/userSelect.js",