bindNotiFunctionally(); $('#get_next_noti_page').click(function(event){ let page = $(this).data('page'); {% if mod.isie == 1 %} uhcipajax = new $.Uchip(); {% else %} uhcipajax = new Uchip(); {% endif %} let btnpage = $(this); $('#get_next_noti_page').hide(); $('#loader_noti_page').show(); uhcipajax.call('module=notification_center&acc=getpage', { data: 'page=' + page, callback: function(response){ $('#loader_noti_page').hide(); if(response.status == 'OK'){ if(response.notifications.length > 0){ $('#get_next_noti_page').show(); $('#get_next_noti_page').data('page', parseInt(response.page) + 1); renderNotifications(response.notifications); } } } }); event.stopPropagation(); }); function renderNotifications(notifications){ let html_notis = ''; notifications.forEach(function(notify){ let unreadclass = ''; if (notify.st != 2 ){ unreadclass = 'unread'; } let title = ''; let icon = ''; if (notify.type == 'websitechange'){ icon = 'fa-globe'; title = notify.childs.length + ' ' + '{{langene.NCLABELWEB}}'; }else if(notify.type == 'emailquota' ){ icon = 'fa-envelope-o'; title = notify.childs.length + ' ' + '{{langene.NCLABELEMQE}}'; }else if(notify.type == 'diskusage'){ icon = 'fa-hdd-o'; title = notify.childs.length + ' ' + '{{langene.NCLABELDQA}}'; }else if(notify.type == 'bwquota'){ icon = 'fa-tachometer'; title = notify.childs.length + ' ' + '{{langene.NCLABELBWQA}}'; } html_notis += '
  • ' + '' + '
    ' + ' ' + title + '' + '' + '
    ' + '
    ' + '' + '
  • ' + ''; }); $('#li_load_more_notis').before(html_notis); bindNotiFunctionally('with-subnotify.new-loaded'); dateNotiConverter(); $('.with-subnotify.new-loaded').removeClass('new-loaded'); } function updateNotificationsView(toupdate, notify){ {% if mod.isie == 1 %} uhcipajax = new $.Uchip(); {% else %} uhcipajax = new Uchip(); {% endif %} uhcipajax.call('module=notification_center&acc=updatenotifications', { data: 'notifications=' + JSON.stringify(toupdate), callback: function(response){ notify.find('.title-notify').removeClass('unread'); let unreadqty = parseInt($('#unread_amount').text()); if(unreadqty - 1 > 0){ $('#unread_amount').text(unreadqty - 1); }else{ $('#unread_amount').hide(); } toupdate.forEach(function(item){ $('#subnoti_' + item).data('st', 2); }); } }); } dateNotiConverter(); function dateNotiConverter(){ $('.date-info').each(function(){ $(this).text(moment.unix($(this).data('date')).fromNow()); $(this).removeClass('date-info'); }); } function bindNotiFunctionally(extra_class){ extra_class = (extra_class === undefined) ? 'with-subnotify' : extra_class; $('ul.cwp-notifications .dropdown-item.' + extra_class).on('click', function(event){ let subnotify = $(this).parent().find('.sub-notify'); if(subnotify.is(':visible')){ subnotify.slideUp('fast'); }else{ let toupdate = []; subnotify.slideDown('fast'); subnotify.find('.sub-notify-item').each(function(){ let st = $(this).data('st'); if(st != 2){ toupdate.push($(this).data('notiid')); } }); let notify = $(this); if(toupdate.length > 0){ setTimeout(function(){ if(subnotify.is(':visible')){ updateNotificationsView(toupdate, notify); } },2500); } } event.stopPropagation(); }); }