2015-08-03 11:35:01 +02:00
|
|
|
/*function showNotifsList() {
|
|
|
|
movim_toggle_class('#notifslist', 'show');
|
|
|
|
}*/
|
|
|
|
|
|
|
|
var Notifs = {
|
|
|
|
lswidget : localStorage.getItem('username').replace('@', 'at') + '_Notifs',
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
refresh : function() {
|
|
|
|
var items = document.querySelectorAll('#notifs_widget li:not(.subheader)');
|
|
|
|
var i = 0;
|
|
|
|
while(i < items.length)
|
|
|
|
{
|
|
|
|
items[i].onclick = function(e) {
|
|
|
|
MovimTpl.showPanel();
|
|
|
|
Contact_ajaxGetContact(this.dataset.jid);
|
|
|
|
Notifs.reset(items);
|
|
|
|
movim_add_class(this, 'active');
|
|
|
|
}
|
|
|
|
|
2015-12-21 22:59:03 +01:00
|
|
|
items[i].querySelector('span.control.icon').onclick = function(e) {
|
2015-08-03 11:35:01 +02:00
|
|
|
Notifs_ajaxAsk(this.dataset.jid);
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
/* Should the list of pending invitations show? */
|
|
|
|
var invitShown = document.querySelector('#notifs_widget li.subheader')
|
|
|
|
if(invitShown){
|
|
|
|
var ls = localStorage.getObject(Notifs.lswidget);
|
|
|
|
if(ls === null){
|
|
|
|
localStorage.setObject(Notifs.lswidget, {"invitShown": true});
|
|
|
|
Notifs.ls = localStorage.getObject(Notifs.lswidget);
|
|
|
|
}
|
|
|
|
if(localStorage.getObject(Notifs.lswidget).invitShown === true)
|
|
|
|
document.querySelector('#notifs_widget').className += " groupshown";
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
invitShown.onclick = function(e) {
|
|
|
|
Notifs.showHide(e.target);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
reset: function(list) {
|
|
|
|
for(i = 0; i < list.length; i++) {
|
|
|
|
movim_remove_class(list[i], 'active');
|
|
|
|
}
|
|
|
|
},
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
showHide : function(e){
|
|
|
|
state = localStorage.getObject(Notifs.lswidget).invitShown;
|
|
|
|
parent = document.querySelector('#notifs_widget');
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
if(state === true)
|
|
|
|
parent.className = parent.className.replace(" groupshown", "");
|
|
|
|
else
|
|
|
|
parent.className += " groupshown";
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
localStorage.setObject(Notifs.lswidget, {"invitShown": !state});
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
MovimWebsocket.attach(function() {
|
2015-08-19 11:28:28 +02:00
|
|
|
Notifs_ajaxGet();
|
2015-08-03 11:35:01 +02:00
|
|
|
});
|