Trigger Popup
unknown
javascript
10 months ago
1.2 kB
11
Indexable
<script>
jQuery(document).ready(function($) {
const saveAppId = '96d13d9';
const discountId = '6f4794e';
const isStandalone = window.matchMedia('(display-mode: standalone)').matches
|| (typeof window.navigator.standalone !== 'undefined' && window.navigator.standalone);
if (!isStandalone) {
showPopup(saveAppId);
} else {
if (!localStorage.getItem('discount_shown')) {
showPopup(discountId, 'discount_shown', true);
}
}
function showPopup(widgetId, storageKey = '', trackShown = false) {
const $popupContent = $('#wdt-popup-box-content-holder-' + widgetId);
if ($popupContent.length) {
$.magnificPopup.open({
items: {
src: '#wdt-popup-box-content-holder-' + widgetId,
type: 'inline'
},
removalDelay: 500,
mainClass: 'wdt-popup-box-window-' + widgetId + ' wdt-fade-zoom',
callbacks: {
open: function() {
$('.mfp-wrap').addClass('wdt-popup-box-window mfp-inline-holder');
},
close: function() {
if (trackShown && storageKey) {
localStorage.setItem(storageKey, 'true');
}
}
}
});
}
}
});
</script>Editor is loading...
Leave a Comment