Conversation window can be opened and closed

This commit is contained in:
Pierre 2017-06-14 16:39:34 +02:00
parent 3e5ce7c97a
commit fa5cbdf9a6
7 changed files with 153 additions and 8 deletions

View File

@ -539,6 +539,13 @@ var ComunicWeb = {
//TODO : implement //TODO : implement
}, },
/**
* Conversation chat window functions
*/
chatWindows: {
//TODO : implement
},
/** /**
* Interface between conversation UI and the API * Interface between conversation UI and the API
*/ */
@ -552,6 +559,13 @@ var ComunicWeb = {
cachingOpened:{ cachingOpened:{
//TODO : implement //TODO : implement
}, },
/**
* Conversation service file
*/
service:{
//TODO : implement
}
}, },
/** /**

View File

@ -54,6 +54,21 @@ ComunicWeb.components.conversations.cachingOpened = {
//Save the new values //Save the new values
var conversationsString = conversations.join(";"); var conversationsString = conversations.join(";");
sessionStorage.setItem(this.__varName, conversationsString); sessionStorage.setItem(this.__varName, conversationsString);
//Success
return true;
},
/**
* Check is a conversation ID is open or not
*
* @param {Integer} conversationID The ID of the conversation to check
* @return {Boolean} Depends of the presence of the conversation
*/
isopen: function(conversationID){
var conversations = this.getAll();
return conversations.includes(conversationID.toString());
}, },
/** /**

View File

@ -0,0 +1,42 @@
/**
* Conversation chat window functions
*
* @author Pierre HUBERT
*/
ComunicWeb.components.conversations.chatWindows = {
/**
* Create a new chat window
*
* @param {Object} infos Informations required for the new chat window
* @info {HTMLElement} target The target of the new chat window
* @info {Integer} conversationID The ID of the target conversation
* @return {Object} Informations about the new chat window
*/
create: function(infos){
//Log action
ComunicWeb.debug.logMessage("Create a new chat window");
//First, create the generic conversation window
var infosBox = ComunicWeb.components.conversations.windows.create(infos.target.children[0]);
infosBox.conversationID = infos.conversationID;
//Adapt close button behaviour
infosBox.closeFunction = function(){
//Remove root element
infosBox.rootElem.remove();
//Remove the conversation from opened ones
ComunicWeb.components.conversations.cachingOpened.remove(infosBox.conversationID);
}
infosBox.closeButton.onclick = infosBox.closeFunction;
//Return informations about the chat window
return infosBox;
},
}

View File

@ -5,6 +5,12 @@
*/ */
ComunicWeb.components.conversations.manager = { ComunicWeb.components.conversations.manager = {
/**
* @var {String} The ID of the conversation contener
*/
__conversationsContenerID: "conversationsElem",
/** /**
* Display conversations manager * Display conversations manager
* *
@ -13,7 +19,7 @@ ComunicWeb.components.conversations.manager = {
display: function(){ display: function(){
//Try to get conversation manager //Try to get conversation manager
var conversationsContainerElem = byId("conversationsElem"); var conversationsContainerElem = byId(this.__conversationsContenerID);
//Check if element exists or not //Check if element exists or not
if(conversationsContainerElem){ if(conversationsContainerElem){
@ -27,7 +33,7 @@ ComunicWeb.components.conversations.manager = {
//Create conversations manager element //Create conversations manager element
var conversationsContainerElem = createElem("div"); var conversationsContainerElem = createElem("div");
conversationsContainerElem.id = "conversationsElem"; conversationsContainerElem.id = this.__conversationsContenerID;
//Insert the element at the right place //Insert the element at the right place
var pageTarget = byId("pageTarget"); var pageTarget = byId("pageTarget");
@ -100,11 +106,23 @@ ComunicWeb.components.conversations.manager = {
return false; return false;
} }
//Check if the conversation is already open or not
if(ComunicWeb.components.conversations.cachingOpened.isopen(conversationID)){
ComunicWeb.debug.logMessage("The conversation " + conversationID + " is already opened !");
return false;
}
//Log action //Log action
ComunicWeb.debug.logMessage("Opening conversation " + conversationID); ComunicWeb.debug.logMessage("Opening conversation " + conversationID);
//Save conversation ID in session storage //Save conversation ID in session storage
ComunicWeb.components.conversations.cachingOpened.add(conversationID);
//Create a conversation windows
ComunicWeb.components.conversations.chatWindows.create({
target: byId(this.__conversationsContenerID),
conversationID: conversationID
});
//Success //Success
return true; return true;

View File

@ -0,0 +1,11 @@
/**
* Conversation service file
*
* Ensure that the content of the conversations is up to date
*
* @author Pierre HUBER
*/
ComunicWeb.components.conversations.service = {
}

View File

@ -56,6 +56,7 @@ ComunicWeb.components.conversations.windows = {
var boxElements ={ var boxElements ={
rootElem: conversationBox, rootElem: conversationBox,
closeFunction: closeBox, closeFunction: closeBox,
closeButton: closeButton,
boxTitle: boxTitle, boxTitle: boxTitle,
boxTools: boxTools, boxTools: boxTools,
boxBody: boxBody, boxBody: boxBody,

View File

@ -10,7 +10,7 @@ $config['pathAssets'] = $config['siteURL']."assets/";
//CSS files to include //CSS files to include
$config['CSSfiles'] = array( $config['CSSfiles'] = array(
//CSS files //CSS files - adminLTE distribution / bootstrap / plugins
"%PATH_ASSETS%3rdparty/adminLTE/bootstrap/css/bootstrap.min.css", "%PATH_ASSETS%3rdparty/adminLTE/bootstrap/css/bootstrap.min.css",
"%PATH_ASSETS%3rdparty/adminLTE/plugins/font-awesome/css/font-awesome.min.css", "%PATH_ASSETS%3rdparty/adminLTE/plugins/font-awesome/css/font-awesome.min.css",
"%PATH_ASSETS%3rdparty/adminLTE/plugins/ionicons/css/ionicons.min.css", "%PATH_ASSETS%3rdparty/adminLTE/plugins/ionicons/css/ionicons.min.css",
@ -20,30 +20,52 @@ $config['CSSfiles'] = array(
"%PATH_ASSETS%3rdparty/adminLTE/dist/css/AdminLTE.min.css", "%PATH_ASSETS%3rdparty/adminLTE/dist/css/AdminLTE.min.css",
"%PATH_ASSETS%3rdparty/adminLTE/dist/css/skins/_all-skins.min.css", "%PATH_ASSETS%3rdparty/adminLTE/dist/css/skins/_all-skins.min.css",
//App stylesheets //App stylesheets - common stylesheets
"%PATH_ASSETS%css/common/global.css", "%PATH_ASSETS%css/common/global.css",
"%PATH_ASSETS%css/common/page/waitSplashScreen.css", "%PATH_ASSETS%css/common/page/waitSplashScreen.css",
"%PATH_ASSETS%css/common/network/networkError.css", "%PATH_ASSETS%css/common/network/networkError.css",
//Components stylesheets //Components stylesheets
//Menubar stylesheet
"%PATH_ASSETS%css/components/menuBar.css", "%PATH_ASSETS%css/components/menuBar.css",
//Searchform stylesheet
"%PATH_ASSETS%css/components/searchForm.css", "%PATH_ASSETS%css/components/searchForm.css",
//Friendbar stylesheet
"%PATH_ASSETS%css/components/friends/friendsBar.css", "%PATH_ASSETS%css/components/friends/friendsBar.css",
//Conversations stylesheet
"%PATH_ASSETS%css/components/conversations/manager.css", "%PATH_ASSETS%css/components/conversations/manager.css",
"%PATH_ASSETS%css/components/conversations/windows.css", "%PATH_ASSETS%css/components/conversations/windows.css",
"%PATH_ASSETS%css/components/conversations/list.css", "%PATH_ASSETS%css/components/conversations/list.css",
//User selector stylesheet
"%PATH_ASSETS%css/components/userSelect/userSelect.css", "%PATH_ASSETS%css/components/userSelect/userSelect.css",
); );
//JS files to include (at the end of the page) //JS files to include (at the end of the page)
$config['JSfiles'] = array( $config['JSfiles'] = array(
//Framework inclusions //Framework inclusions
//Jquery
"%PATH_ASSETS%3rdparty/adminLTE/plugins/jQuery/jquery-2.2.3.min.js", "%PATH_ASSETS%3rdparty/adminLTE/plugins/jQuery/jquery-2.2.3.min.js",
//Bootstrap
"%PATH_ASSETS%3rdparty/adminLTE/bootstrap/js/bootstrap.min.js", "%PATH_ASSETS%3rdparty/adminLTE/bootstrap/js/bootstrap.min.js",
//JQuery UI
"%PATH_ASSETS%3rdparty/adminLTE/plugins/jquery-ui/jquery-ui.min.js", "%PATH_ASSETS%3rdparty/adminLTE/plugins/jquery-ui/jquery-ui.min.js",
//iCheck
"%PATH_ASSETS%3rdparty/adminLTE/plugins/iCheck/icheck.min.js", "%PATH_ASSETS%3rdparty/adminLTE/plugins/iCheck/icheck.min.js",
//Slimscroll
"%PATH_ASSETS%3rdparty/adminLTE/plugins/slimScroll/jquery.slimscroll.min.js", "%PATH_ASSETS%3rdparty/adminLTE/plugins/slimScroll/jquery.slimscroll.min.js",
//Select2
"%PATH_ASSETS%3rdparty/adminLTE/plugins/select2/select2.min.js", "%PATH_ASSETS%3rdparty/adminLTE/plugins/select2/select2.min.js",
//adminLTE script
"%PATH_ASSETS%3rdparty/adminLTE/dist/js/app.min.js", "%PATH_ASSETS%3rdparty/adminLTE/dist/js/app.min.js",
//Bootstrap notify //Bootstrap notify
@ -55,10 +77,12 @@ $config['JSfiles'] = array(
//Functions schema //Functions schema
"%PATH_ASSETS%js/common/functionsSchema.js", "%PATH_ASSETS%js/common/functionsSchema.js",
//App scripts //Pages list
"%PATH_ASSETS%js/pagesList.js",
//App scripts -- common scripts
"%PATH_ASSETS%js/common/cacheManager.js", "%PATH_ASSETS%js/common/cacheManager.js",
"%PATH_ASSETS%js/common/network.js", "%PATH_ASSETS%js/common/network.js",
"%PATH_ASSETS%js/pagesList.js",
"%PATH_ASSETS%js/common/api.js", "%PATH_ASSETS%js/common/api.js",
"%PATH_ASSETS%js/common/errors.js", "%PATH_ASSETS%js/common/errors.js",
"%PATH_ASSETS%js/common/messages.js", "%PATH_ASSETS%js/common/messages.js",
@ -66,26 +90,41 @@ $config['JSfiles'] = array(
"%PATH_ASSETS%js/common/url.js", "%PATH_ASSETS%js/common/url.js",
"%PATH_ASSETS%js/common/jsFiles.js", "%PATH_ASSETS%js/common/jsFiles.js",
"%PATH_ASSETS%js/common/debug.js", "%PATH_ASSETS%js/common/debug.js",
"%PATH_ASSETS%js/langs/en.inc.js",
"%PATH_ASSETS%js/common/page.js", "%PATH_ASSETS%js/common/page.js",
"%PATH_ASSETS%js/common/notifications.js", "%PATH_ASSETS%js/common/notifications.js",
"%PATH_ASSETS%js/common/formChecker.js", "%PATH_ASSETS%js/common/formChecker.js",
"%PATH_ASSETS%js/common/date.js", "%PATH_ASSETS%js/common/date.js",
"%PATH_ASSETS%js/common/system.js", "%PATH_ASSETS%js/common/system.js",
//Default langage
"%PATH_ASSETS%js/langs/en.inc.js",
//Components //Components
//Mail caching
"%PATH_ASSETS%js/components/mailCaching.js", "%PATH_ASSETS%js/components/mailCaching.js",
//Search form
"%PATH_ASSETS%js/components/searchForm/searchForm.js", "%PATH_ASSETS%js/components/searchForm/searchForm.js",
//Main menubar
"%PATH_ASSETS%js/components/menuBar/common.js", "%PATH_ASSETS%js/components/menuBar/common.js",
"%PATH_ASSETS%js/components/menuBar/notAuthenticated.js", "%PATH_ASSETS%js/components/menuBar/notAuthenticated.js",
"%PATH_ASSETS%js/components/menuBar/authenticated.js", "%PATH_ASSETS%js/components/menuBar/authenticated.js",
//Friends components
"%PATH_ASSETS%js/components/friends/friendsList.js", "%PATH_ASSETS%js/components/friends/friendsList.js",
"%PATH_ASSETS%js/components/friends/friendsBar.js", "%PATH_ASSETS%js/components/friends/friendsBar.js",
//Private conversations
"%PATH_ASSETS%js/components/conversations/manager.js", "%PATH_ASSETS%js/components/conversations/manager.js",
"%PATH_ASSETS%js/components/conversations/list.js", "%PATH_ASSETS%js/components/conversations/list.js",
"%PATH_ASSETS%js/components/conversations/windows.js", "%PATH_ASSETS%js/components/conversations/windows.js",
"%PATH_ASSETS%js/components/conversations/chatWindows.js",
"%PATH_ASSETS%js/components/conversations/interface.js", "%PATH_ASSETS%js/components/conversations/interface.js",
"%PATH_ASSETS%js/components/conversations/service.js",
"%PATH_ASSETS%js/components/conversations/cachingOpened.js", "%PATH_ASSETS%js/components/conversations/cachingOpened.js",
//User selector
"%PATH_ASSETS%js/components/userSelect/userSelect.js", "%PATH_ASSETS%js/components/userSelect/userSelect.js",
//User scripts //User scripts
@ -94,9 +133,14 @@ $config['JSfiles'] = array(
"%PATH_ASSETS%js/user/userInfos.js", "%PATH_ASSETS%js/user/userInfos.js",
//Pages scripts //Pages scripts
//Home page
"%PATH_ASSETS%js/pages/home/home.js", "%PATH_ASSETS%js/pages/home/home.js",
"%PATH_ASSETS%js/pages/home/landingPage.js", "%PATH_ASSETS%js/pages/home/landingPage.js",
//Login page
"%PATH_ASSETS%js/pages/login.js", "%PATH_ASSETS%js/pages/login.js",
//Logout page
"%PATH_ASSETS%js/pages/logout.js", "%PATH_ASSETS%js/pages/logout.js",
//Create shortcuts for common functions //Create shortcuts for common functions