1
0
mirror of https://github.com/nerzhul/ocsms.git synced 2025-06-08 16:36:25 +00:00

Added a function to add a style when a conversation is selected

This commit is contained in:
Ner'zhul 2014-09-17 12:15:27 +02:00
parent b4b93a2f0c
commit 01ff6a2099

View File

@ -8,6 +8,10 @@
* @copyright Loic Blot 2014
*/
// Some global vars to improve performances
var selectedConversation = null;
function fetchConversation(phoneNumber) {
$.getJSON(OC.generateUrl('/apps/ocsms/get/conversation'),
{'phoneNumber': phoneNumber},
@ -47,6 +51,15 @@ function fetchConversation(phoneNumber) {
}
);
}
function changeSelectedConversation(item) {
if (selectedConversation != null) {
selectedConversation.removeClass('active');
}
selectedConversation = $(this);
selectedConversation.addClass('active');
}
(function ($, OC) {
$(document).ready(function () {
// Now bind the events when we click on the phone number
@ -70,6 +83,7 @@ function fetchConversation(phoneNumber) {
var phoneNumber = $(this).attr('mailbox-navigation');
OC.Util.History.pushState('phonenumber=' + phoneNumber);
fetchConversation(phoneNumber);
changeSelectedConversation($(this));
event.preventDefault();
});