mirror of
				https://github.com/pierre42100/ComunicWeb
				synced 2025-11-03 19:54:14 +00:00 
			
		
		
		
	Update conversations page
This commit is contained in:
		@@ -6,6 +6,8 @@
 | 
			
		||||
 | 
			
		||||
.conversations-page-container .conversations-list-box {
 | 
			
		||||
	max-height: 100%;
 | 
			
		||||
	max-width: 300px;
 | 
			
		||||
	margin: auto;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.conversations-page-container .conversations-list-box ul {
 | 
			
		||||
 
 | 
			
		||||
@@ -15,9 +15,8 @@ ComunicWeb.pages.conversations.listPane = {
 | 
			
		||||
	 * Display the list of conversation
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param {HTMLElement} target The target of the page
 | 
			
		||||
	 * @param {Object} args Additional arguments
 | 
			
		||||
	 */
 | 
			
		||||
	display: function(target, args){
 | 
			
		||||
	display: function(target){
 | 
			
		||||
 | 
			
		||||
		//Create the box
 | 
			
		||||
		var listBox = createElem2({
 | 
			
		||||
@@ -58,13 +57,13 @@ ComunicWeb.pages.conversations.listPane = {
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			//Load the list of conversations
 | 
			
		||||
			ComunicWeb.pages.conversations.listPane.refresh_list(boxBody, args);
 | 
			
		||||
			ComunicWeb.pages.conversations.listPane.refresh_list(boxBody);
 | 
			
		||||
 | 
			
		||||
		}, 5000);
 | 
			
		||||
 | 
			
		||||
		//Force load the list of conversations
 | 
			
		||||
		ComunicWeb.pages.conversations.listPane._curr_list = null;
 | 
			
		||||
		ComunicWeb.pages.conversations.listPane.refresh_list(boxBody, args);
 | 
			
		||||
		ComunicWeb.pages.conversations.listPane.refresh_list(boxBody);
 | 
			
		||||
		
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
@@ -72,9 +71,8 @@ ComunicWeb.pages.conversations.listPane = {
 | 
			
		||||
	 * Refresh the list of conversations
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param {HTMLElement} target The target for the list
 | 
			
		||||
	 * @param {Object} args Additionnal arguments
 | 
			
		||||
	 */
 | 
			
		||||
	refresh_list: function(target, args){
 | 
			
		||||
	refresh_list: function(target){
 | 
			
		||||
 | 
			
		||||
		//Loading message, if required
 | 
			
		||||
		if(target.childElementCount == 0){
 | 
			
		||||
@@ -110,7 +108,7 @@ ComunicWeb.pages.conversations.listPane = {
 | 
			
		||||
			emptyElem(target); //Remove any previously shown list
 | 
			
		||||
 | 
			
		||||
			//Display the list of conversations
 | 
			
		||||
			ComunicWeb.pages.conversations.listPane._display_list(target, result, args);
 | 
			
		||||
			ComunicWeb.pages.conversations.listPane._display_list(target, result);
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
	},
 | 
			
		||||
@@ -121,9 +119,8 @@ ComunicWeb.pages.conversations.listPane = {
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param {HTMLElement} target The target for the list
 | 
			
		||||
	 * @param {Object} list The list of conversations
 | 
			
		||||
	 * @param {Object} args Additional arguments
 | 
			
		||||
	 */
 | 
			
		||||
	_display_list: function(target, list, args){
 | 
			
		||||
	_display_list: function(target, list){
 | 
			
		||||
 | 
			
		||||
		//Create the conversations container
 | 
			
		||||
		var conversationsContainer = createElem2({
 | 
			
		||||
@@ -132,16 +129,13 @@ ComunicWeb.pages.conversations.listPane = {
 | 
			
		||||
			class: "nav nav-pills nav-stacked"
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		//Make sure there isn't any selected conversation currently
 | 
			
		||||
		args.selected_conversation = null;
 | 
			
		||||
 | 
			
		||||
		//Process the list of conversations
 | 
			
		||||
		for (var num in list) {
 | 
			
		||||
			if (list.hasOwnProperty(num)) {
 | 
			
		||||
				var conversation = list[num];
 | 
			
		||||
				
 | 
			
		||||
				//Display conversation element
 | 
			
		||||
				args = this._display_entry(conversationsContainer, conversation, args);
 | 
			
		||||
				this._display_entry(conversationsContainer, conversation);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
@@ -150,20 +144,6 @@ ComunicWeb.pages.conversations.listPane = {
 | 
			
		||||
			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;
 | 
			
		||||
 | 
			
		||||
			//Enable slimscroll again
 | 
			
		||||
			ComunicWeb.pages.conversations.utils.enableSlimScroll(
 | 
			
		||||
				conversationsContainer, 
 | 
			
		||||
				ComunicWeb.pages.conversations.utils.getAvailableHeight() + 55, 
 | 
			
		||||
				newScrollPos);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
@@ -171,10 +151,8 @@ ComunicWeb.pages.conversations.listPane = {
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param {HTMLElement} target The target for the conversation
 | 
			
		||||
	 * @param {Object} info Information about the conversation to display
 | 
			
		||||
	 * @param {Object} args Additional arguments
 | 
			
		||||
	 * @return Additional arguments (may be modified)
 | 
			
		||||
	 */
 | 
			
		||||
	_display_entry: function(target, info, args) {
 | 
			
		||||
	_display_entry: function(target, info) {
 | 
			
		||||
 | 
			
		||||
		//Create conversation container element
 | 
			
		||||
		var convContainer = createElem2({
 | 
			
		||||
@@ -196,16 +174,9 @@ ComunicWeb.pages.conversations.listPane = {
 | 
			
		||||
			convLink.className += " selected";
 | 
			
		||||
 | 
			
		||||
			//Open the conversation
 | 
			
		||||
			args.opener(info.ID);
 | 
			
		||||
			openPage("conversations/"+info.ID)
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		//Check if it is the current conversation
 | 
			
		||||
		if(args.getCurrentID() == info.ID){
 | 
			
		||||
			convLink.className += " selected";
 | 
			
		||||
 | 
			
		||||
			//Save selected conversation link
 | 
			
		||||
			args.selected_conversation = convContainer;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		//Add conversation last activity on the rigth
 | 
			
		||||
		var lastActivityContainer = createElem2({
 | 
			
		||||
@@ -249,9 +220,6 @@ ComunicWeb.pages.conversations.listPane = {
 | 
			
		||||
			type: "span",
 | 
			
		||||
			innerHTML: (info.members.length === 1 ? "1 member" : info.members.length + " members")
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		//Return the list of arguments
 | 
			
		||||
		return args;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -14,60 +14,22 @@ ComunicWeb.pages.conversations.main = {
 | 
			
		||||
	 */
 | 
			
		||||
	open: function(args, target){
 | 
			
		||||
 | 
			
		||||
		//Conversation page is organized like an array with two columns
 | 
			
		||||
		//Left column : the list of conversations
 | 
			
		||||
		//Rigth column : the message of the currently opened conversation
 | 
			
		||||
 | 
			
		||||
		//Create a row
 | 
			
		||||
		var row = createElem2({
 | 
			
		||||
		//Create a container
 | 
			
		||||
		const container = createElem2({
 | 
			
		||||
			appendTo: target,
 | 
			
		||||
			type: "div",
 | 
			
		||||
			class: "row conversations-page-container"
 | 
			
		||||
			class: "conversations-page-container"
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		//Left area: The list of conversations
 | 
			
		||||
		var leftArea = createElem2({
 | 
			
		||||
			appendTo: row,
 | 
			
		||||
			type: "div",
 | 
			
		||||
			class: "col-md-3"
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		//Right area : The conversations
 | 
			
		||||
		var rightArea = createElem2({
 | 
			
		||||
			appendTo: row,
 | 
			
		||||
			type: "div",
 | 
			
		||||
			class: "col-md-9"
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		/**
 | 
			
		||||
		 * Open a conversation
 | 
			
		||||
		 * 
 | 
			
		||||
		 * @param {Number} id The ID of the conversation
 | 
			
		||||
		 */
 | 
			
		||||
		var conversationOpener = function(id){
 | 
			
		||||
 | 
			
		||||
			//Empty the target
 | 
			
		||||
			emptyElem(rightArea);
 | 
			
		||||
 | 
			
		||||
			//Open the conversation
 | 
			
		||||
			ComunicWeb.pages.conversations.conversation.open(id, rightArea);
 | 
			
		||||
 | 
			
		||||
			//Update website URI
 | 
			
		||||
			ComunicWeb.common.page.update_uri("Conversations", "conversations/" + id);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		//Check if a conversation has to be opened
 | 
			
		||||
		if(args.subfolder){
 | 
			
		||||
 | 
			
		||||
			//Open the conversation
 | 
			
		||||
			conversationOpener(ComunicWeb.pages.conversations.main.getCurrentConversationID());
 | 
			
		||||
			ComunicWeb.pages.conversations.conversation.open(this.getCurrentConversationID(), container);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		//Display the list of conversation
 | 
			
		||||
		ComunicWeb.pages.conversations.listPane.display(leftArea, {
 | 
			
		||||
			opener: conversationOpener,
 | 
			
		||||
			getCurrentID: this.getCurrentConversationID
 | 
			
		||||
		});
 | 
			
		||||
		// Otherwise display the list of conversations
 | 
			
		||||
		else {
 | 
			
		||||
			ComunicWeb.pages.conversations.listPane.display(container);
 | 
			
		||||
		}	
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user