1(function ($) { 2 "use strict"; 3 4 let DIRECTION = null; 5 6 function direction() { 7 if (DIRECTION === null) { 8 DIRECTION = getComputedStyle(document.body).direction; 9 } 10 11 return DIRECTION; 12 } 13 14 function isRTL() { 15 return direction() === 'rtl'; 16 } 17 18 /* 19 // initialize custom numbers 20 */ 21 $(function () { 22 $('.input-number').customNumber(); 23 }); 24 25 26 /* 27 // product tabs 28 */ 29 $(function () { 30 $('.product-tabs').each(function (i, element) { 31 $('.product-tabs__list', element).on('click', '.product-tabs__item', function (event) { 32 event.preventDefault(); 33 34 const tab = $(this); 35 const content = $('.product-tabs__pane' + $(this).attr('href'), element); 36 37 if (content.length) { 38 $('.product-tabs__item').removeClass('product-tabs__item--active'); 39 tab.addClass('product-tabs__item--active'); 40 41 $('.product-tabs__pane').removeClass('product-tabs__pane--active'); 42 content.addClass('product-tabs__pane--active'); 43 } 44 }); 45 46 const currentTab = $('.product-tabs__item--active', element); 47 const firstTab = $('.product-tabs__item:first', element); 48 49 if (currentTab.length) { 50 currentTab.trigger('click'); 51 } else { 52 firstTab.trigger('click'); 53 } 54 }); 55 }); 56 57 58 /* 59 // block slideshow 60 */ 61 $(function() { 62 $('.block-slideshow .owl-carousel').owlCarousel({ 63 items: 1, 64 autoplay: true, 65 autoplayHoverPause: true, 66 autoplaySpeed: 800, 67 autoplayTimeout: 8000, 68 nav: false, 69 dots: true, 70 loop: true, 71 rtl: isRTL() 72 }); 73 }); 74 75 76 /* 77 // block brands carousel 78 */ 79 $(function() { 80 $('.block-brands__slider .owl-carousel').owlCarousel({ 81 nav: false, 82 dots: false, 83 loop: true, 84 rtl: isRTL(), 85 responsive: { 86 1200: {items: 6}, 87 992: {items: 5}, 88 768: {items: 4}, 89 576: {items: 3}, 90 0: {items: 2} 91 } 92 }); 93 }); 94 95 96 /* 97 // block posts carousel 98 */ 99 $(function() { 100 $('.block-posts').each(function() { 101 const layout = $(this).data('layout'); 102 const options = { 103 margin: 30, 104 nav: false, 105 dots: false, 106 loop: true, 107 rtl: isRTL() 108 }; 109 const layoutOptions = { 110 'grid-nl': { 111 112 responsive: { 113 992: {items: 3}, 114 768: {items: 2}, 115 0: {items: 1} 116 } 117 }, 118 'list-sm': { 119 responsive: { 120 992: {items: 2}, 121 0: {items: 1} 122 } 123 } 124 }; 125 const owl = $('.block-posts__slider .owl-carousel'); 126 127 owl.owlCarousel($.extend({}, options, layoutOptions[layout])); 128 129 $(this).find('.block-header__arrow--left').on('click', function() { 130 owl.trigger('prev.owl.carousel', [500]); 131 }); 132 $(this).find('.block-header__arrow--right').on('click', function() { 133 owl.trigger('next.owl.carousel', [500]); 134 }); 135 }); 136 }); 137 138 139 /* 140 // teammates 141 */ 142 $(function() { 143 $('.teammates .owl-carousel').owlCarousel({ 144 nav: false, 145 dots: true, 146 rtl: isRTL(), 147 responsive: { 148 768: {items: 3, margin: 32}, 149 380: {items: 2, margin: 24}, 150 0: {items: 1} 151 } 152 }); 153 }); 154 155 /* 156 // quickview 157 */ 158 const quickview = { 159 cancelPreviousModal: function() {}, 160 clickHandler: function() { 161 const modal = $('#quickview-modal'); 162 const button = $(this); 163 const doubleClick = button.is('.product-card__quickview--preload'); 164 const productID = button.data('pid'); 165 166 quickview.cancelPreviousModal(); 167 168 if (doubleClick) { 169 return; 170 } 171 172 button.addClass('product-card__quickview--preload'); 173 174 let xhr = null; 175 // timeout ONLY_FOR_DEMO! 176 const timeout = setTimeout(function() { 177 xhr = $.ajax({ 178 url: my_domain+'quickview.php?pid='+productID, 179 success: function(data) { 180 quickview.cancelPreviousModal = function() {}; 181 button.removeClass('product-card__quickview--preload'); 182
183 modal.find('.modal-content').html(data); 184 modal.find('.quickview__close').on('click', function() { 185 modal.modal('hide'); 186 }); 187 modal.modal('show'); 188 } 189 }); 190 }, 1000); 191 192 quickview.cancelPreviousModal = function() { 193 button.removeClass('product-card__quickview--preload'); 194 195 if (xhr) { 196 xhr.abort(); 197 } 198 199 // timeout ONLY_FOR_DEMO! 200 clearTimeout(timeout); 201 }; 202 } 203 }; 204 205 $(function () { 206 const modal = $('#quickview-modal'); 207 208 modal.on('shown.bs.modal', function() { 209 modal.find('.product').each(function () { 210 const gallery = $(this).find('.product-gallery'); 211 212 if (gallery.length > 0) { 213 initProductGallery(gallery[0], $(this).data('layout')); 214 } 215 }); 216 217 $('.input-number', modal).customNumber(); 218 }); 219 220 $('.product-card__quickview').on('click', function() { 221 quickview.clickHandler.apply(this, arguments); 222 }); 223 }); 224 225 226 227 228 229 /* 230 // products carousel 231 */ 232 $(function() { 233 $('.block-products-carousel').not( ".reorder" ).each(function() { 234 const layout = $(this).data('layout'); 235 const options = { 236 items: 4, 237 margin: 14, 238 nav: false, 239 dots: false, 240 //loop: true, 241 stagePadding: 1, 242 rtl: isRTL() 243 }; 244 const layoutOptions = { 245 'grid-4': { 246 responsive: { 247 1200: {items: 4, margin: 14}, 248 992: {items: 4, margin: 10}, 249 768: {items: 3, margin: 10}, 250 576: {items: 2, margin: 10}, 251 475: {items: 2, margin: 10}, 252 0: {items: 1} 253 } 254 }, 255 'grid-4-sm': { 256 responsive: { 257 1200: {items: 4, margin: 14}, 258 992: {items: 3, margin: 10}, 259 768: {items: 3, margin: 10}, 260 576: {items: 2, margin: 10}, 261 475: {items: 2, margin: 10}, 262 0: {items: 1} 263 } 264 }, 265 'grid-5': { 266 responsive: { 267 1200: {items: 5, margin: 12}, 268 992: {items: 4, margin: 10}, 269 768: {items: 3, margin: 10}, 270 576: {items: 2, margin: 10}, 271 475: {items: 2, margin: 10}, 272 0: {items: 1} 273 } 274 }, 275 'horizontal': { 276 items: 3, 277 responsive: { 278 1200: {items: 3, margin: 14}, 279 992: {items: 3, margin: 10}, 280 768: {items: 2, margin: 10}, 281 576: {items: 1}, 282 475: {items: 1}, 283 0: {items: 1} 284 } 285 }, 286 }; 287 const owl = $('.owl-carousel', this); 288 let cancelPreviousTabChange = function() {}; 289 290 owl.owlCarousel($.extend({}, options, layoutOptions[layout])); 291 292 $(this).find('.block-header__group').on('click', function(event) { 293 const block = $(this).closest('.block-products-carousel'); 294 const categoryID = $(this).data('cid'); 295 296 event.preventDefault(); 297 298 if ($(this).is('.block-header__group--active')) { 299 return; 300 } 301 302 cancelPreviousTabChange(); 303 304 block.addClass('block-products-carousel--loading'); 305 $(this).closest('.block-header__groups-list').find('.block-header__group--active').removeClass('block-header__group--active'); 306 $(this).addClass('block-header__group--active'); 307 308 let xhr2 = null; 309 // timeout ONLY_FOR_DEMO! 310 const timer = setTimeout(function() { 311 xhr2 = $.ajax({ 312 url: my_domain+'carousel.php?cid='+categoryID, 313 success: function(data) { 314 315 let items = $(data).filter('.block-products-carousel__column'); 316 317 /*** this is ONLY_FOR_DEMO! / start */ 318 /**/ const itemsArray = items.get(); 319 // /**/ const newItemsArray = []; 320 // /**/ 321 // /**/ while (itemsArray.length > 0) { 322 // /**/ const randomIndex = Math.floor(Math.random() * itemsArray.length); 323 // /**/ const randomItem = itemsArray.splice(randomIndex, 1)[0]; 324 // /**/ 325 // /**/ newItemsArray.push(randomItem); 326 // /**/ } 327 /**/ items = $(itemsArray); 328 /*** this is ONLY_FOR_DEMO! / end */ 329 330 block.find('.owl-carousel') 331 .trigger('replace.owl.carousel', [items]) 332 .trigger('refresh.owl.carousel') 333 .trigger('to.owl.carousel', [0, 0]); 334 335 // block.find('.owl-carousel').html(data); 336 $('.product-card__quickview', block).on('click', function() { 337 quickview.clickHandler.apply(this, arguments); 338 }); 339 block.removeClass('block-products-carousel--loading'); 340 } 341 }); 342 }, 1000); 343 344 345 // timeout ONLY_FOR_DEMO! you can replace it with an ajax request 346// let timer; 347// timer = setTimeout(function() { 348// let items = block.find('.owl-carousel .owl-item:not(".cloned") .block-products-carousel__column'); 349// 350// /*** this is ONLY_FOR_DEMO! / start */ 351// /**/ const itemsArray = items.get(); 352// /**/ const newItemsArray = []; 353// /**/ 354// /**/ while (itemsArray.length > 0) { 355// /**/ const randomIndex = Math.floor(Math.random() * itemsArray.length); 356// /**/ const randomItem = itemsArray.splice(randomIndex, 1)[0]; 357// /**/ 358// /**/ newItemsArray.push(randomItem); 359// /**/ } 360// /**/ items = $(newItemsArray); 361// /*** this is ONLY_FOR_DEMO! / end */ 362// 363// block.find('.owl-carousel') 364// .trigger('replace.owl.carousel', [items]) 365// .trigger('refresh.owl.carousel') 366// .trigger('to.owl.carousel', [0, 0]); 367// 368// $('.product-card__quickview', block).on('click', function() { 369// quickview.clickHandler.apply(this, arguments); 370// }); 371// 372// block.removeClass('block-products-carousel--loading'); 373// }, 1000); 374 cancelPreviousTabChange = function() { 375 // timeout ONLY_FOR_DEMO! 376 clearTimeout(timer); 377 cancelPreviousTabChange = function() {}; 378 }; 379 }); 380 381 $(this).find('.block-header__arrow--left').on('click', function() { 382 owl.trigger('prev.owl.carousel', [500]); 383 }); 384 $(this).find('.block-header__arrow--right').on('click', function() { 385 owl.trigger('next.owl.carousel', [500]); 386 }); 387 }); 388 }); 389 390 391 392 393 394 /*
395 // reorder carousel 396 */ 397 $(function() { 398 $('.block-products-carousel.reorder').each(function() { 399 const layout = $(this).data('layout'); 400 const options = { 401 items: 4, 402 margin: 14, 403 nav: false, 404 dots: false, 405 //loop: true, 406 stagePadding: 1, 407 rtl: isRTL() 408 }; 409 const layoutOptions = { 410 'grid-4': { 411 responsive: { 412 1200: {items: 4, margin: 14}, 413 992: {items: 4, margin: 10}, 414 768: {items: 3, margin: 10}, 415 576: {items: 2, margin: 10}, 416 475: {items: 2, margin: 10}, 417 0: {items: 1} 418 } 419 }, 420 'grid-4-sm': { 421 responsive: { 422 1200: {items: 4, margin: 14}, 423 992: {items: 3, margin: 10}, 424 768: {items: 3, margin: 10}, 425 576: {items: 2, margin: 10}, 426 475: {items: 2, margin: 10}, 427 0: {items: 1} 428 } 429 }, 430 'grid-5': { 431 responsive: { 432 1200: {items: 5, margin: 12}, 433 992: {items: 4, margin: 10}, 434 768: {items: 3, margin: 10}, 435 576: {items: 2, margin: 10}, 436 475: {items: 2, margin: 10}, 437 0: {items: 1} 438 } 439 }, 440 'horizontal': { 441 items: 3, 442 responsive: { 443 1200: {items: 3, margin: 14}, 444 992: {items: 3, margin: 10}, 445 768: {items: 2, margin: 10}, 446 576: {items: 1}, 447 475: {items: 1}, 448 0: {items: 1} 449 } 450 }, 451 }; 452 const owl = $('.owl-carousel', this); 453 454 owl.owlCarousel($.extend({}, options, layoutOptions[layout])); 455 456 const block = $(this); 457 block.addClass('block-products-carousel--loading'); 458 459 let xhr2 = null; 460 461 // 462 const timer = setTimeout(function() { 463 xhr2 = $.ajax({ 464 url: my_domain+'carousel_reorder.php', 465 success: function(data) { 466 467 tconsole('Qui ci sono'); 468 469 let items = $(data).filter('.block-products-carousel__column'); 470 471 block.find('.owl-carousel') 472 .trigger('replace.owl.carousel', [items]) 473 .trigger('refresh.owl.carousel') 474 .trigger('to.owl.carousel', [0, 0]); 475 476 block.removeClass('block-products-carousel--loading'); 477 } 478 }); 479 }, 1000); 480 481 482 483 $(this).find('.block-header__arrow--left').on('click', function() { 484 owl.trigger('prev.owl.carousel', [500]); 485 }); 486 $(this).find('.block-header__arrow--right').on('click', function() { 487 owl.trigger('next.owl.carousel', [500]); 488 }); 489 }); 490 }); 491 492 493 494 495 496 497 498 499 500 501 /* 502 // product gallery 503 */ 504 const initProductGallery = function(element, layout) { 505 layout = layout !== undefined ? layout : 'standard'; 506 507 const options = { 508 dots: false, 509 nav: true, 510 margin: 10, 511 rtl: isRTL() 512 }; 513 const layoutOptions = { 514 standard: { 515 responsive: { 516 1200: {items: 5}, 517 992: {items: 4}, 518 768: {items: 3}, 519 480: {items: 5}, 520 380: {items: 4}, 521 0: {items: 3} 522 } 523 }, 524 sidebar: { 525 responsive: { 526 768: {items: 4}, 527 480: {items: 5}, 528 380: {items: 4}, 529 0: {items: 3} 530 } 531 }, 532 columnar: { 533 responsive: { 534 768: {items: 4}, 535 480: {items: 5}, 536 380: {items: 4}, 537 0: {items: 3} 538 } 539 }, 540 quickview: { 541 responsive: { 542 1200: {items: 5}, 543 768: {items: 4}, 544 480: {items: 5}, 545 380: {items: 4}, 546 0: {items: 3} 547 } 548 } 549 }; 550 551 const gallery = $(element); 552 553 const image = gallery.find('.product-gallery__featured .owl-carousel'); 554 const carousel = gallery.find('.product-gallery__carousel .owl-carousel'); 555 556 image 557 .owlCarousel({items: 1, dots: false, autoplay: true, autoplayTimeout: 8000, autoplayHoverPause: true, autoplaySpeed: 800, rtl: isRTL()}) 558 .on('changed.owl.carousel', syncPosition); 559 560 carousel
561 .on('initialized.owl.carousel', function () { 562 carousel.find('.product-gallery__carousel-item').eq(0).addClass('product-gallery__carousel-item--active'); 563 }) 564 .owlCarousel($.extend({}, options, layoutOptions[layout])); 565 566 carousel.on('click', '.owl-item', function(e){ 567 e.preventDefault(); 568 569 image.data('owl.carousel').to($(this).index(), 300, true); 570 }); 571 572 573 gallery.find('.product-gallery__zoom').on('click', function() { 574 openPhotoSwipe(image.find('.owl-item.active').index()); 575 }); 576 577 image.on('click', '.owl-item > a', function(event) { 578 event.preventDefault(); 579 580 openPhotoSwipe($(this).closest('.owl-item').index()); 581 }); 582 583 function openPhotoSwipe(index) { 584 const photoSwipeImages = image.find('.owl-item > a').toArray().map(function(element) { 585 return { 586 src: element.href, 587 msrc: element.href, 588 w: 752, 589 h: 520 590 }; 591 }); 592 593 const photoSwipeOptions = { 594 getThumbBoundsFn: function(index) { 595 const imageElement = image.find('.owl-item img')[index]; 596 const pageYScroll = window.pageYOffset || document.documentElement.scrollTop; 597 const rect = imageElement.getBoundingClientRect(); 598 599 return {x: rect.left, y: rect.top + pageYScroll, w: rect.width}; 600 }, 601 index: index, 602 bgOpacity: .9, 603 history: false 604 }; 605 606 const photoSwipeGallery = new PhotoSwipe($('.pswp')[0], PhotoSwipeUI_Default, photoSwipeImages, photoSwipeOptions); 607 608 photoSwipeGallery.listen('beforeChange', function() { 609 image.data('owl.carousel').to(photoSwipeGallery.getCurrentIndex(), 0, true); 610 }); 611 612 photoSwipeGallery.init(); 613 } 614 615 616 function syncPosition (el) { 617 let current = el.item.index; 618 619 carousel 620 .find('.product-gallery__carousel-item') 621 .removeClass('product-gallery__carousel-item--active') 622 .eq(current) 623 .addClass('product-gallery__carousel-item--active'); 624 const onscreen = carousel.find('.owl-item.active').length - 1; 625 const start = carousel.find('.owl-item.active').first().index(); 626 const end = carousel.find('.owl-item.active').last().index(); 627 628 if (current > end) { 629 carousel.data('owl.carousel').to(current, 100, true); 630 } 631 if (current < start) { 632 carousel.data('owl.carousel').to(current - onscreen, 100, true); 633 } 634 } 635 }; 636 637 $(function() { 638 $('.product').each(function () { 639 const gallery = $(this).find('.product-gallery'); 640 641 if (gallery.length > 0) { 642 initProductGallery(gallery[0], $(this).data('layout')); 643 } 644 }); 645 }); 646 647 648 /* 649 // Checkout payment methods 650 */ 651 $(function () { 652 $('[name="checkout_payment_method"]').on('change', function () { 653 654 updateCart(); 655 656 $(".payment-methods__list").find(".payment-methods__item-title").removeClass("blue font-weight-bold"); 657 //$(".payment-methods__list").find("i.fas, i.fab").removeClass("blue font-weight-bold"); 658 659 const currentItem = $(this).closest('.payment-methods__item'); 660 661 currentItem.find(".payment-methods__item-title").addClass("blue font-weight-bold"); 662 //currentItem.find("i.fas, i.fab").addClass("blue font-weight-bold"); 663 664 $(this).closest('.payment-methods__list').find('.payment-methods__item').each(function (i, element) { 665 const links = $(element); 666 const linksContent = links.find('.payment-methods__item-container'); 667 668 if (element !== currentItem[0]) { 669 const startHeight = linksContent.height(); 670 671 linksContent.css('height', startHeight + 'px'); 672 links.removeClass('payment-methods__item--active'); 673 674 linksContent.css('height', ''); 675 676 } else { 677 const startHeight = linksContent.height(); 678 679 links.addClass('payment-methods__item--active'); 680 681 const endHeight = linksContent.height(); 682 683 linksContent.css('height', startHeight + 'px'); 684 linksContent.css('height', endHeight + 'px'); 685 } 686 }); 687 }); 688 689 $('.payment-methods__item-container').on('transitionend', function (event) { 690 if (event.originalEvent.propertyName === 'height') { 691 $(this).css('height', ''); 692 } 693 }); 694 }); 695 696 697 /* 698 // collapse 699 */ 700 $(function () { 701 $('[data-collapse]').each(function (i, element) { 702 const collapse = element; 703 const openedClass = $(element).data('collapse-opened-class'); 704 705 $('[data-collapse-trigger]', collapse).on('click', function () { 706 const item = $(this).closest('[data-collapse-item]'); 707 const content = item.children('[data-collapse-content]'); 708 const itemParents = item.parents(); 709 710 itemParents.slice(0, itemParents.index(collapse) + 1).filter('[data-collapse-item]').css('height', ''); 711 712 if (item.is('.' + openedClass)) { 713 const startHeight = content.height(); 714 715 content.css('height', startHeight + 'px'); 716 item.removeClass(openedClass); 717 718 content.css('height', ''); 719 } else { 720 const startHeight = content.height(); 721 722 item.addClass(openedClass); 723 724 const endHeight = content.height(); 725 726 content.css('height', startHeight + 'px'); 727 content.css('height', endHeight + 'px'); 728 } 729 }); 730 731 $('[data-collapse-content]', collapse).on('transitionend', function (event) { 732 if (event.originalEvent.propertyName === 'height') { 733 $(this).css('height', ''); 734 } 735 }); 736 }); 737 }); 738 739 740 /* 741 // price filter 742 */ 743 $(function () { 744 $('.filter-price').each(function (i, element) { 745 const min = $(element).data('min'); 746 const max = $(element).data('max'); 747 const from = $(element).data('from'); 748 const to = $(element).data('to'); 749 const slider = element.querySelector('.filter-price__slider'); 750 751 noUiSlider.create(slider, { 752 start: [from, to], 753 connect: true, 754 direction: isRTL() ? 'rtl' : 'ltr', 755 range: { 756 'min': min, 757 'max': max 758 } 759 }); 760 761 const titleValues = [ 762 $(element).find('.filter-price__min-value')[0], 763 $(element).find('.filter-price__max-value')[0] 764 ]; 765 766 slider.noUiSlider.on('update', function (values, handle) { 767 titleValues[handle].innerHTML = values[handle]; 768 }); 769 }); 770 }); 771 772 773 /* 774 // mobilemenu 775 */ 776 $(function () { 777 const body = $('body'); 778 const mobilemenu = $('.mobilemenu'); 779 780 if (mobilemenu.length) { 781 const open = function() { 782 const bodyWidth = body.width(); 783 body.css('overflow', 'hidden'); 784 body.css('paddingRight', (body.width() - bodyWidth) + 'px'); 785 786 mobilemenu.addClass('mobilemenu--open'); 787 }; 788 const close = function() { 789 body.css('overflow', 'auto'); 790 body.css('paddingRight', ''); 791 792 mobilemenu.removeClass('mobilemenu--open'); 793 }; 794 795 796 $('.mobile-header__menu-button').on('click', function() { 797 open(); 798 }); 799 $('.mobilemenu__backdrop, .mobilemenu__close').on('click', function() { 800 close(); 801 }); 802 } 803 }); 804 805 806 /* 807 // tooltips 808 */ 809 $(function () { 810 $('[data-toggle="tooltip"]').tooltip({'delay':{show:300}}); 811 }); 812 813 814 /* 815 // layout switcher 816 */ 817 $(function () { 818 $('.layout-switcher__button').on('click', function() { 819 const layoutSwitcher = $(this).closest('.layout-switcher'); 820 const productsView = $(this).closest('.products-view'); 821 const productsList = productsView.find('.products-list'); 822 823 layoutSwitcher.find('.layout-switcher__button').removeClass('layout-switcher__button--active'); 824 $(this).addClass('layout-switcher__button--active'); 825 826 productsList.attr('data-layout', $(this).attr('data-layout')); 827 productsList.attr('data-with-features', $(this).attr('data-with-features')); 828 }); 829 }); 830 831 832 /* 833 // offcanvas filters 834 */ 835 $(function () { 836 const body = $('body'); 837 const blockSidebar = $('.block-sidebar'); 838 const mobileMedia = matchMedia('(max-width: 991px)'); 839 840 if (blockSidebar.length) { 841 const open = function() { 842 if (blockSidebar.is('.block-sidebar--offcanvas--mobile') && !mobileMedia.matches) { 843 return; 844 } 845 846 const bodyWidth = body.width(); 847 body.css('overflow', 'hidden'); 848 body.css('paddingRight', (body.width() - bodyWidth) + 'px'); 849 850 blockSidebar.addClass('block-sidebar--open'); 851 }; 852 const close = function() { 853 body.css('overflow', 'auto'); 854 body.css('paddingRight', ''); 855 856 blockSidebar.removeClass('block-sidebar--open'); 857 }; 858 const onChangeMedia = function() { 859 if (blockSidebar.is('.block-sidebar--open.block-sidebar--offcanvas--mobile') && !mobileMedia.matches) { 860 close(); 861 } 862 }; 863 864 $('.filters-button').on('click', function() { 865 open(); 866 }); 867 $('.block-sidebar__backdrop, .block-sidebar__close').on('click', function() { 868 close(); 869 }); 870 871 if (mobileMedia.addEventListener) { 872 mobileMedia.addEventListener('change', onChangeMedia); 873 } else { 874 mobileMedia.addListener(onChangeMedia); 875 } 876 } 877 }); 878 879 880 881 $(function () { 882 $('.exit_butt').on('click', function() { 883 884 $("#m_header h4").html("Uscita"); 885 $("#m_body p").html("Vuoi uscire dalla tua area riservata?"); 886 $("#m_header") 887 .removeClass() 888 .addClass("modal-header") 889 .addClass("bgyellow"); 890 $("#m_body i") 891 .removeClass() 892 .addClass("fas fa-4x mb-3 animated bounceInLeft") 893 .addClass("grey") 894 .addClass("fa-running"); 895 $("#m_footer button").html("Esci ora").on('click', function() { 896 $("#m_body p").load(my_domain+"ajax_check_logout.php", function(responseTxt, statusTxt, xhr){ 897 if(responseTxt == "LOGOUT!") 898 window.location.href = my_domain+'it/accedi-registrati.html'; 899 }); 900 }); 901 $("#ModalWindow").modal("show"); 902 903 }); 904 }); 905 906 907 908 // DETTAGLIO ORDINI 909 var ordineattivo = ""; 910 $(function () { 911 $('a.ado').click(function(){ 912 var ordine = $(this).html(); 913 ordine = ordine.replace("#",""); 914 //alert(ordine); 915 916 if(ordine!=ordineattivo) { 917 $(this).after("<img id='w"+ordine+"' src='"+my_domain+"images/loading.gif'>"); 918 $.post(my_domain+"account_order_detail.php", {IDo: ordine}, function(result){ 919 if(result=="error") { 920 window.location.href = my_domain+"it/accedi-registrati.html"; 921 } else { 922 $("#d"+ordine+" div").html(result); 923 $("#d"+ordineattivo+" div").slideUp(400); 924 $("#d"+ordine+" div").slideDown(400); 925 ordineattivo = ordine; 926 $("#w"+ordine).remove(); 927 $(".progress-bar").each(function() { 928 var incrementa = $(this).attr("data-increase"); 929 $(this).width(incrementa+"%"); 930 }); 931 $(function () { 932 $('[data-toggle="tooltip"]').tooltip({'delay':{show:300}}); 933 }); 934 $(function () { 935 $('.ods').click(function(){ 936 $(this).nextAll("ul").first().slideToggle(400); 937 $(this).find('i').toggleClass("fa-plus-circle fa-minus-circle"); 938 }); 939 }); 940 941 $('.gofile').on('click', function() { 942 var oid = $(this).data("oid"); 943 window.location.href = my_domain+"account_file.php?IDo="+oid; 944 }); 945 946 $('.reo').on('click', function() { 947 var oil = $(this).data("oil"); 948 window.location.href = my_domain+"account_reorder.php?IDl="+oil; 949 }); 950 951 952 $('.goorder').on('click', function() { 953 var oid = $(this).data("oid"); 954 window.location.href = my_domain+"account_orderpdf.php?oid="+oid; 955 }); 956 957 $('.gopay').on('click', function() { 958 var oid = $(this).data("oid"); 959 window.location.href = my_domain+"it/success/"+oid; 960 }); 961 962 963 $('.delorder').on('click', function() { 964 var oid = $(this).data("oid"); 965 966 $("#m_header h4").html("Conferma"); 967 $("#m_body p").html("Vuoi annullare l'ordine? Ti ricordiamo che gli ordini annullati vengono periodicamente cancellati dal nostro
967sistema e che eventuali file caricati verranno eliminati."); 968 $("#m_header") 969 .removeClass() 970 .addClass("modal-header") 971 .addClass("bgyellow"); 972 $("#m_body i") 973 .removeClass() 974 .addClass("fas fa-4x mb-3 animated tada") 975 .addClass("grey") 976 .addClass("fa-trash-alt"); 977 $("#m_footer button").html("Annulla ora").on('click', function() { 978 $.post(my_domain+"account_order_del.php", {oid: oid}, function(result){ 979 980 //console.log(result); 981 982 if(result=="success") { 983 location.reload(true); 984 } 985 }); 986 987 }); 988 $("#ModalWindow").modal("show"); 989 }); 990 991 $('#uploadfile-modal').on('hidden.bs.modal', function (e) { 992 location.reload(true); 993 }) 994 995 } 996 }); 997 } 998 }); 999 }); 1000 1001 1002 // BUTTONS 1003 $(function () { 1004 $('.goinvoice').on('click', function() { 1005 var oid = $(this).data("oid"); 1006 window.location.href = my_domain+"account_invoicepdf.php?oid="+oid; 1007 }); 1008 1009 1010 // COUPON IN CART 1011 $('.bcoupon').on('click', function() { 1012 var icc = $("#input-coupon-code").val(); 1013 var txterr = ''; 1014 1015 //alert(icc); 1016 1017 const bcoupon = $(this); 1018 bcoupon.addClass("btn-loading"); 1019 1020 $.post(my_domain+"ajax_cart_validate_coupon.php", {icc: icc}, function(result){ 1021 1022 if(result!="ok") { 1023 1024 if(result=="noauth") { 1025 txterr = 'Per utilizzare i coupon devi prima autenticarti.'; 1026 } 1027 else if(result=="nocodeerr") { 1028 txterr = 'Inserisci un codice coupon valido.'; 1029 } 1030 else if(result=="noiva") { 1031 txterr = 'Non è possibile utilizzare i codici coupon su ordini che contengono articoli con percentuali di IVA non ordinaria. Contattaci direttamente per risolvere il problema.'; 1032 } 1033 else if(result=="nocode") { 1034 txterr = 'Il codice coupon non è stato riconosciuto, ti preghiamo di verificare.'; 1035 } 1036 else if(result=="nodisp") { 1037 txterr = 'Il codice coupon risulta già utilizzato.'; 1038 } 1039 else if(result=="nodata1") { 1040 txterr = 'Il codice coupon non è ancora attivo. Controlla le date di validità .'; 1041 } 1042 else if(result=="nodata2") { 1043 txterr = 'Il codice coupon non è più attivo. Controlla le date di validità .'; 1044 } 1045 else if(result=="nomin") { 1046 txterr = 'Il codice sconto prevede un minimo di spesa che non è stato raggiunto. Controlla le caratteristiche del coupon.'; 1047 } 1048 else if(result=="nomin") { 1049 txterr = 'Il codice sconto prevede un minimo di spesa che non è stato raggiunto. Controlla le caratteristiche del coupon.'; 1050 } 1051 else if(result=="noprice") { 1052 txterr = 'Ti ricordiamo che l\'importo degli articoli deve essere superiore di almeno 1 euro rispetto al valore del coupon.'; 1053 } 1054 else if(result=="promo") { 1055 txterr = 'Ti ricordiamo che non è possibile applicare coupon su carrelli che contengano Promo Speciali.'; 1056 } 1057 else { 1058 txterr = 'Si è verificato un errore generico, prova a ricaricare la pagina.'.result; 1059 } 1060 $("#m_header h4").html("Attenzione"); 1061 $("#m_body p").html(txterr); 1062 $("#m_header") 1063 .removeClass() 1064 .addClass("modal-header") 1065 .addClass("bgred"); 1066 $("#m_body i") 1067 .removeClass() 1068 .addClass("fas fa-4x mb-3 animated tada") 1069 .addClass("red") 1070 .addClass("fa-exclamation-triangle"); 1071 $("#m_footer button").html("Chiudi"); 1072 $("#ModalWindow").modal("show"); 1073 $("#ModalWindow").on('hidden.bs.modal', function(){ 1074 bcoupon.removeClass("btn-loading"); 1075 }); 1076 1077 } else { 1078 $("#m_header h4").html("Completato!"); 1079 $("#m_body p").html("Il coupon è stato applicato correttamente al tuo ordine e il credito relativo è stato scalato dal totale imponibile."); 1080 //$("#m_body p").html("Il coupon è stato applicato correttamente al tuo ordine.<br /><small class='mt-2'><strong>ATTENZIONE!</strong><br/>Ti ricordiamo che con l'applicazione del coupon tutte le eventuali promo sui singoli articoli vengono azzerate e i prezzi riportati ai valori di listino.</small>"); 1081 $("#m_header") 1082 .removeClass() 1083 .addClass("modal-header") 1084 .addClass("bggreen"); 1085 $("#m_body i") 1086 .removeClass() 1087 .addClass("fas fa-4x mb-3 animated tada") 1088 .addClass("green") 1089 .addClass("fa-check"); 1090 $("#m_footer button").html("Chiudi"); 1091 $("#ModalWindow").modal("show"); 1092 $("#ModalWindow").on('hidden.bs.modal', function(){ 1093 location.reload(true); 1094 }); 1095 } 1096 1097 }); 1098 }); 1099 1100 1101 1102 // COUPON IN LISTA COUPON 1103 $('.lcoupon').on('click', function() { 1104 var icc = $(this).data("icc"); 1105 var txterr = ''; 1106 1107 $.post(my_domain+"ajax_cart_validate_coupon.php", {icc: icc}, function(result){ 1108 1109 if(result!="ok") { 1110 1111 if(result=="noauth") { 1112 txterr = 'Per utilizzare i coupon devi prima autenticarti.'; 1113 } 1114 else if(result=="nocodeerr") { 1115 txterr = 'Inserisci un codice coupon valido.'; 1116 } 1117 else if(result=="noiva") { 1118 txterr = 'Non è possibile utilizzare i codici coupon su ordini che contengono articoli con percentuali di IVA non ordinaria. Contattaci direttamente per risolvere il problema.'; 1119 } 1120 else if(result=="nocode") { 1121 txterr = 'Il codice coupon non è stato riconosciuto, ti preghiamo di verificare.'; 1122 } 1123 else if(result=="nodisp") { 1124 txterr = 'Il codice coupon risulta già utilizzato.'; 1125 } 1126 else if(result=="nodata1") { 1127 txterr = 'Il codice coupon non è ancora attivo. Controlla le date di validità .'; 1128 } 1129 else if(result=="nodata2") { 1130 txterr = 'Il codice coupon non è più attivo. Controlla le date di validità .'; 1131 } 1132 else if(result=="nomin") { 1133 txterr = 'Il codice sconto prevede un minimo di spesa che non è stato raggiunto. Controlla le caratteristiche del coupon.'; 1134 } 1135 else if(result=="nomin") { 1136 txterr = 'Il codice sconto prevede un minimo di spesa che non è stato raggiunto. Controlla le caratteristiche del coupon.'; 1137 } 1138 else if(result=="noprice") { 1139 txterr = 'Ti ricordiamo che l\'importo degli articoli deve essere superiore di almeno 1 euro rispetto al valore del coupon.'; 1140 } 1141 else if(result=="promo") { 1142 txterr = 'Ti ricordiamo che non è possibile applicare coupon su carrelli che contengano Promo Speciali.'; 1143 } 1144 else { 1145 txterr = 'Si è verificato un errore generico, prova a ricaricare la pagina.'.result; 1146 } 1147 $("#m_header h4").html("Attenzione"); 1148 $("#m_body p").html(txterr); 1149 $("#m_header") 1150 .removeClass() 1151 .addClass("modal-header") 1152 .addClass("bgred"); 1153 $("#m_body i") 1154 .removeClass() 1155 .addClass("fas fa-4x mb-3 animated tada") 1156 .addClass("red") 1157 .addClass("fa-exclamation-triangle"); 1158 $("#m_footer button").html("Chiudi"); 1159 $("#ModalWindow").modal("show"); 1160 $("#ModalWindow").on('hidden.bs.modal', function(){ 1161 //bcoupon.removeClass("btn-loading"); 1162 }); 1163 1164 } else { 1165 $("#m_header h4").html("Completato!"); 1166 $("#m_body p").html("Il coupon è stato inserito correttamente nel carrello.<br /><small class='mt-2'><strong>ATTENZIONE!</strong><br/>Ti ricordiamo che con l'applicazione del coupon tutte le eventuali promo sui singoli articoli vengono azzerate e i prezzi riportati ai valori di listino.</small>"); 1167 $("#m_header") 1168 .removeClass() 1169 .addClass("modal-header") 1170 .addClass("bggreen"); 1171 $("#m_body i") 1172 .removeClass() 1173 .addClass("fas fa-4x mb-3 animated tada") 1174 .addClass("green") 1175 .addClass("fa-check"); 1176 $("#m_footer button").html("Chiudi"); 1177 $("#ModalWindow").modal("show"); 1178 $("#ModalWindow").on('hidden.bs.modal', function(){ 1179 location.reload(true); 1180 }); 1181 } 1182 1183 }); 1184 }); 1185 1186 1187
1188 // DELETE COUPON IN CART 1189 $('.dcoupon').on('click', function() { 1190 $(this).addClass("btn-loading"); 1191 $.post(my_domain+"ajax_cart_delete_coupon.php", function(result){ 1192 location.reload(true); 1193 }); 1194 }); 1195 1196 $('.cart__checkout-button').on('click', function() { 1197 var icc = $("#input-coupon-code").val(); 1198 $(this).addClass("btn-loading"); 1199 $.post(my_domain+"ajax_cart_checkout.php", {icc: icc}, function(result){ 1200 if(result!="ok") { 1201 $("#m_header h4").html("Attenzione"); 1202 $("#m_body p").html("Devi essere autenticato per concludere l'ordine."); 1203 $("#m_header") 1204 .removeClass() 1205 .addClass("modal-header") 1206 .addClass("bgred"); 1207 $("#m_body i") 1208 .removeClass() 1209 .addClass("fas fa-4x mb-3 animated tada") 1210 .addClass("red") 1211 .addClass("fa-exclamation-triangle"); 1212 $("#m_footer button").html("Chiudi"); 1213 $("#ModalWindow").modal("show"); 1214 $("#ModalWindow").on('hidden.bs.modal', function(){ 1215 window.location.href = my_domain+"it/accedi-registrati.html?ref=it/il-tuo-carrello-concludi.html"; 1216 }); 1217 1218 } else { 1219 window.location.href = my_domain+"it/il-tuo-carrello-concludi.html"; 1220 } 1221 1222 }); 1223 }); 1224 1225 $("#edit_data").on('click', function() { 1226 window.location.href = my_domain+"it/account/edit.html"; 1227 }); 1228 1229 $("#edit_addr").on('click', function() { 1230 window.location.href = my_domain+"account_address_red.php"; 1231 }); 1232 1233 $(".salvaprezzo_cond").on('click', function(e) { 1234 e.preventDefault(); 1235 e.stopPropagation(); 1236 $("#m_header h4").html("Salva il prezzo!"); 1237 $("#m_body p").addClass("text-left").html("<small>Scegliendo l'opzione <strong>Salva il prezzo!</strong> ti assicuri per il futuro la garanzia di ordinare gli stessi articoli pagando sempre la medesima cifra, anche in caso di aumenti sui nostri prezzi di listino.<br/><br/> <ul><li>Non sarà possibile eseguire variazioni sulle caratteristiche degli articoli contenuti nell'ordine replicato (tiratura, materiali, tipo di stampa, ecc.).</li><li>I file di stampa del nuovo ordine potranno essere sostituiti. I vecchi file resteranno archiviati nei nostri sistemi.</li><li>Le date di consegna del nuovo ordine verranno ricalcolate al momento dell'ordine, in base alle offerte scelte per le varie lavorazioni.</li><li>Qualora l'ordine contenesse articoli non più a catalogo, verrà riconosciuto un <strong>buono sconto</strong> utilizzabile su altri ordini, pari a ⬠3,00 per ogni lavorazione non più disponibile.</li><li>L'opzione prevede un sovrapprezzo variabile, calcolato e visibile direttamente nel carrello.</li></ul></small>"); 1238 $("#m_header") 1239 .removeClass() 1240 .addClass("modal-header") 1241 .addClass("bgyellow"); 1242 $("#m_body i") 1243 .removeClass() 1244 $("#m_footer button").html("Chiudi"); 1245 $("#ModalWindow").modal("show"); 1246 1247 }); 1248 1249 $(".side-cart button[type='submit']").on('click', function(e) { 1250 e.preventDefault(); 1251 e.stopPropagation(); 1252 1253 var form_dest = my_domain+"ajax_cart_confirm_order.php"; 1254 // TEST! 1255 //if(av) 1256 // form_dest = my_domain+"test_date_multiple.php"; 1257 // TEST! 1258 1259 $('body').css('overflow','hidden'); 1260 $(this).addClass("btn-loading"); 1261 $(".classover1").fadeTo(400,0.85); 1262 1263 1264 //var checkout_notes = $("#checkout_notes").val(); 1265 var dataString = $('#form_note').serialize(); 1266 var request = $.ajax({ 1267 url: form_dest, 1268 method: "POST", 1269 data: dataString 1270 //ContentType: "application/x-www-form-urlencoded; charset=UTF-8", 1271 //dataType: "text" 1272 }); 1273 request.done(function( result ) { 1274 tconsole("dataString: "+dataString); 1275 if(result.indexOf("FPerror")<0) { 1276 //tconsole("dataString: "+dataString); 1277 //if(av) { 1278 //$("html").html(result); 1279 //} else { 1280 setTimeout(function(){location.href=my_domain+"it/success/"+result} , 2000); 1281 //} 1282 } else { 1283 let newResult = result.replace("FPerror", ""); 1284 location.href = my_domain+"it/error/"+newResult; 1285 } 1286 }); 1287 1288 /*$.post(my_domain+"ajax_cart_confirm_order.php", { notes: checkout_notes }, function(result){ 1289 //tconsole("Result: "+result); 1290 if(result.indexOf("FPerror")<0) 1291 setTimeout(function(){location.href=my_domain+"it/success/"+result} , 2500); 1292 });*/ 1293 1294 }); 1295 1296 $('#formpaypal button').on('click', function(e) { 1297 e.preventDefault(); 1298 $(this).addClass("btn-loading"); 1299 $('#formpaypal').attr('action',my_domain+'cart_step4_PPnvp.php'); 1300 $('#formpaypal').submit(); 1301 1302 }); 1303 1304 $('#form_form_azienda, #form_form_privato, #form_form_spedizione').on('input change', function() { 1305 $(".butt_update").attr('disabled', false); 1306 }); 1307 1308 1309 $('.goorder').on('click', function() { 1310 var oid = $(this).data("oid"); 1311 window.location.href = my_domain+"account_orderpdf.php?oid="+oid; 1312 }); 1313 1314 1315 $(".list_fav").on('click','.fav_info',function() 1316 { 1317 var riga = ($(this).data('row')); 1318 $("#favdet_"+riga).toggle(350); 1319 /*var text = $(this).html(); 1320 $(this).html( 1321 text == "<i class=\"fas fa-info\"></i>" ? "<i class=\"fas fa-caret-down\"></i>" : "<i class=\"fas fa-info\"></i>");*/ 1322 }); 1323 1324 1325 $(".list_fav").on('click','.fav_delete',function() 1326 { 1327 var fav = ($(this).data('fav')); 1328 if (confirm("Vuoi cancellare questo preferito?")) { 1329 1330 $.ajax({ 1331 method: "POST", 1332 url: my_domain+"ajax_delete_preferiti.php", 1333 data: { riga: fav, tipo: 'single' }, 1334 success: function(data) { 1335 //console.log(data); 1336 if(data=='cookie') { 1337 alert("Sembra che tu non abbia effettuato l'accesso, verifica di essere effettivamente autenticato."); 1338 $(".list_fav").fadeTo(400,1); 1339 } 1340 else if(data=='success') { 1341 //alert("Complimenti, il preferito è stato rimosso dalla tua lista!"); 1342 $(".list_fav").load(my_domain+"ajax_preferiti_lista.php").fadeTo(400,1); 1343 //alert($('.list_fav .dropcart__product').length); 1344 if($('.list_fav .dropcart__product').length==1) { 1345 $(".dropcart__buttons").addClass("d-none"); 1346 } 1347 } 1348 else { 1349 alert("Si è verificato un errore generico, prova a ricaricare la pagina e ripetere la procedura."); 1350 $(".list_fav").fadeTo(400,1); 1351 } 1352 1353 } 1354 }); 1355 } 1356 }); 1357 1358 1359 $(".fav_delete_all").on('click',function() 1360 { 1361 if (confirm("Sei sicuro di voler cancellare tutti i tuoi preferiti?")) { 1362 1363 $.ajax({ 1364 method: "POST", 1365 url: my_domain+"ajax_delete_preferiti.php", 1366 data: { riga: 99999999, tipo: 'all' }, 1367 success: function(data) { 1368 //console.log(data); 1369 if(data=='cookie') { 1370 alert("Sembra che tu non abbia effettuato l'accesso, verifica di essere effettivamente autenticato."); 1371 $(".list_fav").fadeTo(400,1); 1372 } 1373 else if(data=='success') { 1374 //alert("Complimenti, tutti i preferiti sono stati rimossi dalla tua lista!"); 1375 $(".dropcart__buttons").hide(); 1376 $(".list_fav").load(my_domain+"ajax_preferiti_lista.php").fadeTo(400,1); 1377 } 1378 else { 1379 alert("Si è verificato un errore generico, prova a ricaricare la pagina e ripetere la procedura.d:"+data); 1380 $(".list_fav").fadeTo(400,1); 1381 } 1382 1383 } 1384 }); 1385 } 1386 }); 1387 1388 1389 1390 }); 1391 1392 1393 // JUMP ANNO 1394 $(function () { 1395 $('#jYear').change(function(){ 1396 var anno = $(this).val(); 1397 window.location.href = "?yn="+anno; 1398 }); 1399 }); 1400 1401 1402 // JUMP ORDINE 1 1403 $(function () { 1404 $('#jOrder').change(function(){ 1405 var ordine = $(this).val(); 1406 window.location.href = "?IDo="+ordine; 1407 }); 1408 1409 }); 1410 1411 1412 1413 1414 // JUMP ORDINE NUOVO AREA FILE 1415 $(function () { 1416 $('#jOrder_new').change(function(){ 1417 let pathParts = window.location.pathname.split("/areafile"); 1418 let pagina = pathParts[0]+"/areafile"; 1419 var ordine = $(this).val(); 1420 window.location.href = pagina+"/"+ordine; 1421 }); 1422 }); 1423 // JUMP LAVORAZIONE 1424 $(function () { 1425 $('#jLav').change(function(){ 1426 let pathParts = window.location.pathname.split("/areafile"); 1427 let pagina = pathParts[0]+"/areafile"; 1428 var lavorazione = $(this).val(); 1429 var ordine = $('#jOrder_new').val(); 1430 window.location.href = pagina+"/"+ordine+"/"+lavorazione; 1431 }); 1432 }); 1433 1434 1435 1436 1437 // JUMP COUPON 1438 $(function () { 1439 $('#jCoupon').change(function(){ 1440 var coupon = $(this).val(); 1441 window.location.href = "?show="+coupon; 1442 }); 1443 }); 1444 1445 1446 // JUMP LAVORAZIONE 1447 $(function () { 1448 1449 $("#ul_lav").on('click','a:not(.active)', function(event){ 1450 var lid = $(this).data("lid"); 1451 var oid = $(this).data("oid"); 1452 $("#ul_lav a").removeClass("active"); 1453 $(event.target).addClass("active"); 1454 dettFile(oid,lid); 1455 1456 }); 1457 }); 1458 1459 1460 // ADDRESS BUTT 1461 $(function () { 1462 $('.addr_add').click(function(){ 1463 window.location.href = my_domain+"it/account/address_new.html"; 1464 }); 1465 $('.addr_edt').click(function(){ 1466 var aid = $(this).data("id"); 1467 window.location.href = my_domain+"it/account/address_edit/"+aid+".html"; 1468 }); 1469 $('.addr_del').click(function(){ 1470 var aid = $(this).data("id"); 1471 1472 $("#m_header h4").html("Conferma"); 1473 $("#m_body p").html("Vuoi cancellare definitivamente questo indirizzo dalla tua rubrica?"); 1474 $("#m_header") 1475 .removeClass() 1476 .addClass("modal-header") 1477 .addClass("bgyellow"); 1478 $("#m_body i") 1479 .removeClass() 1480 .addClass("fas fa-4x mb-3 animated tada") 1481 .addClass("grey") 1482 .addClass("fa-trash-alt"); 1483 $("#m_footer button").html("Cancella ora").on('click', function() { 1484 $.post(my_domain+"account_address_del.php", {aid: aid}, function(result){ 1485 1486 if(result=="error") { 1487 location.reload(true); 1488 } else { 1489 $(".adc_"+aid).fadeOut(400, function(){ 1490 $(this).remove(); 1491 }); 1492 } 1493 }); 1494 1495 }); 1496 $("#ModalWindow").modal("show"); 1497 }); 1498 1499 $('.add_options').click(function(){ 1500 $(this).toggleClass("address-active"); 1501 $(this).find("span").fadeToggle(200); 1502 $(this).find("i").toggleClass("animated tada blue"); 1503 $(this).find(".option_desc").slideToggle(350); 1504 updateCart(); 1505 }); 1506 1507 $('#o1').click(function(){ 1508 if($(this).hasClass("address-active")) { 1509 if($('#contr').hasClass("payment-methods__item--active")) { 1510 alert('Il pagamento alla consegna non è disponibile per gli ordini con imballo anonimo. Il metodo di pagamento verrà variato in BONIFICO BANCARIO.'); 1511 selectPay('bonban'); 1512 } 1513 $('#contr input').prop('disabled',true); 1514 $('#contr').fadeTo(500,0.5).on('click', function() { 1515 alert('Il pagamento alla consegna non è disponibile per gli ordini con imballo anonimo.'); 1516 }); 1517 } else { 1518 checkContrassegno(); 1519 } 1520 updateCart(); 1521 }); 1522 1523 $(".addresses-list.checkout.addr .addresses-list__item").click(function(event){ 1524 if(!($(this).hasClass("address-active"))) { 1525 $(".addresses-list.checkout.addr") 1526 .find(".address-active") 1527 .removeClass("address-active"); 1528 $(".addresses-list.checkout.addr") 1529 .find(".address_desc") 1530 .slideUp(350); 1531 $(event.currentTarget) 1532 .addClass("address-active"); 1533 $(this).find(".address_desc") 1534 .slideDown(350); 1535 $(this).find("i") 1536 .addClass("animated tada"); 1537 1538 var ida = $(this).data("ida"); 1539 if(ida==1594) { 1540 //$("li#contr").fadeOut(500); 1541 $("strong#contr_spese").fadeOut(500); 1542 $("strong#contr_pagamento_tipo").html("contanti o POS"); 1543 $("div#badge_contrassegno").fadeOut(500, function() {
1544 $("div#badge_consegnafp").fadeIn(500); 1545 $("li#contr .payment-methods__item-title ititle").html("Pagamento alla consegna"); 1546 $("span#contr_pagamento_new").fadeIn(300); 1547 }); 1548 1549 //$("li#paypal").fadeOut(500); 1550 $("li#paypal").fadeTo(500,0.5).on('click', function() { 1551 alert('Il pagamento PayPal non è disponibile per gli ordini con ritiro diretto.'); 1552 }); 1553 $('#paypal input').prop('disabled',true); 1554 if($('#paypal').hasClass("payment-methods__item--active")) { 1555 alert('Il pagamento PayPal non è disponibile per gli ordini con ritiro diretto. Il metodo di pagamento verrà variato in CARTA DI CREDITO.'); 1556 selectPay('phey'); 1557 } 1558 1559 $("div#o2").fadeOut(500); 1560 if($("div#o2").hasClass("address-active")) 1561 $("div#o2").trigger('click'); 1562 $("div.divider02").fadeOut(500); 1563 $("div#o3").fadeOut(500); 1564 if($("div#o3").hasClass("address-active")) 1565 $("div#o3").trigger('click'); 1566 $("div.divider03").fadeOut(500); 1567 1568 } else { 1569 //$("li#contr").fadeIn(500); 1570 $("strong#contr_spese").fadeIn(500); 1571 $("strong#contr_pagamento_tipo").html("contanti o assegno"); 1572 $("div#badge_consegnafp").fadeOut(500, function() { 1573 $("div#badge_contrassegno").fadeIn(500); 1574 $("li#contr .payment-methods__item-title ititle").html("Contrassegno"); 1575 $("span#contr_pagamento_new").fadeOut(300); 1576 }); 1577 1578 //$("li#paypal").fadeIn(500); 1579 $('#paypal').fadeTo(500,1).off('click'); 1580 $('#paypal input').prop('disabled',false); 1581 1582 1583 $("div#o2").fadeIn(500); 1584 $("div.divider02").fadeIn(500); 1585 $("div#o3").fadeIn(500); 1586 $("div.divider03").fadeIn(500); 1587 1588 //selectPay('paypal'); 1589 } 1590 var idp = $(this).data("idp"); 1591 if(idp!='0') { 1592 if($('#contr').hasClass("payment-methods__item--active")) { 1593 alert('Il pagamento alla consegna non è disponibile per i ritiri in fermoPoint BRT. Il metodo di pagamento verrà variato in BONIFICO BANCARIO.'); 1594 selectPay('bonban'); 1595 } 1596 $('#contr input').prop('disabled',true); 1597 $('#contr').fadeTo(500,0.5).on('click', function() { 1598 alert('Il pagamento alla consegna non è disponibile per i ritiri in fermoPoint BRT.'); 1599 }); 1600 } else { 1601 checkContrassegno(); 1602 } 1603 updateCart(); 1604 } 1605 }); 1606 1607 $("#checkout-terms").click(function(){ 1608 if($(this).is(':checked')) { 1609 $(".btn-send-order").prop( "disabled", false ); 1610 } else { 1611 $(".btn-send-order").prop( "disabled", true ); 1612 } 1613 }); 1614 1615 1616 $('#couponz .products-list__item:not(.inattivo,.attivo)').mouseover(function() { 1617 $(this).css('transform','scale(1.1)'); 1618 $(this).siblings().css('filter','blur(3px)'); 1619 $(this).siblings().css('transform','scale(0.92)'); 1620 }); 1621 $('#couponz .products-list__item:not(.inattivo,.attivo)').mouseout(function() { 1622 $(this).css('transform','scale(1)'); 1623 $(this).siblings().css('filter','none'); 1624 $(this).siblings().css('transform','scale(1)'); 1625 }); 1626 1627 1628 1629 // PULSANTE PROVA PREFERITI PER NON AUTENTICATI 1630 $('.try-fav').on('click', function() { 1631 1632 $("#m_header h4").html("Autenticazione necessaria"); 1633 $("#m_body p").html("Per utilizzare questo servizio è necessario essere registrati e aver effettuato l'accesso alla propria Area Riservata."); 1634 $("#m_header") 1635 .removeClass() 1636 .addClass("modal-header") 1637 .addClass("bgred"); 1638 $("#m_body i") 1639 .removeClass() 1640 .addClass("fas fa-4x mb-3 animated tada") 1641 .addClass("red") 1642 .addClass("fa-exclamation-triangle"); 1643 $("#m_footer button").html("Chiudi"); 1644 $("#ModalWindow").modal("show"); 1645 1646 }); 1647 1648 1649 1650 1651 1652 1653 /* 1654 // offcanvas favourite 1655 */ 1656 (function() { 1657 const body = $('body'); 1658 const cart = $('.dropfav.dropcart--style--offcanvas'); 1659 1660 if (cart.length === 0) { 1661 return; 1662 } 1663 1664 function cartIsHidden() { 1665 return window.getComputedStyle(cart[0]).visibility === 'hidden'; 1666 } 1667 function showScrollbar() { 1668 body.css('overflow', ''); 1669 body.css('paddingRight', ''); 1670 } 1671 function hideScrollbar() { 1672 const bodyWidth = body.width(); 1673 body.css('overflow', 'hidden'); 1674 body.css('paddingRight', (body.width() - bodyWidth) + 'px'); 1675 } 1676 function open() { 1677 hideScrollbar(); 1678 1679 cart.addClass('dropcart--open'); 1680 } 1681 function close() { 1682 if (cartIsHidden()) { 1683 showScrollbar(); 1684 } 1685 1686 cart.removeClass('dropcart--open'); 1687 } 1688 1689 $('[data-open="offcanvas-fav"]').click(function(event){ 1690 if (!event.cancelable) { 1691 return; 1692 } 1693 1694 event.preventDefault(); 1695 1696 open(); 1697 }); 1698 1699 1700 1701 // PREFERITI DA PRODOTTO 1702 $('#tabcontent').on('click', '.add_fav', function(event){ 1703 open(); 1704 //console.log('open'); 1705 1706 /*$(".dropcart__products-list").fadeTo( 400, 0.33, function() { 1707 $(this).load(my_domain+"test_add_preferiti.php", function(response,status,xhr) { 1708 if(response=='maximum') { 1709 alert("Hai raggiunto il massimo numero di preferiti consentito. Prova ad eliminarne qualcuno per aggiungerne di nuovi."); 1710 $(this).fadeTo(400,1); 1711 } 1712 }); 1713 });*/ 1714 $(".list_fav").fadeTo( 400, 0.33, function() { 1715 $.ajax({ 1716 method: "POST", 1717 url: my_domain+"ajax_add_preferiti.php", 1718 data: { r: 0 }, 1719 1720 success: function(data) { 1721 console.log(data); 1722 if(data=='maximum') { 1723 alert("Hai raggiunto il massimo numero di preferiti consentito. Prova ad eliminarne qualcuno per aggiungerne di nuovi."); 1724 $(".list_fav").fadeTo(400,1); 1725 } 1726 else if(data=='session') { 1727 alert("La sessione è scaduta, prova a ricaricare la pagina e configurare nuovamente l'articolo."); 1728 $(".list_fav").fadeTo(400,1); 1729 } 1730 else if(data=='cookie') { 1731 alert("Sembra che tu non abbia effettuato l'accesso, verifica di essere effettivamente autenticato."); 1732 $(".list_fav").fadeTo(400,1); 1733 } 1734 else if(data=='exist') { 1735 alert("Questo preferito è già inserito nella tua lista, nessuna modifica è stata effettuata."); 1736 $(".list_fav").fadeTo(400,1); 1737 } 1738 else if(data=='success') { 1739 //alert("Complimenti, il preferito è stato aggiunto alla tua lista!"); 1740 $(".dropcart__buttons").removeClass("d-none"); 1741 $(".list_fav").load(my_domain+"ajax_preferiti_lista.php").fadeTo(400,1); 1742 1743 } 1744 else { 1745 alert("Si è verificato un errore generico, prova a ricaricare la pagina e ripetere la procedura."); 1746 $(".list_fav").fadeTo(400,1); 1747 } 1748 1749 } 1750 }); 1751 }); 1752 }); 1753 1754 1755 // PREFERITI DA CARRELLO 1756 $('.cart-fav').on('click', function(event){ 1757 var riga = ($(this).data('row')); 1758 open(); 1759 1760 $(".list_fav").fadeTo( 400, 0.33, function() { 1761 $.ajax({ 1762 method: "POST", 1763 url: my_domain+"ajax_add_preferiti.php", 1764 data: { r: riga }, 1765 success: function(data) { 1766 console.log(data); 1767 if(data=='maximum') { 1768 alert("Hai raggiunto il massimo numero di preferiti consentito. Prova ad eliminarne qualcuno per aggiungerne di nuovi."); 1769 $(".list_fav").fadeTo(400,1); 1770 } 1771 else if(data=='session') { 1772 alert("La sessione è scaduta, prova a ricaricare la pagina e configurare nuovamente l'articolo."); 1773 $(".list_fav").fadeTo(400,1); 1774 } 1775 else if(data=='cookie') { 1776 alert("Sembra che tu non abbia effettuato l'accesso, verifica di essere effettivamente autenticato."); 1777 $(".list_fav").fadeTo(400,1); 1778 } 1779 else if(data=='exist') { 1780 alert("Questo preferito è già inserito nella tua lista, nessuna modifica è stata effettuata."); 1781 $(".list_fav").fadeTo(400,1); 1782 } 1783 else if(data=='success') { 1784 //alert("Complimenti, il preferito è stato aggiunto alla tua lista!"); 1785 $(".dropcart__buttons").removeClass("d-none"); 1786 $(".list_fav").load(my_domain+"ajax_preferiti_lista.php").fadeTo(400,1); 1787 1788 } 1789 else { 1790 alert("Si è verificato un errore generico, prova a ricaricare la pagina e ripetere la procedura."); 1791 $(".list_fav").fadeTo(400,1); 1792 } 1793 1794 } 1795 }); 1796 }); 1797 }); 1798 1799 1800 1801 1802 1803 1804 1805 cart.find('.dropcart__backdrop, .dropcart__close').on('click', function(){ 1806 close(); 1807 }); 1808 1809 cart.on('transitionend', function(event){ 1810 if (cart.is(event.target) && event.originalEvent.propertyName === 'visibility' && cartIsHidden()) { 1811 showScrollbar(); 1812 } 1813 }); 1814 })(); 1815 1816 1817 1818 1819 }); 1820 1821 1822 1823})(jQuery); 1824 1825 1826 1827function dettFile(IDo,IDl) { 1828 $.post(my_domain+"ajax_upload.php", { 1829 oid: IDo, 1830 lid: IDl 1831 }, 1832 function(result){ 1833 if(result=="error") { 1834 window.location.href = my_domain+"it/accedi-registrati.html"; 1835 } else { 1836 $("#bodyupload").html(result); 1837 } 1838 }); 1839} 1840function tconsole(stringa) { 1841 console.log('TC: '+stringa); 1842} 1843 1844 1845function selectPay(idpag) { 1846 1847 var allLi = "ul.payment-methods__list li"; 1848 1849 $(allLi) 1850 .removeClass("payment-methods__item--active"); 1851 $(allLi+" input") 1852 .prop("checked", false); 1853 $(allLi+" span.payment-methods__item-title") 1854 .removeClass("blue") 1855 .removeClass("font-weight-bold"); 1856 //$(allLi+" i.fab") 1857 //.removeClass("blue"); 1858 1859 $(allLi+"#"+idpag) 1860 .addClass("payment-methods__item--active"); 1861 $(allLi+"#"+idpag+" input") 1862 .prop("checked", true); 1863 $(allLi+"#"+idpag+" span.payment-methods__item-title") 1864 .addClass("blue") 1865 .addClass("font-weight-bold"); 1866 //$(allLi+"#"+idpag+" i.fab") 1867 //.addClass("blue"); 1868} 1869 1870 1871function updateCart() { 1872 var o1 = 0; 1873 var o2 = 0; 1874 var o3 = 0; 1875 var o4 = 0; 1876 var tp = $('[name="checkout_payment_method"]:checked').val(); 1877 var sa = $(".addresses-list.checkout.addr").find(".address-active").data("ida"); 1878 1879 if($("#o1").hasClass("address-active")) o1=1; 1880 if($("#o2").hasClass("address-active")) o2=1; 1881 if($("#o3").hasClass("address-active")) o3=1; 1882 if($("#o4").hasClass("address-active")) o4=1; 1883 1884 var arrstring = o1+"|"+o2+"|"+o3+"|"+o4+"|"+tp+"|"+sa; 1885 1886 $(".side-cart button:enabled").addClass("btn-loading"); 1887 $(".my-cart").fadeTo( 400, 0.33, function() { 1888 $(this).load(my_domain+"ajax_cart_resume.php", { astr:arrstring }, function(response,status,xhr) { 1889 if(response!='error') { 1890 $(this).fadeTo(400,1); 1891 $(".side-cart button:enabled").removeClass("btn-loading");
1892 $(".dropcart__totals").load(my_domain+"ajax_cart_drop.php"); 1893 } 1894 }); 1895 }); 1896 1897} 1898 1899 1900function checkContrassegno() { 1901 $('#contr').off('click'); 1902 1903 var o1 = 0; 1904 var idp = $(".addresses-list.checkout.addr").find(".address-active").data("idp"); 1905 if($("#o1").hasClass("address-active")) o1=1; 1906 1907 if(o1==0 && idp=="0") { 1908 $('#contr').fadeTo(500,1).off('click'); 1909 $('#contr input').prop('disabled',false); 1910 } else { 1911 $('#contr input').prop('disabled',true); 1912 $('#contr').fadeTo(500,0.5).on('click', function() { 1913 alert('Il pagamento alla consegna non è disponibile per i ritiri in fermoPoint BRT e per gli ordini con imballo anonimo.'); 1914 }); 1915 } 1916} 1917 1918 1919 1920 1921 1922 1923function stopScrolling(e) { 1924 e.preventDefault(); 1925 e.stopPropagation(); 1926 return false; 1927} 1928 1929 1930function scrollTabs(idt,back) { 1931 var tab_dim_tot = 0; 1932 $('#tabmenu li').each(function() { 1933 tab_dim_tot += $(this).outerWidth(); 1934 }); 1935 tab_dim_tot += 5; 1936 var container_dim = $("#tabhead").outerWidth(); 1937 var menu_pos = $("#tabmenu").position().left; 1938 var tab_pos = $("#tabmenu li#tab"+idt).position().left; 1939 var tab_dim = $("#tabmenu li#tab"+idt).outerWidth(); 1940 var tab_center_pos = tab_pos+(tab_dim/2)+menu_pos;
1941 var container_center = container_dim/2; 1942 var offset_spost = (container_center-tab_pos-(tab_dim/2)); 1943 1944 if(back==1) { 1945 if(tab_center_pos<container_center) { 1946 if(offset_spost>0) { 1947 offset_spost=0; 1948 } 1949 $('#tabmenu').animate({left: offset_spost},500, function() { 1950 }); 1951 } 1952 } else { 1953 if(tab_center_pos>container_center && (tab_dim_tot+menu_pos)>=container_dim) { 1954 $('#tabmenu').animate({left: offset_spost},500); 1955 } 1956 } 1957 1958 /*tconsole("menu_pos: "+menu_pos); 1959 tconsole("tab_pos: "+tab_pos); 1960 tconsole("container_dim: "+container_dim); 1961 tconsole("tab_center_pos: "+tab_center_pos); 1962 tconsole("offset_spost: "+offset_spost); 1963 tconsole("tab_dim_tot: "+tab_dim_tot);*/ 1964 1965 1966} 1967 1968 1969function reOrder(IDart,oil){ 1970 window.location.href = my_domain+"it/reorder/"+IDart+"/"+oil+"/"; 1971} 1972 1973 1974 1975 1976function applicaSeparatore2(importoNumerico){ 1977 var importo = importoNumerico.toString(); 1978 // Suggerimento di Andrea Rufo 1979 importo = importo.replace(".", ",") 1980 if(importo.length>3){ 1981 importo = importo.split('',importo.length).reverse().join('').replace(/([0-9]{3})/g,'$1.'); 1982 importo = importo.split('',importo.length).reverse().join(''); 1983 } 1984 // Riduzione degli IF proposti da Francesco 1985 return importo.replace(/^\./,''); 1986} 1987
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.