PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.17.0
GiveWP – Donation Plugin and Fundraising Platform v4.17.0
4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 All 256 releases
give / src / DonorDashboards / resources / js / admin / index.js

index.js in GiveWP – Donation Plugin and Fundraising Platform 4.17.0, at src/DonorDashboards/resources/js/admin/index.js

34 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 // Code to handle showing/hiding admin notices (based on dismissed status in localStorage)
2
3 document.addEventListener('DOMContentLoaded', () => {
4 // Select dismissible notices
5 const notices = document.querySelectorAll('div[data-give-dismissible]');
6
7 // Apply for every dismissible GiveWP notice
8 notices.forEach((notice) => {
9 // Generate storage id for notice
10 const storageId = `give-dismissed-${notice.dataset.giveDismissible}`;
11
12 // Retrieve timestamp of notice dismissal, if it has already happened
13 const storedItem = window.localStorage.getItem(storageId);
14
15 // If notice has not yet been dismissed continue
16 if (!storedItem) {
17 // Show the notice, if it has not been dismissed
18 notice.classList.remove('hidden');
19
20 // On dismissal click, add a record to local storage to that it remains hidden in the future
21 notice.addEventListener('click', (e) => {
22 if (e.target.classList.contains('notice-dismiss')) {
23 window.localStorage.setItem(storageId, Date.now());
24 }
25
26 if (e.target.classList.contains('give-donor-dashboard-upgrade-notice__dismiss-link')) {
27 notice.classList.add('hidden');
28 window.localStorage.setItem(storageId, Date.now());
29 }
30 });
31 }
32 });
33 });
34