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

PeerList modification

Export peerList loading from document.ready. Modify peerlist only if there is peers
This commit is contained in:
Loic Blot 2014-10-07 10:33:36 +02:00
parent bea6f41892
commit 17a14753e0
2 changed files with 25 additions and 17 deletions

View File

@ -140,10 +140,7 @@ function changeSelectedConversation(item) {
selectedConversation.parent().addClass('selected');
}
(function ($, OC) {
$(document).ready(function () {
// Now bind the events when we click on the phone number
$.getJSON(OC.generateUrl('/apps/ocsms/get/peerlist'), function(jsondata, status) {
function fetchInitialPeerList() {
// Use a buffer for better jQuery performance
var peerListBuf = "";
@ -160,7 +157,17 @@ function changeSelectedConversation(item) {
peerListBuf += '<li><a href="#" mailbox-navigation="' + val + '">' + peerLabel + '</a></li>';
});
// Only modify peerList if there is peers
if (peerListBuf != '') {
$('#app-mailbox-peers ul').html(peerListBuf);
}
}
(function ($, OC) {
$(document).ready(function () {
// Now bind the events when we click on the phone number
$.getJSON(OC.generateUrl('/apps/ocsms/get/peerlist'), function(jsondata, status) {
fetchInitialPeerList();
// Now bind the events when we click on the phone number
$('#app-mailbox-peers').find('a[mailbox-navigation]').on('click', function (event) {

View File

@ -6,6 +6,7 @@
<div id="app">
<div id="app-mailbox-peers">
<ul>
<li><a>There isn't any conversation</a></li>
</ul>
</div>
<div id="app-content">