1(function ($) { 2 'use strict'; 3 4 var martfury = martfury || {}; 5 6 martfury.init = function () { 7 martfury.$body = $(document.body), 8 martfury.$window = $(window), 9 martfury.$header = $('#masthead'); 10 11 this.journey(); 12 this.testimonialSlides(); 13 this.partnerCarousel(); 14 this.gmaps(); 15 16 // products of category 17 this.productsOfCategory(); 18 this.productsOfCategory2(); 19 20 // product tabs 21 this.productsTabs(); 22 23 // category Tabs 24 this.categoryTabs(); 25 26 // products carousel 27 this.productsCarousel(); 28 this.dealsOfDay(); 29 this.productDealsCarousel(); 30 31 this.topSelling(); 32 this.productsListCarousel(); 33 34 // product brand 35 this.brandsGrid(); 36 this.brandImagesCarousel(); 37 38 /*Couterup*/ 39 if ($.fn.counterUp) { 40 41 $('.martfury-counter .counter-value').counterUp(); 42 } 43 44 }; 45 46 47 martfury.journey = function () { 48 $('.martfury-journey').each(function () { 49 var $el = $(this), 50 $tabs = $el.find('ul li a'), 51 $first = $tabs.filter(':first'), 52 $content = $el.find('.journey-wrapper'), 53 width = $el.find('ul').width(), 54 num = $el.attr('data-number'), 55 space, pos, val; 56 57 if (num == 1) { 58 space = 0; 59 } else { 60 space = (width - 40) / (num - 1); 61 } 62 63 for (var i = 1; i <= num; i++) { 64 var $this = $('.journey-tab-' + i); 65 if (martfuryShortCode.direction === 'true') { 66 if ($this.hasClass('reverse')) { 67 pos = 'left'; 68 val = (i - num) * space * -1; 69 } else { 70 pos = 'right'; 71 val = (i - 1) * space; 72 } 73 } else { 74 if ($this.hasClass('reverse')) { 75 pos = 'right'; 76 val = (i - num) * space * -1; 77 } else { 78 pos = 'left'; 79 val = (i - 1) * space; 80 } 81 } 82 83 84 $this.css(pos, val + 15); 85 } 86 87 $first.addClass('active'); 88 $content.filter(':first').addClass('active'); 89 90 $tabs.on('click', function (e) { 91 e.preventDefault(); 92 93 var $this = $(this), 94 tab_id = $this.attr('data-tab'); 95 96 if ($this.hasClass('active')) { 97 return; 98 } 99 100 $tabs.removeClass('active'); 101 $content.removeClass('active'); 102 103 $this.addClass('active'); 104 $('#' + tab_id).addClass('active'); 105 }); 106 }); 107 }; 108 109 /** 110 * Init testimonial carousel 111 */ 112 martfury.testimonialSlides = function () { 113 if (martfuryShortCode.length === 0 || typeof martfuryShortCode.testimonial === 'undefined') { 114 return; 115 } 116 117 $.each(martfuryShortCode.testimonial, function (id, testimonialData) { 118 var $testimonial = $(document.getElementById(id)); 119 120 $testimonial.not('.slick-initialized').slick({ 121 rtl: (martfuryShortCode.direction === 'true'), 122 slidesToShow: 2, 123 infinite: testimonialData.autoplay, 124 arrows: testimonialData.nav, 125 prevArrow: '<div class="mf-left-arrow"><i class="icon-chevron-left"></i></div>', 126 nextArrow: '<div class="mf-right-arrow"><i class="icon-chevron-right"></i></div>', 127 autoplay: testimonialData.autoplay, 128 autoplaySpeed: testimonialData.autoplay_speed, 129 speed: 800, 130 dots: testimonialData.dot, 131 responsive: [ 132 { 133 breakpoint: 1200, 134 settings: {
135 arrows: false, 136 dots: true 137 } 138 }, 139 { 140 breakpoint: 768, 141 settings: { 142 arrows: false, 143 dots: true 144 } 145 }, 146 { 147 breakpoint: 480, 148 settings: { 149 slidesToShow: 1, 150 arrows: false, 151 dots: true 152 } 153 } 154 ] 155 }); 156 157 $testimonial.on('afterChange', function () { 158 martfury.lazyLoad($testimonial); 159 }); 160 }); 161 }; 162 163 martfury.partnerCarousel = function () { 164 $('.martfury-partner.carousel-type').each(function () { 165 var $this = $(this), 166 $items = $this.find('.list-item'), 167 columns = $this.data('columns'), 168 autoplay = $this.data('auto'), 169 autoplaySpeed = autoplay; 170 171 autoplay = parseInt(autoplaySpeed) > 0 ? true : false; 172 173 $items.not('.slick-initialized').slick({ 174 rtl: (martfuryShortCode.direction === 'true'), 175 slidesToShow: columns, 176 infinite: false, 177 arrows: false, 178 dots: false, 179 autoplay: autoplay, 180 autoplaySpeed: autoplaySpeed, 181 responsive: [ 182 { 183 breakpoint: 1200, 184 settings: { 185 slidesToShow: 4 186 } 187 }, 188 { 189 breakpoint: 768, 190 settings: { 191 slidesToShow: 3 192 } 193 }, 194 { 195 breakpoint: 480, 196 settings: { 197 slidesToShow: 2 198 } 199 } 200 ] 201 }); 202 }); 203 }; 204 205 martfury.productsOfCategory = function () { 206 if (martfuryShortCode.length === 0 || typeof martfuryShortCode.productsOfCategory === 'undefined') { 207 return; 208 } 209 $.each(martfuryShortCode.productsOfCategory, function (id, productsOfCategoryData) { 210 var $viewPort = $(document.getElementById(id)); 211 martfury.catBannerCarousel($viewPort.find('.images-list'), productsOfCategoryData); 212 }); 213 214 $(window).on('scroll', function () { 215 var offSet = 0; 216 217 $.each(martfuryShortCode.productsOfCategory, function (id, productsOfCategoryData) { 218 var $viewPort = $(document.getElementById(id)); 219 if (!$viewPort.hasClass('no-infinite')) { 220 if ($viewPort.is(':in-viewport(' + offSet + ')')) { 221 productsOfCatAjax($viewPort, productsOfCategoryData); 222 $viewPort.addClass('no-infinite'); 223 } 224 } 225 }); 226 227 228 }).trigger('scroll'); 229 230 function productsOfCatAjax($viewPort, productsOfCategoryData) { 231 232 var data = { 233 nonce: martfuryData.nonce, 234 params: productsOfCategoryData.params, 235 element: 'productsOfCat' 236 }, 237 ajax_url = martfuryShortCode.wc_ajax_url.toString().replace('%%endpoint%%', 'martfury_get_shortcode_ajax'); 238 239 $.post( 240 ajax_url, 241 data, 242 function (response) { 243 $viewPort.html(response.data); 244 martfury.lazyLoad($viewPort); 245 martfury.catBannerCarousel($viewPort.find('.images-list'), productsOfCategoryData); 246 $(document.body).trigger('martfury_get_products_ajax_success'); 247 } 248 ); 249 } 250 }; 251 252 martfury.productsOfCategory2 = function () { 253 if (martfuryShortCode.length === 0 || typeof martfuryShortCode.productsOfCategory2 === 'undefined') { 254 return; 255 } 256 $.each(martfuryShortCode.productsOfCategory2, function (id, productsOfCategoryData) { 257 var $viewPort = $(document.getElementById(id)); 258 martfury.catBannerCarousel($viewPort.find('.images-list'), productsOfCategoryData); 259 }); 260 261 $(window).on('scroll', function () { 262 var offSet = 0; 263 264 $.each(martfuryShortCode.productsOfCategory2, function (id, productsOfCategoryData) { 265 var $viewPort = $(document.getElementById(id)); 266 if (!$viewPort.hasClass('no-infinite')) { 267 if ($viewPort.is(':in-viewport(' + offSet + ')')) { 268 productsOfCatAjax($viewPort, productsOfCategoryData); 269 $viewPort.addClass('no-infinite'); 270 } 271 } 272 }); 273 274 275 }).trigger('scroll'); 276 277 function productsOfCatAjax($viewPort, productsOfCategoryData) { 278 var data = { 279 nonce: martfuryData.nonce, 280 params: productsOfCategoryData.params, 281 element: 'productsOfCat2' 282 }, 283 ajax_url = martfuryShortCode.wc_ajax_url.toString().replace('%%endpoint%%', 'martfury_get_shortcode_ajax'); 284 285 $.post( 286 ajax_url, 287 data, 288 function (response) { 289 $viewPort.html(response.data); 290 martfury.lazyLoad($viewPort); 291 martfury.catBannerCarousel($viewPort.find('.images-list'), productsOfCategoryData); 292 martfury.getproductsCarousel($viewPort.find('.mf-products-tabs'), productsOfCategoryData); 293 martfury.productTabsActive($viewPort); 294 $(document.body).trigger('martfury_get_products_ajax_success'); 295 } 296 ); 297 } 298 299 }; 300 301 martfury.productTabsActive = function ($viewPort) { 302 $viewPort.find('.tabs-nav').on('click', 'a', function (e) { 303 e.preventDefault(); 304 var $this = $(this), 305 currentTab = $this.data('href'); 306 307 if ($this.hasClass('active')) { 308 return; 309 } 310 311 $viewPort.find('.tabs-nav a').removeClass('active'); 312 $this.addClass('active'); 313 $viewPort.find('.tabs-panel').removeClass('active'); 314 $viewPort.find('.tabs-' + currentTab).addClass('active'); 315 }); 316 } 317 318 martfury.catBannerCarousel = function ($id, productsOfCategoryData) { 319 $id.not('.slick-initialized').slick({ 320 rtl: (martfuryShortCode.direction === 'true'), 321 slidesToShow: 1, 322 arrows: productsOfCategoryData.navigation, 323 prevArrow: '<span class="icon-chevron-left slick-prev-arrow"></span>', 324 nextArrow: '<span class="icon-chevron-right slick-next-arrow"></span>', 325 infinite: productsOfCategoryData.infinite, 326 autoplay: productsOfCategoryData.autoplay, 327 autoplaySpeed: productsOfCategoryData.autoplay_speed, 328 dots: productsOfCategoryData.pagination 329 }); 330 331 $id.on('afterChange', function () { 332 martfury.lazyLoad($id); 333 }); 334 }; 335 336 /** 337 * Products Tabs 338 */ 339 martfury.productsTabs = function () { 340 if (martfuryShortCode.length === 0 || typeof martfuryShortCode.productsTabs === 'undefined') { 341 return; 342 } 343 344 $.each(martfuryShortCode.productsTabs, function (id, productsTabsData) { 345 var $viewPort = $(document.getElementById(id)); 346 martfury.getproductsCarousel($viewPort, productsTabsData); 347 348 $viewPort.find('.tabs-nav').on('click', 'a', function (e) { 349 e.preventDefault(); 350 var $this = $(this), 351 currentTab = $this.data('href'), 352 $currentEl = $this.closest('.mf-products-tabs'); 353 354 if ($this.hasClass('active')) { 355 return; 356 } 357 358 $viewPort.find('.tabs-nav a').removeClass('active'); 359 $this.addClass('active'); 360 $viewPort.find('.tabs-panel').removeClass('active'); 361 $viewPort.find('.tabs-' + currentTab).addClass('active'); 362 363 getProductsAJAXHandler($this, $currentEl, productsTabsData); 364 }); 365 }); 366 367 $(window).on('scroll', function () { 368 var offSet = 0; 369 370 $.each(martfuryShortCode.productsTabs, function (id, productsTabsData) { 371 var $viewPort = $(document.getElementById(id)); 372 if (!$viewPort.hasClass('no-infinite')) { 373 if ($viewPort.is(':in-viewport(' + offSet + ')')) { 374 productsTabsAjax($viewPort, productsTabsData); 375 $viewPort.addClass('no-infinite'); 376 } 377 } 378 }); 379 380 381 }).trigger('scroll'); 382 383 function productsTabsAjax($viewPort, productsTabsData) { 384 var data = { 385 nonce: martfuryData.nonce, 386 params: productsTabsData.params, 387 element: 'productTabs' 388 }, 389 ajax_url = martfuryShortCode.wc_ajax_url.toString().replace('%%endpoint%%', 'martfury_get_shortcode_ajax'); 390 391 $.post( 392 ajax_url, 393 data, 394 function (response) { 395 $viewPort.find('.tabs-content').html(response.data); 396 martfury.lazyLoad($viewPort); 397 martfury.getproductsCarousel($viewPort, productsTabsData); 398 $(document.body).trigger('martfury_get_products_ajax_success'); 399 } 400 ); 401 } 402 403 function getProductsAJAXHandler($el, $tabs, productsTabsData) { 404 405 var tab = $el.data('href'), 406 $content = $tabs.find('.tabs-' + tab); 407 408 if ($content.hasClass('tab-loaded')) { 409 return; 410 } 411 412 var data = { 413 'columns': productsTabsData.pro_columns, 414 'products': tab, 415 'per_page': productsTabsData.per_page, 416 'product_cats': productsTabsData.pro_cats, 417 }, 418 ajax_url = martfuryShortCode.wc_ajax_url.toString().replace('%%endpoint%%', 'mf_wpbakery_load_products'); 419 420 $.post( 421 ajax_url, 422 data, 423 function (response) { 424 if (!response) { 425 return; 426 } 427 $content.html(response.data); 428 martfury.lazyLoad($content); 429 martfury.getproductsCarousel($content, productsTabsData); 430 $content.addClass('tab-loaded'); 431 } 432 ); 433 }; 434 435 436 }; 437 438 /** 439 * Products carousel
440 */ 441 martfury.productsCarousel = function () { 442 if (martfuryShortCode.length === 0 || typeof martfuryShortCode.productsCarousel === 'undefined') { 443 return; 444 } 445 446 $.each(martfuryShortCode.productsCarousel, function (id, productsData) { 447 var $viewPort = $(document.getElementById(id)); 448 martfury.getproductsCarousel($viewPort, productsData); 449 }); 450 451 $(window).on('scroll', function () { 452 var offSet = 0; 453 454 $.each(martfuryShortCode.productsCarousel, function (id, productsData) { 455 var $viewPort = $(document.getElementById(id)); 456 if (!$viewPort.hasClass('no-infinite')) { 457 if ($viewPort.is(':in-viewport(' + offSet + ')')) { 458 productsCarouselAjax($viewPort, productsData); 459 $viewPort.addClass('no-infinite'); 460 } 461 } 462 }); 463 464 465 }).trigger('scroll'); 466 467 function productsCarouselAjax($viewPort, productsData) { 468 var data = { 469 nonce: martfuryData.nonce, 470 params: productsData.params, 471 element: 'productsCarousel' 472 }, 473 ajax_url = martfuryShortCode.wc_ajax_url.toString().replace('%%endpoint%%', 'martfury_get_shortcode_ajax'); 474 475 $.post( 476 ajax_url, 477 data, 478 function (response) { 479 $viewPort.html(response.data); 480 martfury.lazyLoad($viewPort); 481 martfury.getproductsCarousel($viewPort, productsData); 482 $(document.body).trigger('martfury_get_products_ajax_success'); 483 } 484 ); 485 } 486 487 488 }; 489 490 /** 491 * Products carousel 492 */ 493 martfury.dealsOfDay = function () { 494 if (martfuryShortCode.length === 0 || typeof martfuryShortCode.DealsOfDay === 'undefined') { 495 return; 496 } 497 498 $.each(martfuryShortCode.DealsOfDay, function (id, productsData) { 499 var $viewPort = $(document.getElementById(id)); 500 $viewPort.find('ul.products').not('.slick-initialized').slick({ 501 rtl: (martfuryShortCode.direction === 'true'), 502 slidesToShow: productsData.pro_columns, 503 slidesToScroll: productsData.pro_columns, 504 arrows: productsData.pro_navigation, 505 dots: productsData.pro_navigation, 506 infinite: productsData.pro_infinite, 507 prevArrow: '<span class="icon-chevron-left slick-prev-arrow"></span>', 508 nextArrow: '<span class="icon-chevron-right slick-next-arrow"></span>', 509 autoplay: productsData.pro_autoplay, 510 autoplaySpeed: productsData.pro_autoplay_speed, 511 responsive: [ 512 { 513 breakpoint: 1366, 514 settings: { 515 slidesToShow: parseInt(productsData.pro_columns) > 5 ? 5 : productsData.pro_columns, 516 slidesToScroll: parseInt(productsData.pro_columns) > 5 ? 5 : productsData.pro_columns 517 } 518 }, 519 { 520 breakpoint: 1200, 521 settings: { 522 slidesToShow: parseInt(productsData.pro_columns) > 4 ? 4 : productsData.pro_columns, 523 slidesToScroll: parseInt(productsData.pro_columns) > 4 ? 4 : productsData.pro_columns 524 } 525 }, 526 { 527 breakpoint: 992, 528 settings: { 529 slidesToShow: 3, 530 slidesToScroll: 3 531 } 532 }, 533 { 534 breakpoint: 767, 535 settings: { 536 slidesToShow: 2, 537 slidesToScroll: 2 538 } 539 } 540 ] 541 }); 542 543 $viewPort.on('afterChange', function () { 544 martfury.lazyLoad($viewPort); 545 }); 546 }); 547 }; 548 549 550 /** 551 * Products carousel
552 */ 553 martfury.productDealsCarousel = function () { 554 if (martfuryShortCode.length === 0 || typeof martfuryShortCode.productDealsCarousel === 'undefined') { 555 return; 556 } 557 558 $.each(martfuryShortCode.productDealsCarousel, function (id, productsData) { 559 var $viewPort = $(document.getElementById(id)); 560 $viewPort.find('.products').not('.slick-initialized').slick({ 561 rtl: (martfuryShortCode.direction === 'true'), 562 slidesToShow: productsData.pro_columns, 563 slidesToScroll: productsData.pro_columns, 564 arrows: productsData.pro_navigation, 565 infinite: productsData.pro_infinite, 566 prevArrow: $viewPort.find('.slick-prev-arrow'), 567 nextArrow: $viewPort.find('.slick-next-arrow'), 568 autoplay: productsData.pro_autoplay, 569 autoplaySpeed: productsData.pro_autoplay_speed 570 }); 571 572 $viewPort.find('.woocommerce-product-gallery__image').on('click', function () { 573 var href = $(this).closest('div.product').find('.product-title > a').attr('href'); 574 575 location.href = href; 576 return false; 577 }); 578 579 $viewPort.on('afterChange', function () { 580 martfury.lazyLoad($viewPort); 581 }); 582 }); 583 584 }; 585 586 /** 587 * Top Selling Products 588 */ 589 martfury.topSelling = function () { 590 if (martfuryShortCode.length === 0 || typeof martfuryShortCode.topSelling === 'undefined') { 591 return; 592 } 593 594 $.each(martfuryShortCode.topSelling, function (id, productsData) { 595 var $viewPort = $(document.getElementById(id)); 596 martfury.getproductsCarousel($viewPort, productsData); 597 }); 598 599 $(window).on('scroll', function () { 600 var offSet = 0; 601 602 $.each(martfuryShortCode.topSelling, function (id, productsData) { 603 var $viewPort = $(document.getElementById(id)); 604 if (!$viewPort.hasClass('no-infinite')) { 605 if ($viewPort.is(':in-viewport(' + offSet + ')')) { 606 productsCarouselAjax($viewPort, productsData); 607 $viewPort.addClass('no-infinite'); 608 } 609 } 610 611 }); 612 613 614 }).trigger('scroll'); 615 616 function productsCarouselAjax($viewPort, productsData) { 617 var data = { 618 nonce: martfuryData.nonce, 619 params: productsData.params, 620 element: 'topSelling' 621 }, 622 ajax_url = martfuryShortCode.wc_ajax_url.toString().replace('%%endpoint%%', 'martfury_get_shortcode_ajax'); 623 624 $.post( 625 ajax_url, 626 data, 627 function (response) { 628 $viewPort.html(response.data); 629 martfury.lazyLoad($viewPort); 630 martfury.getproductsCarousel($viewPort, productsData); 631 $(document.body).trigger('martfury_get_products_ajax_success'); 632 } 633 ); 634 } 635 636 637 }; 638 639 /** 640 * Top Selling Products 641 */ 642 martfury.productsListCarousel = function () { 643 if (martfuryShortCode.length === 0 || typeof martfuryShortCode.productsListCarousel === 'undefined') { 644 return; 645 } 646 647 $.each(martfuryShortCode.productsListCarousel, function (id, productsData) { 648 var $viewPort = $(document.getElementById(id)); 649 $viewPort.find('ul.products').not('.slick-initialized').slick({ 650 rtl: (martfuryShortCode.direction === 'true'), 651 slidesToShow: 1, 652 slidesToScroll: 1, 653 arrows: false, 654 dots: productsData.dots, 655 infinite: productsData.infinite, 656 autoplay: productsData.autoplay, 657 autoplaySpeed: productsData.autoplay_speed 658 }); 659 660 $viewPort.on('afterChange', function () { 661 martfury.lazyLoad($viewPort); 662 }); 663 }); 664 665 }; 666 667 martfury.getproductsCarousel = function ($id, productsData) { 668 $id.find('ul.products').not('.slick-initialized').slick({ 669 rtl: (martfuryShortCode.direction === 'true'), 670 slidesToShow: productsData.pro_columns, 671 slidesToScroll: productsData.pro_columns, 672 arrows: productsData.pro_navigation, 673 dots: productsData.pro_navigation, 674 infinite: productsData.pro_infinite, 675 prevArrow: '<span class="icon-chevron-left slick-prev-arrow"></span>', 676 nextArrow: '<span class="icon-chevron-right slick-next-arrow"></span>', 677 autoplay: productsData.pro_autoplay, 678 autoplaySpeed: productsData.pro_autoplay_speed, 679 responsive: [ 680 { 681 breakpoint: 1600, 682 settings: { 683 slidesToShow: parseInt(productsData.pro_columns) > 6 ? 6 : productsData.pro_columns, 684 slidesToScroll: parseInt(productsData.pro_columns) > 6 ? 6 : productsData.pro_columns 685 } 686 }, 687 { 688 breakpoint: 1366, 689 settings: { 690 slidesToShow: parseInt(productsData.pro_columns) > 5 ? 5 : productsData.pro_columns, 691 slidesToScroll: parseInt(productsData.pro_columns) > 5 ? 5 : productsData.pro_columns 692 } 693 }, 694 { 695 breakpoint: 1200, 696 settings: { 697 slidesToShow: parseInt(productsData.pro_columns) > 4 ? 4 : productsData.pro_columns, 698 slidesToScroll: parseInt(productsData.pro_columns) > 4 ? 4 : productsData.pro_columns 699 } 700 }, 701 { 702 breakpoint: 992, 703 settings: { 704 slidesToShow: 3, 705 slidesToScroll: 3 706 } 707 }, 708 { 709 breakpoint: 767, 710 settings: { 711 slidesToShow: 2, 712 slidesToScroll: 2 713 } 714 } 715 ] 716 }); 717 718 $id.on('afterChange', function () { 719 martfury.lazyLoad($id); 720 }); 721 }; 722 723 /** 724 * Category Tabs 725 */ 726 martfury.categoryTabs = function () {
727 var $tabs = $('.mf-category-tabs'); 728 if ($tabs.length < 1) { 729 return; 730 } 731 732 $tabs.find('ul.tabs-nav').not('.slick-initialized').slick({ 733 rtl: (martfuryShortCode.direction === 'true'), 734 slidesToShow: 8, 735 infinite: false, 736 prevArrow: '<span class="icon-chevron-left slick-prev-arrow"></span>', 737 nextArrow: '<span class="icon-chevron-right slick-next-arrow"></span>', 738 responsive: [ 739 { 740 breakpoint: 1200, 741 settings: { 742 slidesToShow: 6, 743 slidesToScroll: 6 744 } 745 }, 746 { 747 breakpoint: 992, 748 settings: { 749 slidesToShow: 4, 750 slidesToScroll: 4 751 } 752 }, 753 { 754 breakpoint: 480, 755 settings: { 756 slidesToShow: 2, 757 slidesToScroll: 2 758 } 759 } 760 ] 761 }); 762 }; 763 764 /** 765 * LazyLoad 766 */ 767 martfury.lazyLoad = function ($els) { 768 $els.find('img.lazy').lazyload({ 769 load: function () { 770 $(this).removeClass('lazy'); 771 } 772 }).trigger('appear'); 773 }; 774 775 776 /** 777 * Init Google maps 778 */ 779 martfury.gmaps = function () { 780 781 if (martfuryShortCode.length === 0 || typeof martfuryShortCode.map === 'undefined') { 782 return; 783 } 784 785 var mapOptions = { 786 scrollwheel: false, 787 draggable: true, 788 zoom: 10, 789 mapTypeId: google.maps.MapTypeId.ROADMAP, 790 panControl: false, 791 zoomControl: true, 792 zoomControlOptions: { 793 style: google.maps.ZoomControlStyle.SMALL 794 }, 795 scaleControl: false, 796 streetViewControl: false 797 798 }, 799 customMap; 800 801 var bounds = new google.maps.LatLngBounds(); 802 var infoWindow = new google.maps.InfoWindow(); 803 804 805 $.each(martfuryShortCode.map, function (id, mapData) { 806 var map_color = mapData.map_color, 807 road_highway_color = mapData.road_highway_color; 808 809 var styles = 810 [ 811 { 812 'featureType': 'administrative', 813 'elementType': 'labels.text.fill', 814 'stylers': [{'color': '#444444'}] 815 }, 816 { 817 'featureType': 'landscape', 818 'elementType': 'all', 819 'stylers': [{'color': '#f2f2f2'}] 820 }, 821 { 822 'featureType': 'landscape', 823 'elementType': 'geometry.fill', 824 'stylers': [{'color': '#f2f2f2'}] 825 }, 826 { 827 'featureType': 'landscape', 828 'elementType': 'geometry.stroke', 829 'stylers': [{'color': '#000000'}] 830 }, 831 { 832 'featureType': 'poi', 833 'elementType': 'all', 834 'stylers': [{'visibility': 'off'}] 835 }, 836 { 837 'featureType': 'road', 838 'elementType': 'all', 839 'stylers': [{'saturation': -100}, {'lightness': 45}] 840 }, 841 { 842 'featureType': 'road.highway', 843 'elementType': 'all', 844 'stylers': [{'visibility': 'simplified'}] 845 }, 846 { 847 'featureType': 'road.highway', 848 'elementType': 'geometry.fill', 849 'stylers': [{'color': road_highway_color}] 850 }, 851 { 852 'featureType': 'road.arterial', 853 'elementType': 'labels.icon', 854 'stylers': [{'visibility': 'off'}] 855 }, 856 { 857 'featureType': 'road.local', 858 'elementType': 'geometry.fill', 859 'stylers': [{'color': '#e6e6e6'}] 860 }, 861 { 862 'featureType': 'transit', 863 'elementType': 'all', 864 'stylers': [{'visibility': 'off'}] 865 }, 866 { 867 'featureType': 'water', 868 'elementType': 'all', 869 'stylers': [{'visibility': 'on'}, {'color': map_color}] 870 } 871 ]; 872 873 customMap = new google.maps.StyledMapType(styles, 874 {name: 'Styled Map'}); 875 876 if (mapData.number > 1) { 877 mutiMaps(infoWindow, bounds, mapOptions, mapData, id, styles, customMap); 878 } else { 879 singleMap(mapOptions, mapData, id, styles, customMap); 880 } 881 882 }); 883 }; 884 885 function singleMap(mapOptions, mapData, id, styles, customMap) { 886 var map, 887 marker, 888 location = new google.maps.LatLng(mapData.lat, mapData.lng); 889 890 // Update map options 891 mapOptions.zoom = parseInt(mapData.zoom, 10); 892 mapOptions.center = location; 893 mapOptions.mapTypeControlOptions = { 894 mapTypeIds: [google.maps.MapTypeId.ROADMAP] 895 }; 896 897 // Init map 898 map = new google.maps.Map(document.getElementById(id), mapOptions); 899 900 // Create marker options 901 var markerOptions = { 902 map: map, 903 position: location 904 }; 905 if (mapData.marker) { 906 markerOptions.icon = { 907 url: mapData.marker 908 }; 909 } 910 911 map.mapTypes.set('map_style', customMap); 912 map.setMapTypeId('map_style'); 913 914 // Init marker 915 marker = new google.maps.Marker(markerOptions); 916 917 if (mapData.info) { 918 var infoWindow = new google.maps.InfoWindow({ 919 content: '<div class="info-box mf-map">' + mapData.info + '</div>', 920 maxWidth: 600 921 }); 922 923 google.maps.event.addListener(marker, 'click', function () { 924 infoWindow.open(map, marker); 925 }); 926 } 927 } 928 929 function mutiMaps(infoWindow, bounds, mapOptions, mapData, id, styles, customMap) { 930 931 // Display a map on the page 932 mapOptions.zoom = parseInt(mapData.zoom, 10); 933 mapOptions.mapTypeControlOptions = { 934 mapTypeIds: [google.maps.MapTypeId.ROADMAP] 935 }; 936 937 var map = new google.maps.Map(document.getElementById(id), mapOptions); 938 map.mapTypes.set('map_style', customMap); 939 map.setMapTypeId('map_style'); 940 for (var i = 0; i < mapData.number; i++) {
941 var lats = mapData.lat, 942 lng = mapData.lng, 943 info = mapData.info; 944 945 var position = new google.maps.LatLng(lats[i], lng[i]); 946 bounds.extend(position); 947 948 // Create marker options 949 var markerOptions = { 950 map: map, 951 position: position 952 }; 953 if (mapData.marker) { 954 markerOptions.icon = { 955 url: mapData.marker 956 }; 957 } 958 959 // Init marker 960 var marker = new google.maps.Marker(markerOptions); 961 962 // Allow each marker to have an info window 963 googleMaps(infoWindow, map, marker, info[i]); 964 965 // Automatically center the map fitting all markers on the screen 966 map.fitBounds(bounds); 967 } 968 } 969 970 function googleMaps(infoWindow, map, marker, info) { 971 google.maps.event.addListener(marker, 'click', function () { 972 infoWindow.setContent(info); 973 infoWindow.open(map, marker); 974 }); 975 } 976 977 /** 978 * Load Brands 979 */ 980 martfury.brandsGrid = function () { 981 982 if (martfuryShortCode.length === 0 || typeof martfuryShortCode.productsbrandCarousel === 'undefined') { 983 return; 984 } 985 986 $.each(martfuryShortCode.productsbrandCarousel, function (id, productsData) { 987 var $viewPort = $(document.getElementById(id)); 988 989 productBrandsCarousel($viewPort, productsData); 990 991 // Brands Load More 992 productBrandsInfinite($viewPort); 993 994 function productBrandsInfinite($viewPort) { 995 996 $(window).on('scroll', function () { 997 998 var offSet = 0; 999 1000 if ($viewPort.is(':in-viewport(' + offSet + ')')) { 1001 $viewPort.find('.navigation-number a').trigger('click'); 1002 } 1003 1004 }).trigger('scroll'); 1005 1006 $viewPort.find('.navigation-number').on('click', 'a', function (e) { 1007 e.preventDefault(); 1008 1009 var $el = $(this); 1010 1011 if ($el.data('requestRunning')) { 1012 return; 1013 } 1014 1015 $el.data('requestRunning', true); 1016 1017 var $pagination = $el.closest('.navigation-number'), 1018 $products = $pagination.prev('.product-brands'), 1019 href = $el.attr('href'); 1020 1021 $el.parent().addClass('loading'); 1022 1023 $.get( 1024 href, 1025 function (response) { 1026 var content = $(response).find('.mf-brands-grid .product-brands').children('.brand-item-wrapper'), 1027 $pagination_html = $(response).find('.navigation-number').html(); 1028 1029 $pagination.html($pagination_html); 1030 1031 $products.append(content); 1032 1033 martfury.lazyLoad(content); 1034 1035 productBrandsCarousel(content, productsData); 1036 1037 $pagination.find('a').data('requestRunning', false); 1038 1039 $pagination.removeClass('loading'); 1040 } 1041 ); 1042 }); 1043 } 1044 1045 }); 1046 1047 1048 function productBrandsCarousel($viewPort, productsData) { 1049 var slidesToShow = parseInt(productsData.slidesToShow), 1050 slidesToScroll = parseInt(productsData.slidesToScroll); 1051 $viewPort.find('ul.products').not('.slick-initialized').slick({ 1052 rtl: (martfuryShortCode.direction === 'true'), 1053 slidesToShow: slidesToShow, 1054 slidesToScroll: slidesToScroll, 1055 arrows: productsData.slidesArrows, 1056 infinite: productsData.slideInfinite, 1057 prevArrow: '<span class="icon-chevron-left slick-prev-arrow"></span>', 1058 nextArrow: '<span class="icon-chevron-right slick-next-arrow"></span>', 1059 autoplay: productsData.slideAutoplay, 1060 autoplaySpeed: productsData.slideAutoplaySpeed, 1061 responsive: [ 1062 { 1063 breakpoint: 992, 1064 settings: { 1065 slidesToShow: slidesToShow > 2 ? 2 : slidesToShow, 1066 slidesToScroll: slidesToScroll > 2 ? 2 : slidesToScroll 1067 } 1068 }, 1069 { 1070 breakpoint: 480, 1071 settings: { 1072 slidesToShow: slidesToShow > 1 ? 1 : slidesToShow, 1073 slidesToScroll: slidesToScroll > 1 ? 1 : slidesToScroll 1074 } 1075 } 1076 ] 1077 }); 1078 1079 $viewPort.on('afterChange', function () { 1080 martfury.lazyLoad($viewPort); 1081 }); 1082 } 1083 1084 }; 1085 1086 1087 martfury.brandImagesCarousel = function () { 1088 if (martfuryShortCode.length === 0 || typeof martfuryShortCode.productsImagesCarousel === 'undefined') { 1089 return; 1090 } 1091 1092 $.each(martfuryShortCode.productsImagesCarousel, function (id, productsData) { 1093 var $viewPort = $(document.getElementById(id)), 1094 slidesToShow = parseInt(productsData.slidesToShow), 1095 slidesToScroll = parseInt(productsData.slidesToScroll); 1096 1097 $viewPort.find('.images-list').not('.slick-initialized').slick({ 1098 rtl: (martfuryShortCode.direction === 'true'), 1099 slidesToShow: slidesToShow, 1100 slidesToScroll: slidesToScroll, 1101 arrows: productsData.slidesArrows, 1102 infinite: productsData.slideInfinite, 1103 prevArrow: '<span class="icon-chevron-left slick-prev-arrow"></span>', 1104 nextArrow: '<span class="icon-chevron-right slick-next-arrow"></span>', 1105 autoplay: productsData.slideAutoplay, 1106 autoplaySpeed: productsData.slideAutoplaySpeed, 1107 responsive: [ 1108 { 1109 breakpoint: 992, 1110 settings: { 1111 slidesToShow: slidesToShow > 4 ? 4 : slidesToShow, 1112 slidesToScroll: slidesToScroll > 4 ? 4 : slidesToScroll 1113 } 1114 }, 1115 { 1116 breakpoint: 800, 1117 settings: { 1118 slidesToShow: slidesToShow > 3 ? 3 : slidesToShow, 1119 slidesToScroll: slidesToScroll > 3 ? 3 : slidesToScroll 1120 } 1121 }, 1122 { 1123 breakpoint: 600, 1124 settings: { 1125 slidesToShow: slidesToShow > 2 ? 2 : slidesToShow, 1126 slidesToScroll: slidesToScroll > 2 ? 2 : slidesToScroll 1127 } 1128 }, 1129 { 1130 breakpoint: 400, 1131 settings: { 1132 slidesToShow: slidesToShow > 1 ? 1 : slidesToShow, 1133 slidesToScroll: slidesToScroll > 1 ? 1 : slidesToScroll 1134 } 1135 } 1136 ] 1137 }); 1138 1139 $viewPort.on('afterChange', function () { 1140 martfury.lazyLoad($viewPort); 1141 }); 1142 }); 1143 1144 } 1145 1146 /** 1147 * Document ready 1148 */ 1149 $(function () { 1150 martfury.init(); 1151 }); 1152 1153})(jQuery);
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.