Improved connection between big and small conversation windows

This commit is contained in:
Pierre HUBERT 2019-05-16 18:40:39 +02:00
parent 30743601a9
commit cd8280ae01
6 changed files with 39 additions and 12 deletions

View File

@ -24,7 +24,8 @@ declare interface CreateElem2Args {
innerHTMLprefix ?: string, innerHTMLprefix ?: string,
disabled ?: boolean, disabled ?: boolean,
children ?: HTMLElement[], children ?: HTMLElement[],
onclick ?: Function onclick ?: Function,
ondblclick ?: Function
} }
declare function createElem(nodeType : string, appendTo : string) : HTMLElement; declare function createElem(nodeType : string, appendTo : string) : HTMLElement;

View File

@ -145,11 +145,16 @@ function log(message){
* Open a conversation specified by its ID * Open a conversation specified by its ID
* *
* @param {number} id The ID of the conversation to open * @param {number} id The ID of the conversation to open
* @param {bool} fullscreen Specify whether the conversation has to
* appear in full screen or not
*/ */
function openConversation(id){ function openConversation(id, fullscreen = false){
if(!fullscreen)
ComunicWeb.components.conversations.manager.addConversation({ ComunicWeb.components.conversations.manager.addConversation({
conversationID: id conversationID: id
}); });
else
openPage("conversations/" + id);
} }
/** /**

View File

@ -45,6 +45,7 @@ function createElem(nodeType, appendTo){
* @info {boolean} disabled Set whether the field should be disabled or not (input only) * @info {boolean} disabled Set whether the field should be disabled or not (input only)
* @info {HTMLElement[]} children Children for the new object * @info {HTMLElement[]} children Children for the new object
* @info {Function} onclick * @info {Function} onclick
* @info {Function} ondblclick
* @return {HTMLElement} The newly created element * @return {HTMLElement} The newly created element
*/ */
function createElem2(infos){ function createElem2(infos){
@ -133,6 +134,9 @@ function createElem2(infos){
if(infos.onclick) if(infos.onclick)
newElem.addEventListener("click", infos.onclick); newElem.addEventListener("click", infos.onclick);
if(infos.ondblclick)
newElem.addEventListener("dblclick", infos.ondblclick);
//Return newly created element //Return newly created element
return newElem; return newElem;
} }

View File

@ -386,24 +386,32 @@ ComunicWeb.components.conversations.chatWindows = {
* Change the name of the converation at the top of the windows * Change the name of the converation at the top of the windows
* *
* @param {String} newName The new name for the conversation window * @param {String} newName The new name for the conversation window
* @param {Ojbect} infos Informations about the conversation window * @param {Ojbect} info Information about the conversation window
* @return {Boolean} True for a success * @return {Boolean} True for a success
*/ */
changeName: function(newName, infos){ changeName: function(newName, info){
//Reduce new name //Reduce new name
if(newName.length > 18) if(newName.length > 18)
newName = newName.slice(0, 17) + "..."; newName = newName.slice(0, 17) + "...";
//Empty name field //Empty name field
emptyElem(infos.boxTitle); emptyElem(info.boxTitle);
//Create conversation icon //Create conversation icon
var conversationIcon = createElem("i", infos.boxTitle); createElem2({
conversationIcon.className = "fa fa-comments"; type: "i",
appendTo: info.boxTitle,
class: "fa fa-comments",
ondblclick: () => {
openConversation(info.conversationID, true);
info.closeFunction();
}
});
//Add conversation title //Add conversation title
var conversationTitle = createElem("span", infos.boxTitle); var conversationTitle = createElem("span", info.boxTitle);
conversationTitle.innerHTML = " " + newName; conversationTitle.innerHTML = " " + newName;
//Success //Success

View File

@ -153,7 +153,7 @@ ComunicWeb.components.conversations.service = {
for(i in result){ for(i in result){
//Check if new entries are available //Check if new entries are available
if(result[i].length === 0) if(result[i].length === 0 || !this.__serviceCache[i])
continue; //Nothing to be done continue; //Nothing to be done
//Extract conversation ID //Extract conversation ID

View File

@ -63,6 +63,15 @@ ComunicWeb.pages.conversations.conversation = {
class: "box-header" class: "box-header"
}); });
// Box icon
createElem2({
appendTo: boxHeader,
type: "span",
class: "box-title",
innerHTML: "<i class='fa fa-comments'></i> ",
ondblclick: () => openConversation(convID, false)
});
//Box title //Box title
var boxTitle = createElem2({ var boxTitle = createElem2({
appendTo: boxHeader, appendTo: boxHeader,