https://www.lbs.edu.ng/wp-content/plugins/quick-event-manager/legacy/quick-event-manager.js?ver=9.17
1const {__, _x, _n, sprintf} = wp.i18n; 2var qem_dont_cancel; 3 4 5(function ($) { 6 function pseudo_popup(content) { 7 var popup = document.createElement("div"); 8 popup.innerHTML = content; 9 var viewport_width = window.innerWidth; 10 var viewport_height = window.innerHeight; 11 12 function add_underlay() { 13 var underlay = document.createElement("div"); 14 underlay.style.position = "fixed"; 15 popup.style.zIndex = "9997"; 16 underlay.style.top = "0px"; 17 underlay.style.left = "0px"; 18 underlay.style.width = viewport_width + "px"; 19 underlay.style.height = viewport_height + "px"; 20 underlay.style.background = "#7f7f7f"; 21 if (navigator.userAgent.match(/msie/i)) { 22 underlay.style.background = "#7f7f7f"; 23 underlay.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=50)"; 24 } else { 25 underlay.style.background = "rgba(127, 127, 127, 0.5)"; 26 } 27 underlay.onclick = function () { 28 underlay.parentNode.removeChild(underlay); 29 popup.parentNode.removeChild(popup); 30 }; 31 document.body.appendChild(underlay); 32 } 33 34 add_underlay(); 35 var x = viewport_width / 2; 36 var y = viewport_height / 2; 37 popup.style.position = "fixed"; 38 document.body.appendChild(popup); 39 x -= popup.clientWidth / 2; 40 y -= popup.clientHeight / 2; 41 popup.style.zIndex = "9998"; 42 popup.style.top = y + "px"; 43 popup.style.left = x + "px"; 44 return false; 45 } 46 47 function qem_toggle_state() { 48 $(this).attr('clicked', 'clicked') 49 } 50 51 function qem_calendar_ajax(e) { 52 /* 53 Get calendar 54 */ 55 var calendar = $(e).closest('.qem_calendar'); 56 var cid = Number(calendar.attr('id').replace('qem_calendar_', '')); 57 var params = 'action=qem_ajax_calendar'; 58 59 /* 60 URL Encode the atts array 61 */ 62 63 let qem_calendar_atts = $('#qem_calendar_' + cid).data('qem_calendar_atts'); 64 for (property in qem_calendar_atts) { 65 params += '&atts[' + encodeURIComponent(property) + ']=' + encodeURIComponent(qem_calendar_atts[property]); 66 } 67 let qem_month = $('#qem_calendar_' + cid).data('qem_month'); 68 let qem_year = $('#qem_calendar_' + cid).data('qem_year'); 69 let qem_category = $('#qem_calendar_' + cid).data('qem_category'); 70 params += "&qemmonth=" + qem_month + "&qemyear=" + qem_year + "&qemcalendar=" + cid; 71 if (qem_category != '') params += '&category=' + qem_category; 72 73 $.post(ajaxurl, params, function (v) { 74 calendar.replaceWith($(v)); 75 qem_calnav(); 76 }, 'text'); 77 78 } 79 80 function qem_handle_regular(e, f) { 81 82 data = e; 83 84 /* 85 Handle Redirection 86 */ 87 if (data.hasOwnProperty('redirect')) { 88 if (data.redirect.redirect && !data.errors.length) { 89 window.location.href = data.redirect.url; 90 return; 91 } 92 } 93 94 qem = f.closest('.qem'); 95 if ( !qem.length ) { 96 qem = f.closest('.qem-columns'); 97 } 98 /* 99 Update whoscoming and places 100 */ 101 102 qem.find('.whoscoming').html(data.coming); 103 /* f.closest('.qem').find('.places').html(data.places); */ 104 105 /* 106 Deactivate all current errors 107 */ 108 qem.find('.qem-register').find('.qem-error,.qem-error-header').removeClass('qem-error qem-error-header'); 109 qem.find('.qem-register').find('h2').text(data.title); 110 111 /* 112 Hide the button! 113 */ 114 qem.find('.toggle-qem').hide(); 115 116 if (data.blurb !== undefined) { 117 var blurbText = qem.find('.qem-register').find('p').first(); 118 blurbText.show(); 119 blurbText.html(data.blurb); 120 } 121 122 /* 123 If errors: Display 124 */ 125 $('.qem-field-error').remove(); 126 console.log('---------------------') 127 console.log(data) 128 for (i in data.errors) { 129 element = f.find('[name=' + data.errors[i].name + ']'); 130 console.log(element); 131 element.addClass('qem-error'); 132 element.after('<p class="qem-error-header qem-field-error">' + data.errors[i].error + '</p>'); 133 } 134 135 /* 136 Change header class to reflect errors being present 137 */ 138 if (data.errors.length) { 139 qem.find('.qem-register').find('h2').addClass('qem-error-header'); 140 qem.find('.qem-register .places').hide(); 141 /* @since 9.2.3 remove as seems to hide the form for no good reason 142 if (data.errors[i].name == 'alreadyregistered') { 143 qem.find('.qem-register').children('p').first().hide(); 144 qem.find('.places').hide(); 145 qem.find('.qem-form').html(data.form || ''); 146 } 147 */ 148 149 } else { 150 /* 151 Successful validation! 152 */ 153 qem.find('.places').hide(); 154 var form = data.form; 155 qem.find('.qem-form').html(form); 156 } 157 158 /* 159 Scroll To Top 160 */ 161 $('html,body').animate({ 162 scrollTop: Math.max(qem.find('.qem-register').offset().top - 25, 0), 163 }, 200); 164 } 165 166 function qem_validate_form(ev) { 167 var f = $(this); 168 var formid = f.attr('id'); 169 170 // Intercept request and handle with AJAX 171 var fd = $(this).serialize(); 172 var action = $('<input type="text" />'); 173 action.attr('name', 'action'); 174 action.val('qem_validate_form'); 175
176 fd += '&' + action.serialize() + '&action=qem_validate_form'; 177 $('input[name=qemregister' + formid + ']').prop("disabled", true); 178 $('.qem_validating_form[data-form-id="' + formid + '"]').show(function () { 179 $.post(ajaxurl, 180 fd, 181 function (e) { 182 console.log('success'); 183 qem_handle_regular(e, f); 184 $('.qem_validating_form[data-form-id="' + formid + '"]').hide(); 185 }, 186 'json' 187 ).done(function (e) { 188 console.log('success 2'); 189 // second success 190 }).fail(function (e) { 191 console.log('fail'); 192 console.log(e); 193 // ajax fail 194 }).always(function (e) { 195 console.log('always'); 196 $('input[name=qemregister' + formid + ']').prop("disabled", false); 197 // alert("finished"); 198 }); 199 }); 200 ev.preventDefault(); 201 return false; 202 } 203 204 function qem_decide(e) { 205 206 if (!e.ic) return 0; 207 return 1; 208 209 } 210 211 212 $(document).ready(function () { 213 214 document.querySelectorAll('.qem-register form').forEach((form) => { 215 form.addEventListener('submit', qem_validate_form); 216 }); 217 $('.qem-register form input[type=submit], .qem-register form input[type=button]').click(qem_toggle_state); 218 219 /* 220 Set up calendar functionality 221 */ 222 qem_calnav(); 223 224 $("#paylater").change(function () { 225 var A = $('#submit').val(), 226 B = $('#submit').attr('alt'); 227 228 $('#submit').attr('alt', A).val(B); 229 }); 230 231 /* 232 Setup payment buttons for in-context payments 233 */ 234 if (typeof qem_ignore_ic === 'undefined') qem_ignore_ic = null; 235 236 if (typeof qem_ic !== 'undefined' && qem_ignore_ic == false) { 237 238 $('.qem-form form').submit(function (event) { 239 event.preventDefault(); 240 return false; 241 }); 242 243 $('.qem-form input[type=submit]').click(function (event) { 244 245 event.preventDefault(); 246 247 /* 248 Collect Important Data 249 */ 250 $target = event.target; 251 c = $($target); 252 $ = jQuery; 253 form = c.closest('form'); 254 form.hide(); 255 256 var formid = form.attr('id'); 257 $('.qem_validating_form[data-form-id="' + formid + '"]').show(); 258 259 var fd = $(form).serialize(); 260 fd += '&' + c.attr('name') + '=' + c.val() + '&action=qem_validate_form'; 261 $.ajax({ 262 type: 'POST', 263 url: ajaxurl, 264 data: fd, 265 success: function (e) { 266 data = e; 267 268 if (!data.success) { 269 270 $('.qem_validating[data-form-id="' + formid + '"]').hide(); 271 $('.qem_processing[data-form-id="' + formid + '"]').hide(); 272 form.show(); 273 qem_handle_regular(data, form); 274 275 return; 276 } 277 /* <fs_premium_only> */ 278 if (!data.ignore && data.stripe.use) { 279 $('.qem_validating[data-form-id="' + formid + '"]').hide(); 280 $('.qem_processing[data-form-id="' + formid + '"]').show(); 281 var stripe = Stripe(data.stripe.publishable_key); 282 stripe.redirectToCheckout({ 283 // Make the id field from the Checkout Session creation API response 284 // available to this file, so you can provide it as argument here 285 // instead of the {{CHECKOUT_SESSION_ID}} placeholder. 286 sessionId: data.stripe.session_id 287 }).then(function (result) { 288 // If `redirectToCheckout` fails due to a browser or network 289 // error, display the localized error message to your customer 290 // using `result.error.message`. 291 alert(result.error.message); 292 }); 293 } 294 /* </fs_premium_only> */ 295 }, 296 error: function (data) { 297 console.log(data); 298 alert(__('Server Error check console log', 'quick-event-manager')); 299 } 300 }); 301 302 return false;
303 }); 304 /* <fs_premium_only> */ 305 /* </fs_premium_only> */ 306 } 307 308 $('.qem-multi-product').on('input', function () { 309 var multiHolder = $(this).closest('.qem_multi_holder'); 310 var productInputs = multiHolder.find('input'); 311 var total = 0; 312 var attending = 0; 313 314 for (var i = 0; i < productInputs.length; i++) { 315 var inputValue = $(productInputs[i]).val(); 316 317 // Remove all non-integer characters from the input value 318 var cleanedValue = inputValue.replace(/\D/g, ''); 319 320 // Update the input field with the cleaned value 321 $(productInputs[i]).val(cleanedValue); 322 323 var quantity = parseInt(cleanedValue); 324 var cost = parseFloat($(productInputs[i]).data('qem-cost')); 325 if (!isNaN(quantity) ) { 326 attending += quantity; 327 total += quantity * cost; 328 } 329 } 330 331 if (attending < 2) { 332 $("#morenames").hide(); 333 } else { 334 $("#morenames").show(); 335 } 336 337 multiHolder.find('#total_price .qem_output').text(total.toFixed(2)); 338 }); 339 /* 340 QEM Toggle 341 */ 342 343 // settings preview 344 $('.qem-preview').on('click', function (e) { 345 alert(__('This is a preview of the event. To see the event go to the Events list.', 'quick-event-manager')); 346 return false 347 }) 348 349 // lightbox action 350 $("body").on('click', ".qem_linkpopup", function () { 351 let lightBoxData = $(this).data('xlightbox'); 352 xlightbox(lightBoxData); 353 }); 354 355 // fb and twitter share windows 356 $("body").on('click', ".qem_fb_share, .qem_twitter_share", function () { 357 window.open(this.href, 'targetWindow', 'titlebar=no,toolbar=no,location=0,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=250'); 358 return false; 359 }); 360 361 362 $("#yourplaces").keyup(function () { 363 var model = document.getElementById('yourplaces'); 364 var number = $('#yourplaces').val() 365 if (number == 1) 366 $("#morenames").hide(); 367 else { 368 $("#morenames").show(); 369 } 370 }); 371 372 $(".apply").hide(); 373 $(".toggle-qem").click(function (event) { 374 $(this).next(".apply").slideToggle(); 375 event.preventDefault(); 376 return false; 377 }); 378 379 /* 380 Date Picker 381*/ 382 383 datePickerOptions = { 384 closeText: "Done", 385 prevText: "Prev", 386 nextText: "Next", 387 currentText: "Today", 388 monthNames: ["January", "February", "March", "April", "May", "June",
389 "July", "August", "September", "October", "November", "December"], 390 monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", 391 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], 392 dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], 393 dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], 394 dayNamesMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], 395 weekHeader: "Wk", 396 firstDay: 1, 397 isRTL: false, 398 showMonthAfterYear: false, 399 yearSuffix: "", 400 dateFormat: 'dd M yy' 401 }; 402 403 $('#qemdate').datepicker(datePickerOptions); 404 $('#qemenddate').datepicker(datePickerOptions); 405 $('#qemcutoffdate').datepicker(datePickerOptions); 406 $('#qem_reg_start_date').datepicker(datePickerOptions); 407 408 }); 409 410 function qem_redirect(params) { 411 412 413 var action = "?token=" + params.token; 414 if (params.module == 'deferred') action = ''; 415 var form = $("<form method='POST' style='display:none;' action='" + action + "'></form>"), input; 416 for (i in params) { 417 418 if (i == "token") continue; 419 input = $('<input type="hidden" />'); 420 input.attr('name', i); 421 input.attr('value', params[i]); 422 423 form.append(input); 424 425 } 426 427 form.append("<input type='submit' name='qem_submit' value='submitted' />"); 428 $('body').append(form); 429 form.submit(); 430 431 } 432 433 function qem_calendar_prep(e) { 434 var calendar = $(e).closest('.qem_calendar'); 435 var cid = Number(calendar.attr('id').replace('qem_calendar_', '')); 436 var params = e.href.split('#')[0].split('?')[1]; 437 if (params !== undefined) params = params.split('&'); 438 else params = []; 439 var values = {}; 440 441 /* 442 Form params into an object 443 */ 444 for (i = 0; i < params.length; i++) { 445 set = params[i].split('='); 446 values[set[0]] = set[1]; 447 } 448 449 /* 450 Special case, no parameters at all = reset category 451 */ 452 if (params.length == 0) values.category = ''; 453 454 /* 455 Set the global variables if the link would have changed them! 456 */ 457 if (values.qemmonth !== undefined) $('#qem_calendar_' + cid).data('qem_month', values.qemmonth); 458 if (values.qemyear !== undefined) $('#qem_calendar_' + cid).data('qem_year', values.qemyear); 459 if (values.category !== undefined) $('#qem_calendar_' + cid).data('qem_category', values.category); 460 } 461 462 function qem_calnav() { 463 $('.qem_calendar .calnav').click(function (ev) { 464 465 ev.preventDefault(); 466 467 qem_calendar_prep(this); 468 qem_calendar_ajax(this); 469 470 return false; 471 472 }); 473 474 $('.qem_calendar .qem-category a').click(function (ev) { 475 476 ev.preventDefault(); 477 478 qem_calendar_prep(this); 479 qem_calendar_ajax(this); 480 481 return false; 482 483 }); 484 485 } 486 487 /* 488 LightBox 489 */ 490 491 function xlightbox(insertContent, ajaxContentUrl) { 492 493 // add lightbox/shadow <div/>'s if not previously added 494 if ($('#xlightbox').length == 0) { 495 var theLightbox = $('<div id="xlightbox"/>'); 496 var theShadow = $('<div id="xlightbox-shadow"/>'); 497 $(theShadow).click(function (e) { 498 closeLightbox(); 499 }); 500 $('body').append(theShadow); 501 $('body').append(theLightbox); 502 } 503 504 // remove any previously added content 505 $('#xlightbox').empty(); 506 507 // insert HTML content 508 if (insertContent != null) { 509 $('#xlightbox').append(insertContent); 510 } 511 512 // insert AJAX content 513 if (ajaxContentUrl != null) { 514 // temporarily add a "Loading..." message in the lightbox 515 $('#xlightbox').append('<p class="loading">Loading...</p>'); 516 517 // request AJAX content 518 $.ajax({ 519 type: 'GET', 520 url: ajaxContentUrl, 521 success: function (data) { 522 // remove "Loading..." message and append AJAX content 523 $('#xlightbox').empty(); 524 $('#xlightbox').append(data); 525 }, 526 error: function (data) { 527 console.log(data); 528 alert(__('Server Error Check Console log!', 'quick-event-manager')); 529 } 530 }); 531 } 532 533 // move the lightbox to the current window top + 100px 534 $('#xlightbox').css('top', $(window).scrollTop() + 100 + 'px'); 535 536 // display the lightbox 537 $('#xlightbox').show(); 538 $('#xlightbox-shadow').show(); 539 540 } 541 542// close the lightbox 543 544 function closeLightbox() { 545 546 // hide lightbox and shadow <div/>'s 547 $('#xlightbox').hide(); 548 $('#xlightbox-shadow').hide(); 549 550 // remove contents of lightbox in case a video or other content is actively playing 551 $('#xlightbox').empty(); 552 } 553})(jQuery); 554 555 556
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.