PluginProbe
Taskbuilder – Project Management & Task Management Tool With Kanban Board / 6.0.4
Taskbuilder – Project Management & Task Management Tool With Kanban Board v6.0.4
6.0.5 6.0.2 6.0.3 6.0.4 6.0.1 6.0.0 5.0.8 5.0.9 4.0.9 5.0.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 All 57 releases
taskbuilder / asset / js / notification.js

notification.js in Taskbuilder – Project Management & Task Management Tool With Kanban Board 6.0.4, at asset/js/notification.js

68 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 jQuery(document).ready(function() {
2 // Load notification count when the page loads
3 wppm_loadNotifications();
4 // Refresh every 30 seconds
5 setInterval(function () {
6 if (!document.hidden) {
7 wppm_loadNotifications();
8 }
9 }, 60000);
10 });
11
12 jQuery(document).on('click', function (e) {
13 if (
14 !jQuery(e.target).closest('#wppm_notification_bell').length &&
15 !jQuery(e.target).closest('#wppm-notification-container').length
16 ) {
17 jQuery('#wppm-notification-container').hide();
18 }
19 });
20
21 function wppm_loadNotifications() {
22 jQuery.ajax({
23 url: wppm_notification.ajax_url,
24 type: "POST",
25 data: {
26 action: "wppm_get_notifications"
27 },
28 dataType: "json",
29 success: function(response) {
30 if(response.length > 0){
31 jQuery("#wppm_notification_bell").addClass("wppm-has-notification");
32 jQuery(".wppm-badge").text(response.length).show();
33 }else{
34 jQuery("#wppm_notification_bell").removeClass("wppm-has-notification");
35 jQuery(".wppm-badge").text("0").show();
36 }
37 var html = "";
38 if(response.length > 0){
39 jQuery.each(response, function(i, notification){
40 html += '<div class="wppm-notification-item" data-id="' + notification.id + '" data-link="' + notification.link + '">';
41 html += '<div class="wppm-notification-message">'+notification.message+'</div>';
42 html += '<small>'+notification.created_at+'</small>';
43 html += '</div>';
44 });
45 }else{
46 html = '<div class="wppm-no-notification">No new notifications</div>';
47 }
48 jQuery("#wppm-notification-container").html(html);
49 }
50 });
51 }
52
53 jQuery(document).on("click", ".wppm-notification-item", function () {
54 var id = jQuery(this).data("id");
55 jQuery.ajax({
56 url: wppm_notification.ajax_url,
57 type: "POST",
58 data: {
59 action: "wppm_mark_notification_read",
60 id: id
61 }
62 });
63 // Then open the task
64 });
65 jQuery(document).on('click', '#wppm_notification_bell', function () {
66 wppm_loadNotifications();
67 jQuery('#wppm-notification-container').toggle();
68 });