https://wstoolpro.com/wp-content/plugins/wp-modal-popup-with-cooki…/assets/js/wmpci-popup.js?ver=2.5
1/*! 2 * WmpciPop 1.0.0 3 * https://astoundify.com 4 * 5 * Copyright (c) 2021 Astoundify 6 */ 7 8(function (WmpciPop, undefined) { 9 10 'use strict'; 11 12 // set default settings 13 var settings = { 14 15 // set default cover id 16 coverId: 'wmpci-popup-cover', 17 18 // duration (in days) before it pops up again 19 expires: 1, 20 21 // close if someone clicks an element with this class and prevent default action 22 closeClassNoDefault: 'wmpci-popup-close', 23 24 // close if someone clicks an element with this class and continue default action 25 closeClassDefault: 'wmpci-close-go', 26 27 // change the cookie name 28 cookieName: '_Wmpci_Popup', 29 30 // on popup open function callback 31 onPopUpOpen: null, 32 33 // on popup close function callback 34 onPopUpClose: null, 35 36 // hash to append to url to force display of popup 37 forceHash: 'splash', 38 39 // hash to append to url to delay popup for 1 day 40 delayHash: 'go', 41 42 // close if the user clicks escape 43 closeOnEscape: true, 44 45 // set an optional delay (in milliseconds) before showing the popup 46 delay: 10000, 47 48 // automatically close the popup after a set amount of time (in milliseconds) 49 hideAfter: null 50 }, 51 52 53 // grab the elements to be used 54 $el = { 55 html: document.getElementsByTagName('html')[0], 56 cover: document.getElementById(settings.coverId), 57 closeClassDefaultEls: document.querySelectorAll('.' + settings.closeClassDefault), 58 closeClassNoDefaultEls: document.querySelectorAll('.' + settings.closeClassNoDefault) 59 }, 60 61 62 /** 63 * Helper methods 64 */ 65 66 util = { 67 68 hasClass: function(el, name) { 69 return new RegExp('(\\s|^)' + name + '(\\s|$)').test(el.className); 70 }, 71 72 addClass: function(el, name) { 73 if (!util.hasClass(el, name)) { 74 el.className += (el.className ? ' ' : '') + name; 75 } 76 }, 77 78 removeClass: function(el, name) { 79 if (util.hasClass(el, name)) { 80 el.className = el.className.replace(new RegExp('(\\s|^)' + name + '(\\s|$)'), ' ').replace(/^\s+|\s+$/g, ''); 81 } 82 }, 83 84 addListener: function(target, type, handler) { 85 if (target.addEventListener) { 86 target.addEventListener(type, handler, false); 87 } else if (target.attachEvent) { 88 target.attachEvent('on' + type, handler); 89 } 90 }, 91 92 removeListener: function(target, type, handler) { 93 if (target.removeEventListener) { 94 target.removeEventListener(type, handler, false); 95 } else if (target.detachEvent) { 96 target.detachEvent('on' + type, handler); 97 } 98 }, 99 100 isFunction: function(functionToCheck) { 101 var getType = {}; 102 return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]'; 103 }, 104 105 setCookie: function(name, days) { 106 var date = new Date(); 107 date.setTime(+ date + (days * 86400000)); 108 document.cookie = name + '=true; expires=' + date.toGMTString() + '; path=/'; 109 }, 110 111 hasCookie: function(name) { 112 if (document.cookie.indexOf(name) !== -1) { 113 return true; 114 } 115 return false; 116 }, 117 118 // check if there is a hash in the url 119 hashExists: function(hash) { 120 if (window.location.hash.indexOf(hash) !== -1) { 121 return true; 122 } 123 return false; 124 }, 125 126 preventDefault: function(event) { 127 if (event.preventDefault) { 128 event.preventDefault(); 129 } else { 130 event.returnValue = false; 131 } 132 }, 133 134 mergeObj: function(obj1, obj2) { 135 for (var attr in obj2) { 136 obj1[attr] = obj2[attr]; 137 } 138 } 139 }, 140 141 142 /** 143 * Private Methods 144 */ 145 146 // close popup when user hits escape button 147 onDocUp = function(e) { 148 if (settings.closeOnEscape) { 149 if (e.keyCode === 27) { 150 WmpciPop.close(); 151 } 152 } 153 }, 154 155 openCallback = function() { 156 157 // if not the default setting
158 if (settings.onPopUpOpen !== null) { 159 160 // make sure the callback is a function 161 if (util.isFunction(settings.onPopUpOpen)) { 162 settings.onPopUpOpen.call(); 163 } else { 164 throw new TypeError('WmpciPop open callback must be a function.'); 165 } 166 } 167 }, 168 169 closeCallback = function() { 170 171 // if not the default setting 172 if (settings.onPopUpClose !== null) { 173 174 // make sure the callback is a function 175 if (util.isFunction(settings.onPopUpClose)) { 176 settings.onPopUpClose.call(); 177 } else { 178 throw new TypeError('WmpciPop close callback must be a function.'); 179 } 180 } 181 }; 182 183 184 185 /** 186 * Public methods 187 */ 188 189 WmpciPop.open = function() { 190 191 var i, len; 192 193 if (util.hashExists(settings.delayHash)) { 194 util.setCookie(settings.cookieName, 1); // expire after 1 day 195 return; 196 } 197 198 util.addClass($el.html, 'wmpci-popup-open'); 199 200 // bind close events and prevent default event 201 if ($el.closeClassNoDefaultEls.length > 0) { 202 for (i=0, len = $el.closeClassNoDefaultEls.length; i < len; i++) { 203 util.addListener($el.closeClassNoDefaultEls[i], 'click', function(e) { 204 if (e.target === this) { 205 util.preventDefault(e); 206 WmpciPop.close(); 207 } 208 }); 209 } 210 } 211 212 // bind close events and continue with default event 213 if ($el.closeClassDefaultEls.length > 0) { 214 for (i=0, len = $el.closeClassDefaultEls.length; i < len; i++) { 215 util.addListener($el.closeClassDefaultEls[i], 'click', function(e) { 216 if (e.target === this) { 217 WmpciPop.close(); 218 } 219 }); 220 } 221 } 222 223 // bind escape detection to document 224 util.addListener(document, 'keyup', onDocUp); 225 openCallback(); 226 }; 227 228 WmpciPop.close = function(e) { 229 util.removeClass($el.html, 'wmpci-popup-open'); 230 util.setCookie(settings.cookieName, settings.expires); 231 232 // unbind escape detection to document 233 util.removeListener(document, 'keyup', onDocUp); 234 closeCallback(); 235 }; 236 237 WmpciPop.init = function(options) { 238 if (navigator.cookieEnabled) { 239 util.mergeObj(settings, options); 240 241 // check if there is a cookie or hash before proceeding 242 if (!util.hasCookie(settings.cookieName) || util.hashExists(settings.forceHash)) { 243 if (settings.delay === 0) { 244 WmpciPop.open(); 245 } else { 246 // delay showing the popup 247 setTimeout(WmpciPop.open, settings.delay); 248 } 249 if (settings.hideAfter) { 250 // hide popup after the set amount of time 251 setTimeout(WmpciPop.close, settings.hideAfter + settings.delay); 252 } 253 } 254 } 255 }; 256 257 // alias 258 WmpciPop.start = function(options) { 259 WmpciPop.init(options); 260 }; 261 262 263}(window.WmpciPop = window.WmpciPop || {})); 264 265 266// Custom Code 267jQuery( document ).ready(function() { 268 269 var popup_sett = { 270 'coverId' : 'wmpci-popup-wrp', 271 'delay' : (parseInt(Wmpci_Popup.delay) * 1000), 272 'closeOnEscape' : Wmpci_Popup.close_on_esc, 273 'expires' : parseInt(Wmpci_Popup.exp_time), 274 'hideAfter' : (parseInt(Wmpci_Popup.hide_time) * 1000) 275 }; 276 277 if( Wmpci_Popup.enable == 1 ){ 278 WmpciPop.start( popup_sett ); 279 } 280});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.