Advertisement
reggs

UI Stuff

Aug 19th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2.  
  3. //Code to fill the size boxes on the product page. THIS IS BEING USED!
  4. jQuery('#picker_choose-size li label').click(function() {
  5.     console.log('Clicked!');
  6.     // Out with the old...
  7.     jQuery('#picker_choose-size li').removeClass("highlighted");
  8.  
  9.     // ...and in with the new
  10.     jQuery(this).closest('li').addClass('highlighted');
  11.     console.log('Finished');
  12. });
  13.  
  14.  
  15. jQuery('.select-option.swatch-wrapper').tooltip({
  16.     items: "[data-tooltip]",
  17.     content: function () {
  18.         return jQuery('.tooltip1').attr("data-tooltip");
  19.     }
  20. });
  21.  
  22. jQuery('.page-id-174 #picker_addon > div:nth-child(2)').on('click',function(){
  23.  
  24.     jQuery('.gallery-2').hide();
  25.     jQuery('.gallery-21').hide();
  26.     jQuery('.gallery-3').hide();
  27.     jQuery('.gallery-31').hide();
  28.     jQuery('.gallery-1').show('slow');
  29.     jQuery('.gallery-11').show();
  30.  
  31.     gallerySrc = '//agilitybed.com/wp-content/uploads/2017/03/1-mattress.jpg'
  32.     swapPic.attr('src',gallerySrc);
  33.     swapPic.attr('srcset',gallerySrc);
  34.  
  35. });
  36. jQuery('.page-id-174 #picker_addon > div:nth-child(3)').on('click',function(){
  37.  
  38.     jQuery('.gallery-2').show('slow');
  39.     jQuery('.gallery-21').show();
  40.     jQuery('.gallery-3').hide();
  41.     jQuery('.gallery-31').hide();
  42.     jQuery('.gallery-1').hide();
  43.     jQuery('.gallery-11').hide();
  44.  
  45.     gallerySrc = '//agilitybed.com/wp-content/uploads/2017/03/2-foundation.jpg'
  46.     swapPic.attr('src',gallerySrc);
  47.     swapPic.attr('srcset',gallerySrc);
  48.  
  49. });
  50. jQuery('.page-id-174 #picker_addon > div:nth-child(4)').on('click',function(){
  51.  
  52.     jQuery('.gallery-2').hide();
  53.     jQuery('.gallery-21').hide();
  54.     jQuery('.gallery-3').show('slow');
  55.     jQuery('.gallery-31').show();
  56.     jQuery('.gallery-1').hide();
  57.     jQuery('.gallery-11').hide();
  58.  
  59.     gallerySrc = '//agilitybed.com/wp-content/uploads/2017/03/1-mattress0428-1.jpg'
  60.     swapPic.attr('src',gallerySrc);
  61.     swapPic.attr('srcset',gallerySrc);
  62.  
  63. });
  64.  
  65. jQuery(function($){
  66.     descriptionButton = $('body .mat-desc-acc .q_accordion_holder.accordion h5.ui-accordion-header:nth-child(1)');
  67.     deliveryButton = $('body .mat-desc-acc .q_accordion_holder.accordion h5.ui-accordion-header:nth-child(3)');
  68.     certificationButton = $('body .mat-desc-acc .q_accordion_holder.accordion h5.ui-accordion-header:nth-child(5)');
  69.  
  70.     descriptionText = $('.mat-desc-acc .ui-accordion-header:nth-child(1) .tab-title');
  71.     deliveryText = $('.mat-desc-acc .ui-accordion-header:nth-child(3) .tab-title');
  72.     certificationText = $('.mat-desc-acc .ui-accordion-header:nth-child(5) .tab-title');
  73.  
  74.     descriptionButton.on('click',function(){
  75.         console.log('before if');
  76.  
  77.         if(descriptionText.text() === "- DESCRIPTION")
  78.         {
  79.             console.log('close');
  80.             descriptionText.html('+ DESCRIPTION');
  81.  
  82.             console.log('after');
  83.         }
  84.         else{
  85.             console.log('open');
  86.             descriptionText.html('- DESCRIPTION');
  87.         }
  88.  
  89.         deliveryText.html('+ DELIVERY & SETUP');
  90.         certificationText.html('+ CERTIFICATIONS');
  91.         console.log('Plus Switch Outside 1');
  92.     });
  93.  
  94.     deliveryButton.on('click',function(){
  95.         console.log('before if');
  96.  
  97.         if(deliveryText.text() === "- DELIVERY & SETUP")
  98.         {
  99.             console.log('close');
  100.             deliveryText.html('+ DELIVERY & SETUP');
  101.  
  102.             console.log('after');
  103.         }
  104.         else{
  105.             console.log('open');
  106.             deliveryText.html('- DELIVERY & SETUP');
  107.         }
  108.  
  109.         descriptionText.html('+ DESCRIPTION');
  110.         certificationText.html('+ CERTIFICATIONS');
  111.         console.log('Plus Switch Outside 1');
  112.     });
  113.  
  114.     certificationButton.on('click',function(){
  115.         console.log('before if 3');
  116.  
  117.         if(certificationText.text() === "- CERTIFICATIONS")
  118.         {
  119.             console.log('close 3');
  120.             certificationText.html('+ CERTIFICATIONS');
  121.  
  122.             console.log('after 3');
  123.         }
  124.         else{
  125.             console.log('open 3');
  126.             certificationText.html('- CERTIFICATIONS');
  127.         }
  128.         descriptionText.html('+ DESCRIPTION');
  129.         deliveryText.html('+ DELIVERY & SETUP');
  130.         console.log('Plus Switch Outside 3');
  131.     });
  132.  
  133.  
  134.     jQuery('.page-id-174 #picker_addon > div:nth-child(2)').on('click',function(){
  135.         jQuery('.mat-only-switch').show();
  136.         jQuery('.foundation-only-switch').hide();
  137.         jQuery('.adjustable-only-switch').hide();
  138.         jQuery('#product-102 .size-shop_single').attr('src','//agilitybed.com/wp-content/uploads/2017/03/1-mattress-600x446.jpg');
  139.     });
  140.  
  141.     jQuery('.page-id-174 #picker_addon > div:nth-child(3)').on('click',function(){
  142.         jQuery('.mat-only-switch').hide();
  143.         jQuery('.foundation-only-switch').show();
  144.         jQuery('.adjustable-only-switch').hide();
  145.         jQuery('#product-102 .size-shop_single').attr('src','//agilitybed.com/wp-content/uploads/2017/03/2-foundation.jpg');
  146.  
  147.     });
  148.  
  149.     jQuery('.page-id-174 #picker_addon > div:nth-child(4)').on('click',function(){
  150.         jQuery('.mat-only-switch').hide();
  151.         jQuery('.foundation-only-switch').hide();
  152.         jQuery('.adjustable-only-switch').show();
  153.         jQuery('#product-102 .size-shop_single').attr('src','//agilitybed.com/wp-content/uploads/2017/03/1-mattress0428-1.jpg');
  154.  
  155.     });
  156.  
  157.  
  158.     smallBeds = $('#wc_checkout_add_ons_2_field');
  159.     largeBeds = $('#wc_checkout_add_ons_3_field');
  160.  
  161.     addonSmall = $('.sfn-cart-addons .post-906');
  162.     addonLarge = $('.sfn-cart-addons .post-913');
  163.  
  164.     addonField = $('.sfn-cart-addons');
  165.  
  166.  
  167.     addonTypeSmall = $('.variation-Addon p:contains("Mattress"), .variation-Addon p:contains("Mattress + Foundation")');
  168.     sizeTypeSmall = $('.variation-ChooseSize p:contains("TWIN"), .variation-ChooseSize p:contains("TWIN XL"), .variation-ChooseSize p:contains("FULL") ' );
  169.  
  170.     addonTypeLarge = $('.variation-Addon p:contains("Mattress"), .variation-Addon p:contains("Mattress + Foundation")');
  171.     sizeTypeLarge = $('.variation-ChooseSize p:contains("QUEEN"), .variation-ChooseSize p:contains("KING"), .variation-ChooseSize p:contains("CAL KING") ' );
  172.  
  173.     smallBedCheck = $('[data-product_sku="twin-001"], [data-product_sku="twin-002"], [data-product_sku="twinxl-001"], [data-product_sku="twinxl-002"], [data-product_sku="full-001"], [data-product_sku="full-002"]');
  174.     largeBedCheck = $('[data-product_sku="queen-001"], [data-product_sku="queen-002"], [data-product_sku="king-001"], [data-product_sku="king-002"], [data-product_sku="calking-001"], [data-product_sku="calking-002"]');
  175.  
  176.     if (smallBedCheck.length > 0) {
  177.         addonSmall.show();
  178.         addonField.show();
  179.     }
  180.     if (largeBedCheck.length > 0) {
  181.         addonLarge.show();
  182.         addonField.show();
  183.     }
  184.  
  185.     jQuery(".page-id-174 #picker_addon > div:nth-child(3)").addClass('starting-fade');
  186.     jQuery(".page-id-174 #picker_addon > div:nth-child(4)").addClass('starting-fade');
  187.  
  188.     $("#read-more-btny").click(function(e) {
  189.         e.preventDefault();
  190.         $("#read-less-btny").show();
  191.         $("#read-more-btny").hide();
  192.         $( ".hidden-reviews0519" ).show( "slow" );
  193.         console.log('readmore test');
  194.  
  195.     });
  196.     $("#read-less-btny").click(function(e) {
  197.         e.preventDefault();
  198.         $("#read-less-btny").hide();
  199.         $("#read-more-btny").show();
  200.         $( ".hidden-reviews0519" ).hide( "slow" );
  201.         console.log('readmore test');
  202.  
  203.     });
  204.  
  205.     galleryBtny = $('.mo-gallery-img');
  206.     swapPic = $('img.attachment-shop_single.size-shop_single.wp-post-image');
  207.     zoomPic = $('a.woocommerce-main-image.zoom');
  208.  
  209.     galleryBtny.on('click',function(e){
  210.         e.preventDefault();
  211.         gallerySrc = $(this).attr('href');
  212.         gallerySrcHero = $(this).attr('rel');
  213.         swapPic.attr('src',gallerySrc);
  214.         swapPic.attr('srcset',gallerySrcHero);
  215.         zoomPic.attr('href',gallerySrc);
  216.         console.log($(this).find('img').attr('src'));
  217.         console.log('she ran');
  218.     });
  219.  
  220.     jQuery('.videoPopUpLink a').on('click',function() {
  221.          $n.fancybox({
  222.                      'overlayColor':'#000000',
  223.                      'hideOnOverlayClick':false,
  224.                      'padding': 0,
  225.                      'autoScale': true,
  226.                      'autoDimensions': false,
  227.                      'showCloseButton': true,
  228.                      'content':'<iframe src="https://player.vimeo.com/video/217874617?color=334a6d&title=0&byline=0&portrait=0&autoplay=1" width="100%" height="100%" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>',
  229.                      'transitionIn':'fade',
  230.                      'transitionOut':'elastic',
  231.                      'width': window.innerWidth < 768 ? parseInt(window.innerWidth*90/100) : 768,
  232.                      'height': window.innerWidth < 768 ? parseInt(window.innerWidth*90/100)/1.77778 : 432
  233.              });
  234.     });
  235.  
  236.     jQuery('.videoPopUpLinkFoundation a').on('click',function() {
  237.         $n.fancybox({
  238.             'overlayColor':'#000000',
  239.             'hideOnOverlayClick':false,
  240.             'padding': 0,
  241.             'autoScale': true,
  242.             'autoDimensions': false,
  243.             'showCloseButton': true,
  244.             'content':'<iframe src="https://player.vimeo.com/video/217874567?color=334a6d&title=0&byline=0&portrait=0&autoplay=1" width="100%" height="100%" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>',
  245.             'transitionIn':'fade',
  246.             'transitionOut':'elastic',
  247.             'width': window.innerWidth < 768 ? parseInt(window.innerWidth*90/100) : 768,
  248.             'height': window.innerWidth < 768 ? parseInt(window.innerWidth*90/100)/1.77778 : 432
  249.         });
  250.     });
  251.  
  252.     jQuery('#wptbheadline1 img').on('click',function(){
  253.         $('.header_inner_left').removeClass('top-bar-spacing')
  254.     });
  255.  
  256.     $('#newsletter_signup2 img').bind('touchstart touchend touchup', function(event) {
  257.         event.stopPropagation();
  258.     });
  259.  
  260. });
  261.  
  262. jQuery('a.swatch-anchor').on('click',function(){
  263.     jQuery(".page-id-174 #picker_addon > div:nth-child(3)").removeClass('starting-fade');
  264.     jQuery(".page-id-174 #picker_addon > div:nth-child(4)").removeClass('starting-fade');
  265.     if (this.classList.contains('cleary-bg')){
  266.         jQuery("a.swatch-anchor").removeClass('more-fadey-bg');
  267.         jQuery("a.swatch-anchor").removeClass('cleary-bg');
  268.     }else{
  269.         console.log('clicked2');
  270.         jQuery("a.swatch-anchor").addClass('more-fadey-bg');
  271.         jQuery("a.swatch-anchor").removeClass('cleary-bg');
  272.         jQuery(this).removeClass('more-fadey-bg');
  273.         jQuery(this).addClass('cleary-bg');
  274.         console.log('finished2');
  275.         console.log(jQuery(this).attr('title'));
  276.     }
  277.     if (jQuery(this).attr('title').indexOf('Adjustable') > -1 ){
  278.         jQuery('.swatch-control.radio-select li').addClass('more-widthy');
  279.     }
  280.     else{
  281.         jQuery('.swatch-control.radio-select li').removeClass('more-widthy');
  282.     }
  283. });
  284.  
  285. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement