| 1 |
/******/ (function() { // webpackBootstrap |
| 2 |
var __webpack_exports__ = {}; |
| 3 |
/*!***************************************************!*\ |
| 4 |
!*** ./assets/src/apps/js/admin/admin-notices.js ***! |
| 5 |
\***************************************************/ |
| 6 |
let elLPAdminNotices = null; |
| 7 |
let elBtnDismiss; |
| 8 |
let dataHtml = null; |
| 9 |
const queryString = window.location.search; |
| 10 |
const urlParams = new URLSearchParams(queryString); |
| 11 |
const tab = urlParams.get('tab'); |
| 12 |
const urlApiAdminNotices = lpGlobalSettings.rest + 'lp/v1/admin/tools/admin-notices'; |
| 13 |
|
| 14 |
const callAdminNotices = function () { |
| 15 |
let set = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; |
| 16 |
const params = tab ? `?tab=${tab}` : `?${set}`; |
| 17 |
fetch(urlApiAdminNotices + params, { |
| 18 |
method: 'GET' |
| 19 |
}).then(res => res.json()).then(res => { |
| 20 |
// console.log(data); |
| 21 |
const { |
| 22 |
status, |
| 23 |
message, |
| 24 |
data |
| 25 |
} = res; |
| 26 |
|
| 27 |
if (status === 'success') { |
| 28 |
dataHtml = data.content; |
| 29 |
|
| 30 |
if (dataHtml.length === 0 && elLPAdminNotices) { |
| 31 |
elLPAdminNotices.style.display = 'none'; |
| 32 |
} |
| 33 |
} else { |
| 34 |
dataHtml = message; |
| 35 |
} |
| 36 |
}).catch(err => { |
| 37 |
console.log(err); |
| 38 |
}); |
| 39 |
}; |
| 40 |
|
| 41 |
callAdminNotices(); |
| 42 |
/*** DOMContentLoaded ***/ |
| 43 |
|
| 44 |
document.addEventListener('DOMContentLoaded', () => { |
| 45 |
elLPAdminNotices = document.querySelector('.lp-admin-notices'); |
| 46 |
elBtnDismiss = document.querySelector('.btn-lp-notice-dismiss'); |
| 47 |
const interval = setInterval(() => { |
| 48 |
if (dataHtml !== null) { |
| 49 |
if (dataHtml.length > 0) { |
| 50 |
elLPAdminNotices.innerHTML = dataHtml; |
| 51 |
elLPAdminNotices.style.display = 'block'; |
| 52 |
} |
| 53 |
|
| 54 |
clearInterval(interval); |
| 55 |
} |
| 56 |
}, 1); |
| 57 |
}); |
| 58 |
/*** Events ***/ |
| 59 |
|
| 60 |
document.addEventListener('click', e => { |
| 61 |
const el = e.target; |
| 62 |
|
| 63 |
if (el.classList.contains('btn-lp-notice-dismiss')) { |
| 64 |
e.preventDefault(); // eslint-disable-next-line no-alert |
| 65 |
|
| 66 |
if (confirm('Are you sure you want to dismiss this notice?')) { |
| 67 |
const parent = el.closest('.lp-admin-notice'); |
| 68 |
callAdminNotices(`dismiss=${el.getAttribute('data-dismiss')}`); |
| 69 |
parent.remove(); |
| 70 |
|
| 71 |
if (elLPAdminNotices.querySelectorAll('.lp-admin-notice').length === 0) { |
| 72 |
elLPAdminNotices.style.display = 'none'; |
| 73 |
} |
| 74 |
} |
| 75 |
} |
| 76 |
}); |
| 77 |
/******/ })() |
| 78 |
; |
| 79 |
//# sourceMappingURL=admin-notices.js.map |