diff --git a/assets/css/pages/conversations/listPane.css b/assets/css/pages/conversations/listPane.css index ef638417..56b0a691 100644 --- a/assets/css/pages/conversations/listPane.css +++ b/assets/css/pages/conversations/listPane.css @@ -8,6 +8,10 @@ max-height: 100%; } +.conversations-page-container .conversations-list-box ul { + max-height: 100%; +} + .conversations-page-container a.selected { background: #f7f7f7; } \ No newline at end of file diff --git a/assets/js/common/functionsSchema.js b/assets/js/common/functionsSchema.js index 9d57d95c..c8f91fcf 100644 --- a/assets/js/common/functionsSchema.js +++ b/assets/js/common/functionsSchema.js @@ -1156,7 +1156,15 @@ var ComunicWeb = { */ conversation: { //TODO : implement - } + }, + + + /** + * Conversation page utilities + */ + utils: { + //TODO : implement + }, }, /** diff --git a/assets/js/pages/conversations/conversation.js b/assets/js/pages/conversations/conversation.js index 91d53398..e84bd0c2 100644 --- a/assets/js/pages/conversations/conversation.js +++ b/assets/js/pages/conversations/conversation.js @@ -330,9 +330,7 @@ ComunicWeb.pages.conversations.conversation = { //Enable / update slimscroll var target = ComunicWeb.pages.conversations.conversation._conv_info.window.messagesTarget; var scrollBottom = $(target).prop("scrollHeight")+"px"; - $(target).slimScroll({ - scrollTo: scrollBottom - }); + ComunicWeb.pages.conversations.utils.enableSlimScroll(target, ComunicWeb.pages.conversations.utils.getAvailableHeight(), scrollBottom); }, 100); } @@ -577,11 +575,12 @@ ComunicWeb.pages.conversations.conversation = { newScrollPos = oldestMessage.offsetTop - 30; if(newScrollPos < 0) newScrollPos = 0; - $(convInfo.window.messagesTarget).slimScroll({ - scrollTo: newScrollPos + "px" - }); + ComunicWeb.pages.conversations.utils.enableSlimScroll( + convInfo.window.messagesTarget, + ComunicWeb.pages.conversations.utils.getAvailableHeight(), + newScrollPos); }); }); - } + }, }; \ No newline at end of file diff --git a/assets/js/pages/conversations/listPane.js b/assets/js/pages/conversations/listPane.js index 0f9b26ee..73076562 100644 --- a/assets/js/pages/conversations/listPane.js +++ b/assets/js/pages/conversations/listPane.js @@ -145,19 +145,24 @@ ComunicWeb.pages.conversations.listPane = { } //Enable slimscroll - $(conversationsContainer).slimScroll({ - height: '100%' - }); + ComunicWeb.pages.conversations.utils.enableSlimScroll( + conversationsContainer, + ComunicWeb.pages.conversations.utils.getAvailableHeight(), + 0); //Scroll to selected conversation, if possible if(args.selected_conversation != null){ var newScrollPos = args.selected_conversation.offsetTop - 30; if(newScrollPos < 0) newScrollPos = 0; - $(conversationsContainer).slimScroll({ - scrollTo: newScrollPos + "px" - }); + + //Enable slimscroll again + ComunicWeb.pages.conversations.utils.enableSlimScroll( + conversationsContainer, + ComunicWeb.pages.conversations.utils.getAvailableHeight() + 55, + newScrollPos); } + }, /** diff --git a/assets/js/pages/conversations/utils.js b/assets/js/pages/conversations/utils.js new file mode 100644 index 00000000..5bababc4 --- /dev/null +++ b/assets/js/pages/conversations/utils.js @@ -0,0 +1,33 @@ +/** + * Conversation page utilities + * + * @author Pierre HUBERT + */ + +ComunicWeb.pages.conversations.utils = { + + /** + * Enable slimscroll for the conversation element + * + * @param {HMTLElement} target The target for slimscroll + * @param {Number} height The available height for the element + * @param {Number} pos Scroll position to go to + */ + enableSlimScroll: function(target, height, pos){ + + $(target).slimScroll({ + scrollTo: pos + "px", + height: height + "px", + }); + }, + + /** + * Get the available height for the conversations + * + * @return {Number} The available height, in pixel + */ + getAvailableHeight: function(){ + return Number(byId("pageTarget").style.minHeight.replace("px", "")) - 180; + } + +} \ No newline at end of file diff --git a/system/config/dev.config.php b/system/config/dev.config.php index 71c6c284..c6b2cbd2 100644 --- a/system/config/dev.config.php +++ b/system/config/dev.config.php @@ -387,6 +387,7 @@ class Dev { "js/pages/conversations/main.js", "js/pages/conversations/listPane.js", "js/pages/conversations/conversation.js", + "js/pages/conversations/utils.js", //User settings page "js/pages/settings/main.js",