1(function () { 2 var $ = jQuery; 3 4 (function (factory) { 5 if (typeof define === 'function' && define.amd) { 6 define(['jquery'], factory); //AMD 7 } else if (typeof exports === 'object') { 8 module.exports = factory; //Browserify 9 } else { 10 factory(jQuery); //globals 11 } 12 })(function ($) { 13 $.event.special.mresize = { 14 add: function () { 15 var el = $(this); 16 if (el.data('mresize')) return; 17 if (el.css('position') === 'static') el.css('position', 'relative'); 18 el.append( 19 "<div class='resize' style='position:absolute; width:auto; height:auto; top:0; right:0; bottom:0; left:0; margin:0; padding:0; overflow:hidden; visibility:hidden; z-index:-1'><iframe style='width:100%; height:0; border:0; visibility:visible; margin:0' /><iframe style='width:0; height:100%; border:0; visibility:visible; margin:0' /></div>", 20 ) 21 .data('mresize', { 22 w: el.width(), 23 h: el.height(), 24 t: null, 25 throttle: 100, 26 }) 27 .find('.resize iframe') 28 .each(function () { 29 $(this.contentWindow || this).on('resize', function () { 30 var d = el.data('mresize'); 31 if (d.w !== el.width() || d.h !== el.height()) { 32 if (d.t) clearTimeout(d.t); 33 d.t = setTimeout(function () { 34 el.triggerHandler('mresize'); 35 d.w = el.width(); 36 d.h = el.height(); 37 }, d.throttle); 38 } 39 }); 40 }); 41 }, 42 remove: function () { 43 $(this).removeData('mresize').find('.resize').remove(); 44 }, 45 }; 46 }); 47 48 $(document).ready(function () { 49 const time = 300; 50 51 var get_month_value; 52 var window_width = $(window).width(); 53 54 //Get in touch 55 56 var gitClose = $('.glp-block-apply-wrapper .glp-close'); 57 var gitPageToTop = $('.glp-page-to-top'); 58 var gitApply = $('.glp-apply'); 59 60 var glpTopDeal = $('.glp-shop-top-deal'); 61 62 gitClose.click(function () { 63 gitApply.fadeOut(time); 64 $(this).fadeOut(time); 65 setTimeout(function () { 66 gitPageToTop.fadeIn(time); 67 $('.glp-block-apply-wrapper .glp-btn-tap.glp-close').css('display', 'none'); 68 }, time); 69 }); 70 71 gitPageToTop.click(function () { 72 gitPageToTop.fadeOut(time); 73 setTimeout(function () { 74 gitApply.fadeIn(time); 75 gitClose.fadeIn(time); 76 }, time); 77 }); 78 79 const slider = document.querySelector('[type="range"]'); 80 if (slider) { 81 const output = document.querySelector('[data-output]'); 82 83 rangeSlider.create(slider, { 84 onSlide: function (val) { 85 output.textContent = val.toLocaleString('en-US'); 86 }, 87 }); 88 89 const slider_rate = document.querySelector('.rate-in'); 90 const output_rate = document.querySelector('.rate-out'); 91 92 rangeSlider.create(slider_rate, { 93 onSlide: function (val) { 94 output_rate.textContent = val; 95 }, 96 }); 97 98 var rangeSlider_fill_cs = []; 99 if (window_width > 767) { 100 for (var i = 1; i <= 98; i++) { 101 rangeSlider_fill_cs.push('<div class="glp-layer-green">' + '</div>'); 102 } 103 } else { 104 for (var i = 1; i <= 39; i++) { 105 rangeSlider_fill_cs.push('<div class="glp-layer-green">' + '</div>'); 106 } 107 } 108 109 var rangeSlider_fill_cs_rate = []; 110 if (window_width > 767) { 111 for (var i = 1; i <= 48; i++) { 112 rangeSlider_fill_cs_rate.push('<div class="glp-layer-green">' + '</div>'); 113 } 114 } else { 115 for (var i = 1; i <= 39; i++) { 116 rangeSlider_fill_cs_rate.push('<div class="glp-layer-green">' + '</div>'); 117 } 118 } 119 120 var rangeSlider_fill_cs_rate_product = []; 121 if (window_width > 767) { 122 for (var i = 1; i <= 58; i++) { 123 rangeSlider_fill_cs_rate_product.push('<div class="glp-layer-green">' + '</div>'); 124 } 125 } else { 126 for (var i = 1; i <= 39; i++) { 127 rangeSlider_fill_cs_rate_product.push('<div class="glp-layer-green">' + '</div>'); 128 } 129 } 130 131 $('.glp-borrow') 132 .find('.rangeSlider__handle__horizontal') 133 .append( 134 '<div class="glp-output-value">' + 135 $('.glp-your-repayment').data('currency') + 136 '<span>' + 137 formatNumber($('#clp-loan').val()) + 138 '</span>' + 139 '</div>', 140 ); 141 $('.glp-rate') 142 .find('.rangeSlider__handle__horizontal') 143 .append( 144 '<div class="glp-output-value">' + 145 '<span>' + 146 formatNumber($('.rate-in').val()) + 147 '</span>' + 148 '%' + 149 '</div>', 150 ); 151 $('.rangeSlider__horizontal').append('<div class="range_value_green">' + '</div>'); 152 $('.glp-borrow .range_value_green').append(rangeSlider_fill_cs); 153 $('.resource-wrapper .glp-rate .range_value_green').append(rangeSlider_fill_cs_rate); 154 155 $('.product-details-wrapper .glp-rate .range_value_green').append( 156 rangeSlider_fill_cs_rate_product, 157 ); 158 159 var width_full = $('.rangeSlider__horizontal').width(); 160 var width_value = $('.rangeSlider__fill__horizontal').width(); 161 if (window_width > 767) {
162 var width_layer_active = Math.ceil((width_value / width_full) * 100); 163 } else { 164 var width_layer_active = Math.ceil((width_value / width_full) * 39); 165 } 166 167 var count = 1; 168 $('.glp-borrow') 169 .find('.range_value_green .glp-layer-green') 170 .each(function () { 171 if (count > width_layer_active) { 172 $(this).removeClass('active'); 173 } else { 174 if (!$(this).hasClass('active')) { 175 $(this).addClass('active'); 176 } 177 } 178 count++; 179 }); 180 if ($('body').find('.glp-layer-green')) { 181 $( 182 '.glp-borrow .range_value_green .glp-layer-green.active:nth-child(' + 183 width_layer_active-- + 184 ')', 185 ).css({ 186 height: '40px', 187 transform: 'translateY(-20px)', 188 }); 189 $( 190 '.glp-borrow .range_value_green .glp-layer-green.active:nth-child(' + 191 width_layer_active + 192 ')', 193 ).css({ 194 height: '30px', 195 transform: 'translateY(-10px)', 196 }); 197 } 198 var width_value_rate = $('.glp-rate').find('.rangeSlider__fill__horizontal').width(); 199 if (window_width > 767) { 200 var width_layer_active_rate = Math.ceil((width_value_rate / width_full) * 100); 201 } else { 202 var width_layer_active_rate = Math.ceil((width_value_rate / width_full) * 39); 203 } 204 var count = 1; 205 $('.glp-rate') 206 .find('.range_value_green .glp-layer-green') 207 .each(function () { 208 if (count > width_layer_active_rate) { 209 $(this).removeClass('active'); 210 } else { 211 if (!$(this).hasClass('active')) { 212 $(this).addClass('active'); 213 } 214 } 215 count++; 216 }); 217 if ($('body').find('.glp-layer-green')) { 218 $( 219 '.glp-rate .range_value_green .glp-layer-green.active:nth-child(' + 220 width_layer_active_rate-- + 221 ')', 222 ).css({ 223 height: '40px', 224 transform: 'translateY(-20px)', 225 }); 226 $( 227 '.glp-rate .range_value_green .glp-layer-green.active:nth-child(' + 228 width_layer_active_rate + 229 ')', 230 ).css({ 231 height: '30px', 232 transform: 'translateY(-10px)', 233 }); 234 } 235 $(window).load(function () { 236 $('.rangeSlider__fill__horizontal').on('mresize', function () { 237 var text_value = $(this).parents('.glp-range-item').find('output').text(); 238 $(this) 239 .parent('.rangeSlider__horizontal') 240 .find('.glp-output-value span') 241 .html(text_value); 242 var width_value = $(this).width(); 243 if (window_width > 767) { 244 var width_layer_active = Math.ceil((width_value / width_full) * 100); 245 } else { 246 var width_layer_active = Math.ceil((width_value / width_full) * 40); 247 if (width_full - width_value < 50) { 248 $(this).parents('.glp-borrow').find('.glp-output-value').css({ 249 left: '-100px', 250 transform: 'none', 251 }); 252 } else if (width_full - width_value > 300) { 253 $(this).parents('.glp-borrow').find('.glp-output-value').css({ 254 left: '0', 255 transform: 'none', 256 }); 257 } else { 258 $(this).parents('.glp-borrow').find('.glp-output-value').css({ 259 left: '50%', 260 transform: 'translateX(-50%)', 261 }); 262 } 263 } 264 var count = 1; 265 $(this) 266 .parent('.rangeSlider__horizontal') 267 .find('.range_value_green .glp-layer-green') 268 .each(function () { 269 if (count > width_layer_active) { 270 $(this).removeClass('active'); 271 } else { 272 if (!$(this).hasClass('active')) { 273 $(this).addClass('active'); 274 } 275 } 276 count++; 277 }); 278 if ($('body').find('.glp-layer-green')) { 279 $(this) 280 .parent('.rangeSlider__horizontal') 281 .find('.range_value_green .glp-layer-green') 282 .css({ 283 height: '20px', 284 transform: 'translateY(0)', 285 }); 286 $(this) 287 .parent('.rangeSlider__horizontal') 288 .find( 289 '.range_value_green .glp-layer-green.active:nth-child(' + 290 width_layer_active-- + 291 ')', 292 ) 293 .css({ 294 height: '40px', 295 transform: 'translateY(-20px)', 296 }); 297 $(this) 298 .parent('.rangeSlider__horizontal') 299 .find( 300 '.range_value_green .glp-layer-green.active:nth-child(' + width_layer_active + ')', 301 ) 302 .css({ 303 height: '30px', 304 transform: 'translateY(-10px)', 305 }); 306 } 307 }); 308 }); 309 } 310 311 function formatNumber(num) { 312 return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,'); 313 } 314 315 function pmt(rate_per_period, number_of_payments, present_value, future_value, type) { 316 if (rate_per_period != 0.0) { 317 // Interest rate exists 318 var q = Math.pow(1 + rate_per_period, number_of_payments); 319 return ( 320 -(rate_per_period * (future_value + q * present_value)) / 321 ((-1 + q) * (1 + rate_per_period * type)) 322 ); 323 } else if (number_of_payments != 0.0) { 324 // No interest rate, but number of payments exists 325 return -(future_value + present_value) / number_of_payments; 326 } 327 return 0; 328 } 329 330 function calculator() { 331 let loan = parseFloat($('#clp-loan').val()); 332 // console.log(loan); 333 let tenure = parseInt($('.glp-month-value').text()); 334 // console.log(tenure); 335 let interest = $('#clp-interest').val() / 100; 336 337 let monthly_amount = 0; 338 let principal_amount = loan; 339 let total_interest = 0; 340 let total_payable = 0; 341 342 var instalment = 0 - pmt(interest, tenure, loan, 0, 0); 343 for (count = 1, closing = loan; count <= tenure; count++) { 344 opening = closing; 345 interest_paid = opening * interest; 346 principal_paid = instalment - interest_paid; 347 closing = count == tenure ? 0 : opening - principal_paid; 348 // appended; 349 //monthly_amount = instalment.toFixed(2).replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,'); 350 total_interest = 351 parseFloat(total_interest) + 352 parseFloat( 353 interest_paid 354 .toFixed(2) 355 .replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,') 356 .replace(',', ''), 357 ); 358 } 359 360 //appended; 361 /* 362 Months <= 3 : 1% 363 3 < Months <= 6 : 3% 364 6 < Months <= 12 : 5% 365 */ 366 var fees = 0; 367 var fees_ele = $('#clp-total-fees'); 368 369 if (fees_ele.length > 0) { 370 var repayment = $('.glp-your-repayment'); 371 var feeType = repayment.data('fee-type'); 372 var feeIndicator = repayment.data('fee-indicator'); 373 var arrFeeIndicator = feeIndicator.split(','); 374 375 if (feeType === 'disbursal_fee') { 376 let month = { 3: 0, 6: 1, 9: 2, 12: 3 }; 377 fees = (parseInt(principal_amount) * arrFeeIndicator[month[parseInt(tenure)]]) / 100; 378 } 379 380 if (feeType === 'legal_fee') { 381 fees = 382 parseInt(arrFeeIndicator[0]) + (parseInt(principal_amount) * arrFeeIndicator[1]) / 100; 383 } 384 } 385 386 $('.clp-months').html(tenure); 387 $('.clp-interest').html($('#clp-interest').val()); 388 389 if (parseInt(principal_amount) > 0) { 390 total = 391 parseFloat(principal_amount.toFixed(2)) + 392 parseFloat(total_interest.toFixed(2)) + 393 parseFloat(fees.toFixed(2)); 394 monthly_amount = (total / parseInt(tenure)).toFixed(2); 395 $('#clp-monthly-amount').html(formatNumber(monthly_amount)); 396 $('#clp-principal-amount').html(formatNumber(principal_amount.toFixed(2))); 397 $('#clp-total-interest').html(formatNumber(total_interest.toFixed(2))); 398 fees_ele.length > 0 && fees_ele.html(formatNumber(fees.toFixed(2))); 399 $('#clp-total-payable').html(formatNumber(total.toFixed(2))); 400 } else { 401 $('#clp-monthly-amount').html(''); 402 $('#clp-principal-amount').html(''); 403 $('#clp-total-interest').html(''); 404 $('#clp-total-payable').html(''); 405 } 406 } 407 408 $("input[type='range']").change(function () { 409 calculator(); 410 return false;
411 }); 412 413 calculator(); 414 $('.glp-pay .glp-btn').click(function () { 415 var test = $(this); 416 $('.glp-pay .glp-btn').removeClass('glp-get-value'); 417 $('.glp-pay .glp-btn').addClass('glp-btn-white'); 418 $(this).toggleClass('glp-btn-white'); 419 $(this).addClass('glp-get-value'); 420 get_month_value = parseInt($(this).parent('.glp-btn-row').find('.glp-get-value span').text()); 421 $(this).find('.glp-month-value').html(get_month_value); 422 423 // let tenure = parseInt($('.glp-month-value').text()); 424 function formatNumber(num) { 425 return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,'); 426 } 427 428 function pmt(rate_per_period, number_of_payments, present_value, future_value, type) { 429 if (rate_per_period != 0.0) { 430 // Interest rate exists 431 var q = Math.pow(1 + rate_per_period, number_of_payments); 432 return ( 433 -(rate_per_period * (future_value + q * present_value)) / 434 ((-1 + q) * (1 + rate_per_period * type)) 435 ); 436 } else if (number_of_payments != 0.0) { 437 // No interest rate, but number of payments exists 438 return -(future_value + present_value) / number_of_payments; 439 } 440 return 0; 441 } 442 443 function calculator() { 444 let loan = parseFloat($('#clp-loan').val()); 445 // console.log(loan); 446 let tenure = parseInt(test.find('.glp-month-value').text()); 447 // console.log(tenure); 448 let interest = $('#clp-interest').val() / 100; 449 // console.log(interest); 450 451 let monthly_amount = 0; 452 let principal_amount = loan; 453 let total_interest = 0; 454 let total_payable = 0; 455 456 var instalment = 0 - pmt(interest, tenure, loan, 0, 0); 457 for (count = 1, closing = loan; count <= tenure; count++) { 458 opening = closing; 459 interest_paid = opening * interest; 460 principal_paid = instalment - interest_paid; 461 closing = count == tenure ? 0 : opening - principal_paid; 462 // appended; 463 //monthly_amount = instalment.toFixed(2).replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,'); 464 total_interest = 465 parseFloat(total_interest) + 466 parseFloat( 467 interest_paid 468 .toFixed(2) 469 .replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,') 470 .replace(',', ''), 471 ); 472 } 473 474 //appended; 475 /* 476 Months <= 3 : 1% 477 3 < Months <= 6 : 3% 478 6 < Months <= 12 : 5% 479 */ 480 var fees = 0; 481 var fees_ele = $('#clp-total-fees'); 482 483 if (fees_ele.length > 0) { 484 var repayment = $('.glp-your-repayment'); 485 var feeType = repayment.data('fee-type'); 486 var feeIndicator = repayment.data('fee-indicator'); 487 var arrFeeIndicator = feeIndicator.split(','); 488 489 if (feeType === 'disbursal_fee') { 490 let month = { 3: 0, 6: 1, 9: 2, 12: 3 }; 491 fees = (parseInt(principal_amount) * arrFeeIndicator[month[parseInt(tenure)]]) / 100; 492 } 493 494 if (feeType === 'legal_fee') { 495 fees = 496 parseInt(arrFeeIndicator[0]) + 497 (parseInt(principal_amount) * arrFeeIndicator[1]) / 100; 498 } 499 } 500 501 $('.clp-months').html(tenure); 502 $('.clp-interest').html($('#clp-interest').val()); 503 504 if (parseInt(principal_amount) > 0) { 505 total = 506 parseFloat(principal_amount.toFixed(2)) + 507 parseFloat(total_interest.toFixed(2)) + 508 parseFloat(fees.toFixed(2)); 509 monthly_amount = (total / parseInt(tenure)).toFixed(2); 510 $('#clp-monthly-amount').html(formatNumber(monthly_amount)); 511 $('#clp-principal-amount').html(formatNumber(principal_amount.toFixed(2))); 512 $('#clp-total-interest').html(formatNumber(total_interest.toFixed(2))); 513 fees_ele.length > 0 && fees_ele.html(formatNumber(fees.toFixed(2))); 514 $('#clp-total-payable').html(formatNumber(total.toFixed(2))); 515 } else { 516 $('#clp-monthly-amount').html(''); 517 $('#clp-principal-amount').html(''); 518 $('#clp-total-interest').html(''); 519 $('#clp-total-payable').html(''); 520 } 521 } 522 523 $("input[type='range']").change(function () { 524 calculator(); 525 return false;
526 }); 527 calculator(); 528 }); 529 530 $('.glp-view-details').click(function () { 531 $(this).siblings('.glp-table').slideToggle(300); 532 }); 533 534 //Select dropdown 535 536 $('.glp-text-select').click(function () { 537 if ($(this).hasClass('glp-text-select-click')) { 538 $(this).removeClass('glp-text-select-click'); 539 $(this).find('.glp-dropdown').slideUp(300); 540 } else { 541 $('.glp-text-select').removeClass('glp-text-select-click'); 542 $('.glp-dropdown').slideUp(300); 543 $(this).addClass('glp-text-select-click'); 544 if ($(this).hasClass('glp-text-select-click')) { 545 $(this).find('.glp-dropdown').slideDown(300); 546 } 547 } 548 }); 549 550 $('body').on('click', function (e) { 551 var $trigger = $('.glp-text-select-showdrop'); 552 553 if ($trigger !== e.target && !$trigger.has(e.target).length) { 554 $('.glp-text-select').removeClass('glp-text-select-click'); 555 $('.glp-dropdown').slideUp(300); 556 } 557 }); 558 559 $('.glp-layer-mask input[type="checkbox"]').click(function () { 560 if ($(this).is(':checked')) { 561 $('.glp-layer-mask .gform_button').addClass('undisabled'); 562 } else { 563 $('.glp-layer-mask .gform_button').removeClass('undisabled'); 564 } 565 }); 566 567 toggleOpenModal(); 568 569 if (window_width < 992) { 570 var itemSlick = $('.glp-slider .elementor-row'); 571 if (itemSlick.length > 0) { 572 itemSlick.slick({ 573 infinite: false, 574 slidesToShow: 2, 575 slidesToScroll: 1, 576 arrows: false, 577 dots: true, 578 responsive: [ 579 { 580 breakpoint: 767, 581 settings: { 582 slidesToShow: 1, 583 centerMode: true, 584 centerPadding: '40px', 585 }, 586 }, 587 ], 588 }); 589 } 590 } 591 592 filterIstope(); 593 594 (function () { 595 let bannerSlick = $('.glp-banner-slider').find('.glp-banner-slider_slick'); 596 let bannerSlickItem = $('.glp-banner-slider').find('.glp-banner-top'); 597 if (bannerSlickItem.length > 1) { 598 bannerSlick.slick({ 599 infinite: true, 600 slidesToShow: 1, 601 slidesToScroll: 1, 602 dots: true, 603 prevArrow: bannerSlick.find('.prev'), 604 nextArrow: bannerSlick.find('.next'), 605 }); 606 } 607 })(); 608 609 (function () { 610 $('.glp-slider-alldevice .elementor-widget-wrap').slick({ 611 infinite: false, 612 slidesToShow: 3, 613 slidesToScroll: 1, 614 arrows: false, 615 dots: true, 616 responsive: [ 617 { 618 breakpoint: 991, 619 settings: { 620 slidesToShow: 2, 621 }, 622 }, 623 { 624 breakpoint: 767, 625 settings: { 626 slidesToShow: 1, 627 centerMode: true, 628 centerPadding: '40px', 629 }, 630 }, 631 ], 632 }); 633 })(); 634 635 //Top Deal Shop 636 (function () { 637 function shuffle(array) { 638 var m = array.length, 639 t, 640 i; 641 while (m) { 642 i = Math.floor(Math.random() * m--); 643 t = array[m]; 644 array[m] = array[i]; 645 array[i] = t; 646 } 647 return array; 648 } 649 650 if (window_width < 992 && glpTopDeal.length > 0) { 651 let topDeal = $('.glp-shop-top-deal .elementor-widget-wrap'); 652 let arrTopDeal = $('.glp-shop-top-deal .elementor-widget-wrap > div'); 653 654 topDeal.empty(); 655 656 shuffle(arrTopDeal).each(function () { 657 topDeal.append(this); 658 }); 659 660 $('.glp-shop-top-deal .elementor-widget-wrap').slick({ 661 infinite: false, 662 slidesToShow: 2, 663 slidesToScroll: 1, 664 arrows: false, 665 dots: true, 666 responsive: [ 667 { 668 breakpoint: 767, 669 settings: { 670 slidesToShow: 1, 671 centerMode: true, 672 centerPadding: '35px', 673 initialSlide: 1, 674 infinite: true, 675 }, 676 }, 677 ], 678 }); 679 } 680 })(); 681 682 //Hover payment type 683 (function () { 684 if (window_width > 767 && glpTopDeal.length > 0) { 685 $('.glp-shop-card-pament-type_list li', glpTopDeal).hover( 686 function () { 687 $(this).addClass('active'); 688 }, 689 function () { 690 $(this).removeClass('active'); 691 }, 692 ); 693 } 694 })(); 695 696 // load function 697 searchTitle(); 698 setSortCategory(); 699 setSortPayment(); 700 loadLayoutItem(); 701 fixSerachBar(); 702 sliderShopCard(); 703 cancelSearch(); 704 setActiveSearch(); 705 searchItem(); 706 pagination();
707 loadMore(); 708 resetFilter(); 709 getDataModal(); 710 }); 711 712 function getDataModal() { 713 jQuery('.glp-shop-card-payment .glp-js-open-popup').click(function (evemt) { 714 event.preventDefault(); 715 jQuery('.glp-layer-mask .glp-lightbox .glp-close').data('delay', 1000); 716 jQuery('.glp-lightbox .glp-shop-card_icon').hide(); 717 var content = jQuery(this).parent().parent().find('.glp-shop-card_content').html(); 718 var url = jQuery(this).parent().parent().find('.sp_card_url_shop').html(); 719 var title = jQuery(this).parent().parent().find('.glp-shop-card_title').html(); 720 var img = jQuery(this).parent().parent().parent().find('.glp-banner-card').attr('src'); 721 722 jQuery('.glp-lightbox .glp-content-detail h1').html(title); 723 jQuery('.glp-lightbox .glp-content-detail .glp-content').html(content); 724 jQuery('.glp-lightbox .glp-content-detail .glp-shop-now').attr('href', url); 725 jQuery('.glp-lightbox .glp-content-detail .glp-content a').attr('href', 'javascript:void(0)'); 726 jQuery('.glp-lightbox .glp-img-detail .alignnone').attr('src', img); 727 copyCode(); 728 }); 729 730 jQuery('.glp-shop-card_desc.glp-js-open-popup').click(function (evemt) { 731 event.preventDefault(); 732 jQuery('.glp-layer-mask .glp-lightbox .glp-close').data('delay', 1000); 733 jQuery('.glp-lightbox .glp-shop-card_icon').show(); 734 jQuery('.glp-lightbox .glp-img-detail').removeClass('custom'); 735 var content = jQuery(this).parent().find('.glp-shop-card_content').html(); 736 var url = jQuery(this).parent().find('.sp_card_url_shop').html(); 737 var title = jQuery(this) 738 .parent() 739 .parent() 740 .find('.glp-shop-card_content .glp-shop-card_title') 741 .html(); 742 var img = jQuery(this).parent().find('.glp-banner').attr('src'); 743 var icon = jQuery(this).parent().find('.glp-shop-card_icon img').attr('src'); 744 var br = jQuery(this).data('br'); 745 746 jQuery('.glp-lightbox .glp-content-detail h1').html(title); 747 jQuery('.glp-lightbox .glp-content-detail .glp-content').html(content); 748 jQuery('.glp-lightbox .glp-content-detail .glp-shop-now').attr('href', url); 749 jQuery('.glp-lightbox .glp-content-detail .glp-content a').attr('href', 'javascript:void(0)'); 750 jQuery('.glp-lightbox .glp-img-detail .alignnone').attr('src', img); 751 jQuery('.glp-lightbox .glp-img-detail .glp-shop-card_icon img').attr('src', icon); 752 jQuery('.glp-lightbox .glp-img-detail') 753 .removeClass('dark white') 754 .addClass(br + ' custom'); 755 copyCode(); 756 }); 757 } 758 759 function toggleOpenModal() { 760 let ele = $('.glp-js-open-popup'); 761 if (ele.length > 0) { 762 var idDataField = $('.gfield :input[value="glp-product-name"]').attr('id'); 763 $('.glp-js-open-popup a,.glp-js-open-popup').click(function (e) { 764 e.preventDefault(); 765 if (idDataField) { 766 var dataTitle = $(this).data('title-box'); 767 if (dataTitle !== undefined) { 768 $('#' + idDataField).val(dataTitle); 769 } else { 770 $('#' + idDataField).val(''); 771 } 772 } 773 774 $('body').css('overflow', 'hidden'); 775 $('.glp-layer-mask').fadeIn(300); 776 }); 777 $('.glp-layer-mask .form-wrapper .glp-btn').click(function () { 778 var checkrequire = true; 779 $('.glp-form-input').each(function () { 780 if ($(this).val().length) { 781 $(this).next('.message-error').css('display', 'none'); 782 } else { 783 checkrequire = false; 784 $(this).next('.message-error').css('display', 'block'); 785 } 786 }); 787 if (checkrequire) { 788 $('.glp-layer-mask .glp-forminput').fadeOut(300); 789 $('.glp-layer-mask .glp-thankyou').fadeIn(300); 790 } 791 }); 792 793 $('.glp-layer-mask .glp-lightbox .glp-close').click(function () { 794 var check = jQuery(this).data('delay'); 795 if (check > 0) { 796 $('.glp-layer-mask').fadeOut(check); 797 } else { 798 $('.glp-layer-mask').fadeOut(300); 799 } 800 $('body').css('overflow', 'auto'); 801 }); 802 } 803 } 804 805 function filterIstope() { 806 var glpFilter = $('.glp-filter'); 807 var $filter; 808 if (glpFilter.length > 0) { 809 $filter = glpFilter.find('.elementor-widget-wrap').isotope({ 810 itemSelector: '.elementor-widget', 811 }); 812 } 813 // bind filter button click 814 var filtersButtonLength = $('.filters-button').length; 815 816 if (filtersButtonLength > 0) { 817 $('.filters-button a').bind('click', function (e) { 818 e.preventDefault(); 819 setTimeout(function () { 820 let filterValue = ''; 821 filterValue = concatFilterValue(); 822 $filter.isotope({ 823 filter: filterValue, 824 layoutMode: 'fitRows', 825 }); 826 }, 0); 827 $('.glp-filter .elementor-widget-wrap, .glp-filter-label').show(); 828 /* Fix [DEV] MEX Hub Live Site Crawl Through 10.06.2020*/ 829 if ($(window).width() < 768) { 830 $('.glp-filter .elementor-widget-wrap').addClass('glp-show-list'); 831 } 832 /* End Fix [DEV] MEX Hub Live Site Crawl Through 10.06.2020*/ 833 }); 834 } 835 836 $('[data-select]').click(function () { 837 let _this = $(this); 838 let text_drop = _this.text(); 839 let value = $(this).data('value'); 840 841 _this.parents('.glp-text-select').find('.glp-text-drop').html(text_drop).data('value', value); 842 if (filtersButtonLength === 0) { 843 setTimeout(function () { 844 let filterValue = ''; 845 filterValue = concatFilterValue(); 846 $filter.isotope({ 847 filter: filterValue, 848 layoutMode: 'fitRows', 849 }); 850 }, 0); 851 $('.glp-filter .elementor-widget-wrap, .glp-filter-label').show(); 852 } 853 }); 854 } 855 856 function concatFilterValue() { 857 let newValue = ''; 858 $('.glp-text-select').each(function () { 859 let value = $('.glp-text-drop', this).data('value'); 860 if (value !== '') { 861 newValue = newValue + '-' + value; 862 } 863 }); 864 newValue = newValue.replace('-', '.'); 865 return newValue; 866 } 867 868 function checkShowCategory(check = 0) { 869 var count = 0, 870 fist_txt = ''; 871 872 if (jQuery('.glp-show-cat').hasClass('active')) { 873 $('.glp-category li').each(function () { 874 if (jQuery(this).hasClass('active')) { 875 count++; 876 if (fist_txt == '') { 877 fist_txt = jQuery(this).find('a').text(); 878 } 879 } 880 }); 881 jQuery('.glp-show-cat').removeClass('is_value1 is_value2'); 882 if (count > 1) { 883 jQuery('.glp-show-cat') 884 .html(count + ' categories') 885 .addClass('is_value2'); 886 } else if (count == 1) { 887 jQuery('.glp-show-cat') 888 .html(fist_txt + '<i class="fa fa-times" aria-hidden="true"></i>') 889 .addClass('is_value1'); 890 } else if (count == 0) { 891 jQuery('.glp-show-cat').html( 892 'Category <i class="fa fa-angle-down" aria-hidden="true"></i>', 893 ); 894 } 895 } else { 896 jQuery('.glp-show-cat').html('Category <i class="fa fa-angle-down" aria-hidden="true"></i>'); 897 } 898 899 if (jQuery('.glp-show-cat').hasClass('active') && check == 0) { 900 jQuery('.glp-show-cat').toggleClass('active'); 901 if ($(window).width() > 768) { 902 jQuery('.glp-category').slideToggle('slow'); 903 } else { 904 closePopup('.glp-category'); 905 } 906 } 907 } 908 909 function checkShowPayment(check = 0) { 910 var count = 0, 911 fist_txt = ''; 912
913 if (jQuery('.glp-show-pay').hasClass('active')) { 914 $('.glp-payment li').each(function () { 915 if (jQuery(this).hasClass('active')) { 916 count++; 917 if (fist_txt == '') { 918 fist_txt = jQuery(this).find('.glp-title').text(); 919 } 920 } 921 }); 922 jQuery('.glp-show-pay').removeClass('is_value1 is_value2'); 923 if (count > 1) { 924 jQuery('.glp-show-pay') 925 .html(count + ' types') 926 .addClass('is_value2'); 927 } else if (count == 1) { 928 jQuery('.glp-show-pay') 929 .html(fist_txt + '<i class="fa fa-times" aria-hidden="true"></i>') 930 .addClass('is_value1'); 931 } else if (count == 0) { 932 jQuery('.glp-show-pay').html( 933 'Payment type <i class="fa fa-angle-down" aria-hidden="true"></i>', 934 ); 935 } 936 } else { 937 jQuery('.glp-show-pay').html( 938 'Payment type <i class="fa fa-angle-down" aria-hidden="true"></i>', 939 ); 940 } 941 942 if (jQuery('.glp-show-pay').hasClass('active') && check == 0) { 943 jQuery('.glp-show-pay').toggleClass('active'); 944 if ($(window).width() > 768) { 945 jQuery('.glp-payment').slideToggle('slow'); 946 } else { 947 closePopup('.glp-payment'); 948 } 949 } 950 } 951 952 function setSortCategory() { 953 jQuery('.glp-show-cat').click(function (evemt) { 954 if (jQuery('.glp-show-pay').hasClass('active')) { 955 jQuery('.glp-show-pay').toggleClass('active'); 956 if ($(window).width() > 768) { 957 jQuery('.glp-payment').slideToggle('slow'); 958 } 959 } 960 if (jQuery(this).hasClass('active')) { 961 checkShowCategory(1); 962 } 963 964 jQuery(this).toggleClass('active'); 965 if ($(window).width() > 768) { 966 jQuery('.glp-category').slideToggle('slow'); 967 } else { 968 openPopup('.glp-category'); 969 } 970 }); 971 972 jQuery('.glp-category .glp-select').click(function (evemt) { 973 var check = jQuery(this).data('select'); 974 if (check == 0) { 975 $('.glp-category li').each(function () { 976 jQuery(this).addClass('active'); 977 }); 978 jQuery(this).text('Deselect all').data('select', 1); 979 } else { 980 $('.glp-category li').each(function () { 981 jQuery(this).removeClass('active'); 982 }); 983 jQuery(this).text('Select all').data('select', 0); 984 } 985 }); 986 987 jQuery('.glp-category li').click(function (evemt) { 988 if (jQuery(this).hasClass('active')) { 989 jQuery(this).removeClass('active'); 990 } else { 991 jQuery(this).addClass('active'); 992 } 993 994 var check = 0, 995 count = 0; 996 997 $('.glp-category li').each(function () { 998 count++; 999 if (jQuery(this).hasClass('active')) { 1000 check++; 1001 } 1002 }); 1003 if (count == check) { 1004 jQuery('.glp-category .glp-select').text('Deselect all').data('select', 1); 1005 } else { 1006 jQuery('.glp-category .glp-select').text('Select all').data('select', 0); 1007 } 1008 }); 1009 } 1010 1011 function setSortPayment() { 1012 jQuery('.glp-show-pay').click(function (evemt) { 1013 if (jQuery('.glp-show-cat').hasClass('active')) { 1014 jQuery('.glp-show-cat').toggleClass('active'); 1015 if ($(window).width() > 768) { 1016 jQuery('.glp-category').slideToggle('slow'); 1017 } 1018 } 1019 1020 if (jQuery(this).hasClass('active')) { 1021 checkShowPayment(1); 1022 } 1023 1024 jQuery(this).toggleClass('active'); 1025 1026 if ($(window).width() > 768) { 1027 jQuery('.glp-payment').slideToggle('slow'); 1028 } else { 1029 openPopup('.glp-payment'); 1030 } 1031 }); 1032 1033 jQuery('.glp-payment li').click(function (evemt) { 1034 if (jQuery(this).hasClass('active')) { 1035 jQuery(this).removeClass('active'); 1036 } else { 1037 jQuery(this).addClass('active'); 1038 } 1039 }); 1040 } 1041 1042 function loadLayoutItem() { 1043 if ($('.glp-list-item')[0]) { 1044 jQuery('.glp-list-item').data({ 1045 cat: 0, 1046 pay: 0, 1047 page: 1, 1048 pageall: 0, 1049 }); 1050 } 1051 1052 if ($('.glp-shop-card-payment')[0]) { 1053 $('.glp-payment li').each(function () { 1054 // var glp_title = jQuery(this).find('.glp-title').text(); 1055 // var glp_des = jQuery(this).find('.glp-des').text(); 1056 1057 jQuery('.glp-shop-card-payment-type li.img-' + jQuery(this).data('pay') + ' img').attr( 1058 'src', 1059 jQuery(this).data('img'), 1060 ); 1061 // jQuery('.glp-shop-card-payment-type li.img-' + jQuery(this).data('pay') + ' .tooltiptext .glp-title').html(glp_title); 1062 // jQuery('.glp-shop-card-payment-type li.img-' + jQuery(this).data('pay') + ' .tooltiptext .glp-des').html(glp_des); 1063 }); 1064 } 1065 } 1066 1067 function fixSerachBar() { 1068 if (jQuery('.glp-search-bar-shop').length) { 1069 var check_top = jQuery('.glp-search-bar-shop').offset().top; 1070 jQuery(window).on('scroll', function () { 1071 if (jQuery(window).scrollTop() > check_top) { 1072 jQuery('.glp-search-bar-shop').addClass('fixed'); 1073 } else { 1074 jQuery('.glp-search-bar-shop').removeClass('fixed'); 1075 } 1076 }); 1077 } 1078 } 1079 1080 function sliderShopCard() { 1081 if ($(window).width() < 768) { 1082 $('.glp-card-item .elementor-row').slick({ 1083 centerMode: true, 1084 centerPadding: '30px', 1085 slidesToShow: 1,
1086 arrows: false, 1087 autoplay: true, 1088 autoplaySpeed: 20000, 1089 dots: false, 1090 speed: 1000, 1091 infinite: true, 1092 asNavFor: '.glp-slider-dots', 1093 slidesToScroll: 1, 1094 }); 1095 $('.glp-slider-dots').slick({ 1096 infinite: true, 1097 slidesToShow: 3, 1098 slidesToScroll: 1, 1099 asNavFor: '.glp-card-item .elementor-row', 1100 arrows: false, 1101 dots: false, 1102 centerMode: true, 1103 focusOnSelect: true, 1104 centerPadding: '0px', 1105 }); 1106 } 1107 } 1108 1109 // search and find item 1110 1111 function resetFilter() { 1112 jQuery('.glp-reset-filter').click(function (evemt) { 1113 jQuery(this).hide(); 1114 jQuery('.not-found-item').hide(); 1115 jQuery('.glp-item-card').removeClass('hide show show_t').css('display', ''); 1116 jQuery('.glp-payment li').removeClass('active'); 1117 jQuery('.glp-category li').removeClass('active'); 1118 $('.glp-note').hide(); 1119 jQuery('.glp-list-item').data({ pay: 0, cat: 0 }); 1120 jQuery('.glp-show-pay') 1121 .html('Payment type <i class="fa fa-angle-down" aria-hidden="true"></i>') 1122 .removeClass('is_value1 is_value2'); 1123 jQuery('.glp-show-cat') 1124 .html('Category <i class="fa fa-angle-down" aria-hidden="true"></i>') 1125 .removeClass('is_value1 is_value2'); 1126 pagination(); 1127 }); 1128 } 1129 1130 function countItem() { 1131 var count = 0; 1132 jQuery('.not-found-item').hide(); 1133 1134 $('.glp-item-card').each(function () { 1135 if (jQuery(this).hasClass('show')) { 1136 count++; 1137 } 1138 }); 1139 if (count > 0) { 1140 $('.glp-note').show().delay(3000).hide(0); 1141 jQuery('.not-found-item').hide(); 1142 $('.glp-note span').html(count); 1143 } else { 1144 $('.glp-note').hide(); 1145 jQuery('.not-found-item').show(); 1146 } 1147 } 1148 1149 function checkSearch(type, number) { 1150 jQuery('.glp-list-item').data(type, number); 1151 jQuery('#glp-search').val(''); 1152 jQuery('.glp-item-card').css('display', ''); 1153 jQuery('.glp-fist-txt,.glp-clear-search').hide(); 1154 } 1155 1156 function searchTitle() { 1157 if ($(window).width() < 768) { 1158 $('.glp-search-bar-shop').on('click', function (e) { 1159 if (e.target !== this) return; 1160 jQuery('#glp-search').focus(); 1161 }); 1162 } 1163 1164 $('.glp-note').hide(); 1165 $('#glp-search').keyup(function () { 1166 searchItemList(); 1167 }); 1168 } 1169 1170 function searchItemList(filter = '') { 1171 jQuery('.glp-item-card').removeClass('hide show_t'); 1172 var input, filter, ul, li, a, i, txtValue; 1173 var check_cat = jQuery('.glp-list-item ').data('cat'); 1174 var check_pay = jQuery('.glp-list-item').data('pay'); 1175 1176 if (filter == '') { 1177 input = document.getElementById('glp-search'); 1178 filter = input.value.toUpperCase(); 1179 } 1180 if (filter.length > 0) { 1181 $('.glp-clear-search').show(); 1182 $('.glp-note').show().delay(3000).hide(0); 1183 } else { 1184 if (check_cat > 0 || check_pay > 0) { 1185 jQuery('.glp-apply').click(); 1186 } else { 1187 $('.glp-note').hide(); 1188 } 1189 jQuery('.glp-clear-search,.glp-fist-txt').hide(); 1190 } 1191 ul = document.getElementById('glp-list-item'); 1192 li = ul.getElementsByClassName('glp-item-card'); 1193 var count = 0; 1194 var text_top = ''; 1195 for (i = 0; i < li.length; i++) { 1196 a = li[i].getElementsByClassName('glp-shop-card_title')[0]; 1197 txtValue = a.textContent || a.innerText; 1198 1199 if (check_cat > 0 || check_pay > 0) { 1200 if ( 1201 txtValue.toUpperCase().lastIndexOf(filter, 0) > -1 && 1202 li[i].classList.contains('show') 1203 ) { 1204 if (text_top == '') { 1205 text_top = txtValue; 1206 } 1207 li[i].style.display = ''; 1208 li[i].classList.add('show_t'); 1209 count++; 1210 } else { 1211 li[i].style.display = 'none'; 1212 } 1213 } else { 1214 if (txtValue.toUpperCase().lastIndexOf(filter, 0) > -1) { 1215 if (text_top == '') { 1216 text_top = txtValue; 1217 } 1218 li[i].style.display = ''; 1219 li[i].classList.add('show_t'); 1220 count++; 1221 } else { 1222 li[i].style.display = 'none'; 1223 } 1224 } 1225 } 1226 if (text_top != '' && filter.length > 0) { 1227 jQuery('.glp-fist-txt').html(text_top).show(); 1228 // jQuery('.glp-clear-search').show(); 1229 } else { 1230 jQuery('.glp-fist-txt').hide(); 1231 } 1232 1233 if (count > 0) { 1234 $('.glp-note').show().delay(3000).hide(0); 1235 jQuery('.not-found-item').hide(); 1236 $('.glp-note span').html(count); 1237 } else { 1238 $('.glp-note').hide(); 1239 jQuery('.not-found-item').show(); 1240 } 1241 1242 if (filter.length == 0 && (check_cat == 0) & (check_pay == 0)) { 1243 $('.glp-note').hide(); 1244 jQuery('.glp-fist-txt').hide(); 1245 } 1246 pagination(check_cat, check_pay, 1); 1247 } 1248 1249 function cancelSearch() { 1250 jQuery('.glp-clear-search').click(function (evemt) { 1251 jQuery('#glp-search').val(''); 1252 jQuery('.glp-clear-search,.glp-fist-txt').hide(); 1253 var check_cat = jQuery('.glp-list-item').data('cat'); 1254 var check_pay = jQuery('.glp-list-item').data('pay'); 1255 1256 if (check_cat > 0 || check_pay > 0) { 1257 jQuery('.glp-apply').click(); 1258 } else { 1259 jQuery('.not-found-item').hide(); 1260 jQuery('.glp-item-card').removeClass('hide show').css('display', ''); 1261 jQuery('.glp-payment li').removeClass('active'); 1262 $('.glp-note').hide(); 1263 } 1264 pagination(check_cat, check_pay); 1265 }); 1266 1267 jQuery('.glp-cancel-pay').click(function (evemt) { 1268 var check_cat = jQuery('.glp-list-item').data('cat'); 1269 if (check_cat > 0) { 1270 jQuery('.not-found-item').hide(); 1271 jQuery('.glp-item-card').removeClass('hide show').addClass('hide'); 1272 jQuery('.glp-payment li').removeClass('active'); 1273 $('.glp-note').hide(); 1274 checkSearch('pay', 0); 1275 searchCategory(); 1276 } else { 1277 jQuery('.not-found-item').hide(); 1278 jQuery('.glp-item-card').removeClass('hide show'); 1279 jQuery('.glp-payment li').removeClass('active'); 1280 $('.glp-note').hide(); 1281 checkSearch('pay', 0); 1282 jQuery('.glp-reset-filter').hide(); 1283 } 1284 checkShowPayment(); 1285 pagination(check_cat, 0); 1286 if ($(window).width() <= 768) { 1287 closePopup('.glp-payment'); 1288 } 1289 }); 1290 1291 jQuery('.glp-cancel-cat').click(function (evemt) { 1292 var check_pay = jQuery('.glp-list-item').data('pay'); 1293 if (check_pay > 0) { 1294 jQuery('.not-found-item').hide(); 1295 jQuery('.glp-item-card').removeClass('hide show').addClass('hide'); 1296 jQuery('.glp-category li').removeClass('active'); 1297 $('.glp-note').hide(); 1298 checkSearch('cat', 0); 1299 searchPay(); 1300 } else { 1301 jQuery('.not-found-item').hide(); 1302 jQuery('.glp-item-card').removeClass('hide show'); 1303 jQuery('.glp-category li').removeClass('active'); 1304 $('.glp-note').hide(); 1305 checkSearch('cat', 0); 1306 jQuery('.glp-reset-filter').hide(); 1307 } 1308 checkShowCategory(); 1309 pagination(0, check_pay); 1310 if ($(window).width() <= 768) { 1311 closePopup('.glp-payment'); 1312 } 1313 }); 1314 } 1315 1316 function searchPay() { 1317 $('.glp-payment li').each(function () { 1318 if (jQuery(this).hasClass('active')) { 1319 var show = jQuery(this).data('pay'); 1320 $('.glp-item-card').each(function () { 1321 var result = jQuery(this).find('.glp-shop-card-item').data('pay').split(','); 1322 if (jQuery.inArray(show, result) !== -1) { 1323 jQuery(this).addClass('show').removeClass('hide'); 1324 } 1325 }); 1326 } 1327 }); 1328 countItem(); 1329 } 1330 1331 function searchCategory() { 1332 $('.glp-category li').each(function () { 1333 if (jQuery(this).hasClass('active')) { 1334 var show = jQuery(this).data('cat'); 1335 $('.glp-item-card').each(function () { 1336 var result = jQuery(this).find('.glp-shop-card-item').data('cat').split(','); 1337 if (jQuery.inArray(show, result) !== -1) { 1338 jQuery(this).addClass('show').removeClass('hide'); 1339 } 1340 }); 1341 } 1342 }); 1343 countItem(); 1344 } 1345
1346 function searchAll() { 1347 $('.glp-payment li').each(function () { 1348 if (jQuery(this).hasClass('active')) { 1349 var show_pay = jQuery(this).data('pay'); 1350 $('.glp-category li').each(function () { 1351 if (jQuery(this).hasClass('active')) { 1352 var show_cat = jQuery(this).data('cat'); 1353 $('.glp-item-card').each(function () { 1354 var result_pay = jQuery(this).find('.glp-shop-card-item').data('pay').split(','); 1355 var result_cat = jQuery(this).find('.glp-shop-card-item').data('cat').split(','); 1356 if ( 1357 jQuery.inArray(show_pay, result_pay) !== -1 && 1358 jQuery.inArray(show_cat, result_cat) !== -1 1359 ) { 1360 jQuery(this).addClass('show').removeClass('hide'); 1361 } 1362 }); 1363 } 1364 }); 1365 } 1366 }); 1367 countItem(); 1368 } 1369 1370 function setActiveSearch() { 1371 jQuery('.glp-apply-cat').click(function (evemt) { 1372 var check_chose = 0; 1373 $('.glp-category li').each(function () { 1374 if (jQuery(this).hasClass('active')) { 1375 check_chose++; 1376 } 1377 }); 1378 if (check_chose > 0) { 1379 checkSearch('cat', 1); 1380 } 1381 checkShowCategory(); 1382 }); 1383 1384 jQuery('.glp-apply-pay').click(function (evemt) { 1385 var check_chose = 0; 1386 $('.glp-payment li').each(function () { 1387 if (jQuery(this).hasClass('active')) { 1388 check_chose++; 1389 } 1390 }); 1391 if (check_chose > 0) { 1392 checkSearch('pay', 1); 1393 } 1394 checkShowPayment(); 1395 }); 1396 } 1397 1398 function searchItem() { 1399 jQuery('.glp-apply').click(function (evemt) { 1400 var check_cat = jQuery('.glp-list-item').data('cat'); 1401 var check_pay = jQuery('.glp-list-item').data('pay'); 1402 1403 if (check_cat > 0 || check_pay > 0) { 1404 jQuery('.not-found-item').hide(); 1405 jQuery('.glp-item-card').removeClass('show').addClass('hide'); 1406 jQuery('.glp-reset-filter').show(); 1407 } 1408 1409 if (check_cat == 0 && check_pay == 0) { 1410 jQuery('.glp-reset-filter').hide(); 1411 } 1412 1413 if (check_cat > 0 && check_pay > 0) { 1414 searchAll(); 1415 } else if (check_pay > 0) { 1416 searchPay(); 1417 } else if (check_cat > 0) { 1418 searchCategory(); 1419 } 1420 pagination(check_cat, check_pay); 1421 }); 1422 } 1423 1424 function pagination(check_cat = 0, check_pay = 0, custom = 0) { 1425 if (!check_cat && !check_pay) { 1426 var check_cat = jQuery('.glp-list-item').data('cat'); 1427 var check_pay = jQuery('.glp-list-item').data('pay'); 1428 } 1429 1430 var page = 1, 1431 count = 1; 1432 1433 jQuery('.glp-item-card').removeClass(function (index, className) { 1434 return (className.match(/(^|\s)page-\S+/g) || []).join(' '); 1435 }); 1436 if (check_cat > 0 || check_pay > 0) { 1437 var get_list = custom == 1 ? '.glp-item-card.show_t' : '.glp-item-card.show'; 1438 $(get_list).each(function () { 1439 if (count == 13) { 1440 count = 2; 1441 page++; 1442 } else { 1443 count++; 1444 } 1445 jQuery(this).addClass('page-' + page); 1446 1447 for (i = 1; i <= page; i++) { 1448 if (i == 1) { 1449 jQuery('.page-' + i).addClass('show'); 1450 } else { 1451 jQuery('.page-' + i).addClass('hide'); 1452 } 1453 } 1454 }); 1455 } else { 1456 var get_list = custom == 1 ? '.glp-item-card.show_t' : '.glp-item-card'; 1457 1458 $(get_list).each(function () { 1459 if (count == 13) { 1460 count = 2; 1461 page++; 1462 } else { 1463 count++; 1464 } 1465 jQuery(this).addClass('page-' + page); 1466 }); 1467 1468 for (i = 1; i <= page; i++) { 1469 if (i > 1) { 1470 jQuery('.page-' + i).addClass('hide'); 1471 } 1472 } 1473 } 1474 1475 jQuery('.page-1').removeClass('hide'); 1476 1477 if (page > 1) { 1478 jQuery('.glp-load-more').show(); 1479 } else { 1480 jQuery('.glp-load-more').hide(); 1481 } 1482 1483 jQuery('.glp-list-item').data('page', 1); 1484 jQuery('.glp-list-item').data('pageall', page); 1485 } 1486 1487 function loadMore() { 1488 jQuery('.glp-load-more .load-more').click(function (evemt) { 1489 var page = jQuery('.glp-list-item').data('page'); 1490 var pageall = jQuery('.glp-list-item').data('pageall'); 1491 var next_page = page + 1; 1492 jQuery('.page-' + next_page).removeClass('hide'); 1493 jQuery('.glp-list-item').data('page', next_page); 1494 1495 if (next_page == pageall) { 1496 jQuery('.glp-load-more').hide(); 1497 } 1498 }); 1499 } 1500 1501 function closePopup(box) { 1502 $('body').css('overflow', 'auto'); 1503 $(box).removeClass('glp-lightbox').hide(); 1504 $('.glp-layer-mask-filter').fadeOut(500); 1505 jQuery('.glp-search-bar-shop').removeClass('popup'); 1506 } 1507 1508 function openPopup(box) { 1509 $('body').css('overflow', 'hidden'); 1510 $('.glp-layer-mask-filter').fadeIn(300); 1511 $(box).addClass('glp-lightbox').fadeIn(300); 1512 jQuery('.glp-search-bar-shop').addClass('popup'); 1513 } 1514 1515 // search and find item 1516})(); 1517 1518jQuery(document).ready(function () { 1519 copyCode(); 1520 testimonialTabs(); 1521 1522 /****************************** 1523 ***** Functions built in ***** 1524 ******************************/ 1525}); 1526 1527function copyCode() { 1528 jQuery('.glp-content a').click(function (evemt) { 1529 event.preventDefault(); 1530 var code = jQuery(this).text(); 1531 var $temp = jQuery('<input>'); 1532 jQuery('body').append($temp); 1533 $temp.val(code).select(); 1534 document.execCommand('copy'); 1535 $temp.remove(); 1536 1537 if (jQuery(window).width() <= 650) { 1538 var height = jQuery('.glp-lightbox').outerHeight(); 1539 jQuery('head').append( 1540 '<style type="text/css">.glp-detail-shop:before {bottom:' + (height + 30) + 'px;}</style>', 1541 ); 1542 } 1543 1544 jQuery('.glp-detail-shop').addClass('glp-copy'); 1545 setTimeout(function () { 1546 jQuery('.glp-detail-shop').removeClass('glp-copy'); 1547 }, 2000); 1548 }); 1549} 1550 1551function testimonialTabs() { 1552 jQuery('#glp-testimonial-tabs li').on('click', function () { 1553 jQuery('.glp-testimonial-tabs .tab_content').hide(); 1554 var activeTab = jQuery(this).data('rel'); 1555 jQuery('.glp-testimonial-tabs #' + activeTab).fadeIn(); 1556 1557 jQuery('#testimonial ul.tabs li').removeClass('active'); 1558 jQuery(this).addClass('active'); 1559 1560 jQuery('#testimonial .tab_drawer_heading').removeClass('d_active'); 1561 jQuery("#testimonial .tab_drawer_heading[rel^='" + activeTab + "']").addClass('d_active'); 1562 1563 // update the carousel loop; 1564 var tabID = $(this).attr('rel'); 1565 // var caroId = $("#testimonial .carousel").attr('id'); 1566 $('.glp-testimonial-tabs #' + tabID + ' .carousel').carousel(0); 1567 }); 1568 1569 var hash = window.location.hash; 1570 1571 if (hash == '#tab2') { 1572 jQuery('.glp-testimonial-tabs .tab_content').hide(); 1573 var activeTab = 'tab2'; 1574 jQuery('.glp-testimonial-tabs #' + activeTab).fadeIn(); 1575 1576 jQuery('#testimonial ul.tabs li').removeClass('active'); 1577 jQuery('#testimonial ul.tabs li.tab2').addClass('active'); 1578 1579 jQuery('#testimonial .tab_drawer_heading').removeClass('d_active'); 1580 jQuery("#testimonial .tab_drawer_heading[rel^='" + activeTab + "']").addClass('d_active'); 1581 1582 $('.glp-testimonial-tabs #' + activeTab + ' .carousel').carousel(0); 1583 } else { 1584 jQuery('.glp-testimonial-tabs .tab_content').hide(); 1585 jQuery('.glp-testimonial-tabs #tab1').fadeIn(); 1586 } 1587 1588 // change url by phone or pc 1589 if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { 1590 var url = 1591 'grabdriver://open?screenType=CONSENT&webviewUrl=https%3a%2f%2fapi.grab.com%2fgrabid%2fv1%2foauth2%2fgrablet%2fconfig%3fclient_id%3d52d11149470d4013837c812738c79804%26redirect_url%3dhttps%253a%252f%252fgateway.grab-sure.com%252fapi%252fuc%252foauth%252fcallback%253fpageUriAbbr%253dsg_ci_product--195931054958706689'; 1592 } else { 1593 var url = 'https://www.grab.com/sg/download/driver/'; 1594 } 1595 1596 jQuery('.glp-testimonial-tabs a').attr('href', url); 1597} 1598// Add lazy load scripts downloadPDF 1599// Load the library when the list report is added to the page 1600if ($('.glp-download-box')[0]) { 1601 $.when( 1602 $.getScript('/wp-content/plugins/grab-elementor/assets/lib/jszip.min.js'), 1603 $.getScript('/wp-content/plugins/grab-elementor/assets/lib/jszip-utils.js'), 1604 $.getScript('/wp-content/plugins/grab-elementor/assets/lib/FileSaver.min.js'), 1605 $.Deferred(function (deferred) { 1606 $(deferred.resolve); 1607 }), 1608 ).done(function () { 1609 // Auto run download when form submit done 1610 $(document).on('gform_confirmation_loaded', function (e, form_id) { 1611 zipFileReport(); 1612 }); 1613 1614 // Set active item on click 1615 jQuery('.glp-bloomberg-campaign li').click(function (evemt) { 1616 jQuery(this).toggleClass('active'); 1617 }); 1618 1619 // Call function download when click button 1620 // Use in case of direct download without filling form information 1621 jQuery('.glp-btn-download').click(function (event) { 1622 event.preventDefault(); 1623 zipFileReport(); 1624 }); 1625 1626 // Use in case of download in combination with form 1627 jQuery('.glp-download-box .glp-custom-btn a').click(function (event) { 1628 event.preventDefault(); 1629 var count = 0; 1630 1631 jQuery('.glp-bloomberg-campaign li').each(function () { 1632 if (jQuery(this).hasClass('active')) { 1633 count++; 1634 } 1635 }); 1636 1637 if (count == 0) { 1638 alert('Please select option'); 1639 return false;
1640 } else { 1641 $('.glp-download-box .gr-js-download-report').submit(); 1642 } 1643 }); 1644 1645 function zipFileReport() { 1646 var count = 0; 1647 var urls = []; 1648 1649 jQuery('.glp-bloomberg-campaign li').each(function () { 1650 if (jQuery(this).hasClass('active')) { 1651 count++; 1652 urls.push(jQuery(this).data('url')); 1653 } 1654 }); 1655 1656 if (count > 0) { 1657 var zip = new JSZip(); 1658 var count = 0; 1659 1660 var zipFilename = 'report-' + Date.now() + '.zip'; 1661 urls.forEach(function (url) { 1662 var filename = url.split('/').slice(-1).pop(); 1663 JSZipUtils.getBinaryContent(url, function (err, data) { 1664 if (err) { 1665 throw err; // or handle the error 1666 } 1667 1668 zip.file(filename, data, { binary: true }); 1669 count++; 1670 if (count == urls.length) { 1671 zip.generateAsync({ type: 'blob' }).then(function (blob) { 1672 saveAs(blob, zipFilename); 1673 }); 1674 } 1675 }); 1676 }); 1677 1678 // remove item select 1679 jQuery('.glp-bloomberg-campaign li').removeClass('active'); 1680 1681 // hide button download 1682 jQuery('.glp-download-box .glp-custom-btn a').hide(); 1683 return false; 1684 } else { 1685 alert('Please select option'); 1686 } 1687 } 1688 }); 1689} 1690/* Fix [DEV] MEX Hub Live Site Crawl Through 10.06.2020*/ 1691// What problem to solve: not active fist tab on mobile
1692// On which page: https://www.grab.com/sg/merchant/finance/hub/insights/ 1693// TODO: remove after switching to the new tabs component 1694$(window).bind('load', function () { 1695 var tabId = $('body.insights .custom-tab-heading').attr('id'); 1696 $('section#tabcontent-1').addClass('active'); 1697 $('#' + tabId + ' li').on('click', function () { 1698 var id = $(this).data('id'); 1699 $('#' + tabId + ' li').removeClass('active'); 1700 $(this).addClass('active'); 1701 $('section[id^="tabcontent-"]').removeClass('active'); 1702 $('.elementor-top-section#tabcontent-' + id).addClass('active'); 1703 }); 1704});
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.