Ignore:
Timestamp:
10/23/21 17:48:25 (3 years ago)
Author:
beratkjufliju <kufliju@…>
Branches:
develop, master
Children:
a8346eb
Parents:
4b7e2d3
Message:

minor bug fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • resources/assets/js/custom.js

    r4b7e2d3 rb39afb5  
    108108    });
    109109
    110     function hasNew(response) {
    111 
    112         for(var i=0; i<response.length; i++) {
    113             if(!response[i].isRead) {
    114                 return true;
    115             }
    116         }
    117 
    118         return false;
    119     }
    120 
    121     function notifications() {
    122 
    123         var url = "/dashboard/get-notifications";
    124         var _token = $("meta[name='csrf-token']").attr("content");
    125 
    126         $.ajax({
    127             url: url,
    128             type: "post",
    129             dataType: "json",
    130             data: {
    131                 _token : _token,
    132             },
    133             success: function(response) {
    134 
    135                 $(".dropdown-notifications a:not(:last)").remove();
    136                 $(".dropdown-notifications-unread .nav-unread").hide();
    137 
    138                 var l = response.length;
    139 
    140                 if(hasNew(response)) {
    141                     $(".dropdown-notifications .unreadNotificationsInfo").hide();
    142                     $(".dropdown-notifications-unread .nav-unread").show();
    143                 }
    144 
    145                 if(l == 0) {
    146                     $(".dropdown-notifications .unreadNotificationsInfo").show();
    147                 }
    148 
    149                 if(l > 0) {
    150                     $(".dropdown-notifications .unreadNotificationsInfo").hide();
    151                 }
    152 
    153                 for(var i=0; i<l; i++) {
    154 
    155                     var style = response[i].isRead ? "" : "background: #efefef; color: black;";
    156 
    157                     var notificationItem = `
    158                                                 <a href="` + response[i].url + `" class="dropdown-item d-flex" style="` + style + `;">
    159                                                         <div>
    160                                                                 ` + response[i].message + `
    161                                                                 <div class="small text-muted">` + response[i].ago + `</div>
    162                                                         </div>
    163                                                 </a>`;
    164 
    165                     $(".dropdown-notifications").prepend(notificationItem);
    166                 }
    167             },
    168             error: function(response) {
    169                 console.log(response);
    170             }
    171         });
    172     }
    173 
    174     $(".dropdown-notifications-unread .nav-unread").hide();
    175     notifications();
    176     setInterval(function() { notifications(); }, 5000);
    177 
    178     $(".dropdown-notifications-wrapper").click(function() {
    179         $(".dropdown-notifications-unread .nav-unread").hide();
    180     });
    181 
    182110    $(document).on('click', '#btn-layout-builder', function () {
    183111
Note: See TracChangeset for help on using the changeset viewer.