www.truthinaging.com Open in urlscan Pro
207.32.178.91  Public Scan

URL: https://www.truthinaging.com/skin/frontend/tia/2016/js/custom.js
Submission: On June 15 via manual from US — Scanned from DE

Form analysis 0 forms found in the DOM

Text Content

/**
 * Created by olga on 6/9/2016.
 */
jQuery(document).ready(function () {
  var windowWidth = jQuery(window).width();
  var $submenu = jQuery('#subnav');
  var subnavItem = jQuery($submenu).find('li.level0');

  subnavItem.on('mouseover', function () {
    if (jQuery(this).find('ul.level0').size() === 0) {
      jQuery(this).addClass('hover');
    }
  });
  subnavItem.on('mouseleave', function () {
    jQuery(this).removeClass('hover');
  });

  jQuery('.menu_icon').on('click', function (e) {
    jQuery(this).siblings('ul').addClass('active');
    jQuery(this).siblings('.close').addClass('active');
  });
  jQuery('.close').on('click', function (e) {
    jQuery(this).siblings('ul').removeClass('active');
    jQuery(this).removeClass('active');
  });

  if (windowWidth <= 950 && windowWidth >= 460) {
    var sliderText = jQuery('.slider_holder');
    var maxHeight = 0;
    sliderText.each(function (e, i) {
      if (jQuery(this).height() > maxHeight) {
        maxHeight = jQuery(this).outerHeight();
      }
    });
    sliderText.each(function (e, i) {
      jQuery(this).css('height', maxHeight);
    });

    jQuery('.block_content.top_block').css('padding-top', maxHeight + 15);
  }

  var starsCount = 5;
  var $starsHolder = jQuery('.rating');
  var starsHolderWidth = jQuery($starsHolder).width();
  var activeStarsCount = jQuery($starsHolder)
    .find('.active_block')
    .data('stars');
  var starWidth = starsHolderWidth / starsCount;

  var activeStarsWidth = activeStarsCount * starWidth;
  var activeBlockWidth = (activeStarsWidth * 100) / starsHolderWidth;

  jQuery($starsHolder)
    .find('.active_block')
    .css('width', activeBlockWidth + '%');

  var openCommentFormBtn = jQuery('.open_comment_form');
  openCommentFormBtn.on('click', function () {
    jQuery(this).closest('#postComment').addClass('open_comment');
  });
  jQuery('#cancel').on('click', function () {
    jQuery(this).closest('#postComment').removeClass('open_comment');
  });

  if (jQuery('.add_to_cart_holder').size() > 0) {
    var input = jQuery('#qty_input');

    jQuery('#increase').on('click', function () {
      input.value = parseInt(input.value, 10) + 1;
    });

    jQuery('#decrease').on('click', function () {
      console.log(input.val() > 1);
      if (input.val() > 1) {
        input.value = parseInt(input.value, 10) - 1;
      }
    });
  }
  if (jQuery('.col-qty').size() > 0 || jQuery('.add-to-cart').size() > 0) {
    var $qtyHolder = jQuery('.qty.input');

    jQuery('.increase').on('click', function () {
      var currentInput = jQuery(this).closest($qtyHolder).find('input');
      currentInput.val(parseInt(currentInput.val(), 10) + 1);
    });

    jQuery('.decrease').on('click', function () {
      var currentInput = jQuery(this).closest($qtyHolder).find('input');
      if (currentInput.val() > 1) {
        currentInput.val(parseInt(currentInput.val(), 10) - 1);
      }
    });
  }

  jQuery('#add_comment').on('click', function (e) {
    e.preventDefault();

    jQuery('body').addClass('open_popup_form');
    jQuery('#review_form').css('display', 'block');
  });
  jQuery('#review_form').on('click', function (e) {
    if (e.target === this) {
      jQuery('body').removeClass('open_popup_form');
      jQuery(this).css('display', 'none');
    }
  });

  jQuery('#close_btn').on('click', function () {
    jQuery('body').removeClass('open_popup_form');
    jQuery('#review_form').css('display', 'none');
  });
  jQuery('.open_comment_link').on('click', function (e) {
    e.preventDefault();
    jQuery('.tabs-nav li').each(function (i) {
      jQuery(this).removeClass('active');
    });
    jQuery('.tabs-content').each(function () {
      jQuery(this).css('display', 'none');
    });

    jQuery('.tabs').css('padding-top', '330px');
    jQuery('.our_take_holder').css('opacity', 1);

    jQuery('#product_tabs_review_tabbed').addClass('active');
    jQuery('#product_tabs_review_tabbed_contents').css('display', 'block');

    jQuery('body').addClass('open_popup_form');
    jQuery('#review_form').css('display', 'block');
  });
  var customerReviews = jQuery('#customer-reviews');
  if (customerReviews.find('.our_take_holder').size() > 0) {
    jQuery('.tabs').css(
      'padding-top',
      customerReviews.find('.our_take_holder').height() + 60
    );
  }
  jQuery('.tabs-nav li').on('click', function () {
    if (!jQuery('#product_tabs_review_tabbed').hasClass('active')) {
      jQuery('.tabs').css('padding-top', '40px');
      jQuery('.our_take_holder').css('opacity', 0);
    } else {
      jQuery('.tabs').css(
        'padding-top',
        customerReviews.find('.our_take_holder').height() + 60
      );
      jQuery('.our_take_holder').css('opacity', 1);
    }
  });

  // ========= Mobile Header
  jQuery('#subnav .nav-container li').each(function () {
    if (jQuery(this).hasClass('parent')) {
      jQuery(this).append('<span class="toggle"></span>');
    }
  });

  jQuery('.parent .toggle').on('click', function () {
    if (jQuery(this).parent().hasClass('active-parent-item')) {
      jQuery(this).parent().removeClass('active-parent-item');
    } else {
      jQuery(this).parent().addClass('active-parent-item');
    }
  });

  var subnavList = jQuery('#subnav .nav-container');
  jQuery('#subnav .mobile_title').on('click', function () {
    if (parseInt(subnavList.css('height'), 10) === 0) {
      // subnavList.css('max-height', subnavList.find('ul').height());
      subnavList.addClass('open');
      jQuery(this).addClass('open_submenu');
    } else {
      subnavList.removeClass('open');
      jQuery(this).removeClass('open_submenu');
    }
  });

  /*if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ||windowWidth <= 988 ) {
     jQuery('li.level0 a').one('click', function(e) {
     e.preventDefault();
     var secondLevelList = jQuery(this).closest('li').find('ul.level0');

     subnavList.css('max-height', subnavList.height() + secondLevelList.height());
     console.log(subnavList.height() + secondLevelList.height());
     })
     }*/
  if (windowWidth < 769) {
    jQuery('.filter-panel h3').on('click', function () {
      var filterContent = jQuery(this)
        .closest('.filter-panel')
        .find('.block-content');
      if (filterContent.hasClass('open')) {
        filterContent.removeClass('open');
        filterContent.css('max-height', 0);
      } else {
        filterContent.addClass('open');
        filterContent.css('max-height', jQuery('#narrow-by-list').height());
      }
    });
  }
  if (windowWidth <= 916) {
    jQuery('.mobile_menu_button').on('click', function () {
      var myaccountMenu = jQuery(this)
        .closest('.sidebar ')
        .find('.myaccount-menu');
      if (jQuery(this).hasClass('open')) {
        jQuery(this).removeClass('open');
        myaccountMenu.removeClass('open');
        myaccountMenu.css('max-height', 0);
      } else {
        jQuery(this).addClass('open');
        myaccountMenu.addClass('open');
        myaccountMenu.css('max-height', myaccountMenu.find('ul').height());
      }
    });
  }

  if (jQuery('.tabs').size() > 0) {
    var tabsNav = jQuery('.tabs-nav');
    var tabsWidth = 0;
    tabsNav.find('li').each(function () {
      tabsWidth += jQuery(this).width();
    });
    console.log(tabsWidth);
    console.log(jQuery(window).width());
    if (tabsWidth >= jQuery(window).width() - 26) {
      tabsNav.addClass('full');
    }
  }

  var paymentTypeCard = jQuery('#payment_step .type_card .dropdown-status');
  switch (paymentTypeCard.text()) {
    case 'American Express':
      paymentTypeCard.addClass('american_express');
      break;
    case 'Visa':
      paymentTypeCard.addClass('visa');
      break;
    case 'MasterCard':
      paymentTypeCard.addClass('master_card');
      break;
    case 'Discover':
      paymentTypeCard.addClass('discover');
      break;
    default:
      paymentTypeCard.css({ color: '#303030', width: 'auto' });
  }

  jQuery('.dropdown-menu.type_card .dropdown-menu-content a').on(
    'click',
    function () {
      switch (jQuery(this).find('span').text()) {
        case 'American Express':
          paymentTypeCard.removeClass();
          paymentTypeCard.addClass('dropdown-status american_express');
          break;
        case 'Visa':
          paymentTypeCard.removeClass();
          paymentTypeCard.addClass('dropdown-status visa');
          break;
        case 'MasterCard':
          paymentTypeCard.removeClass();
          paymentTypeCard.addClass('dropdown-status master_card');
          break;
        case 'Discover':
          paymentTypeCard.removeClass();
          paymentTypeCard.addClass('dropdown-status discover');
          break;
        default:
          paymentTypeCard.removeClass();
          paymentTypeCard.css({ color: '#303030', width: 'auto' });
      }
    }
  );
  // paymentTypeCard.on('DOMSubtreeModified', paymentTypeCard, function() {
  //     switch(paymentTypeCard.text()) {
  //         case 'American Express':
  //             paymentTypeCard.removeClass();
  //             paymentTypeCard.addClass('dropdown-status american_express');
  //             break;
  //         case 'Visa':
  //             paymentTypeCard.removeClass();
  //             paymentTypeCard.addClass('dropdown-status visa');
  //             break;
  //         case 'MasterCard':
  //             paymentTypeCard.removeClass();
  //             paymentTypeCard.addClass('dropdown-status master_card');
  //             break;
  //         case 'Discover':
  //             paymentTypeCard.removeClass();
  //             paymentTypeCard.addClass('dropdown-status discover');
  //             break;
  //         default:
  //             paymentTypeCard.removeClass();
  //             paymentTypeCard.css({'color': '#303030', 'width': 'auto'});
  //     }
  // });

  //checkout steps
  //billing

  jQuery('#btn_billing').on('click', function () {
    var nextStep = true;

    jQuery('.billingAddress .required-entry:visible').each(function () {
      if (jQuery(this).val() == '') {
        nextStep = false;
        jQuery(this).css({ border: '1px solid #e01d1d' });
      } else {
        jQuery(this).css({ border: '1px solid #d7d7d7' });
      }
    });

    jQuery('.billingAddress .required-entry:visible').change(function () {
      if (jQuery(this).val() != '') {
        jQuery(this).css({ border: '1px solid #d7d7d7' });
      }
    });

    if (
      !jQuery('.shipment-methods .validate-one-required-by-name:checked').val()
    ) {
      nextStep = false;

      jQuery('.error_msg').remove();
      jQuery(
        "<p class='error_msg' style='color:#e01d1d'>Please Select Shipping Method</p>"
      ).insertBefore('.checkout-col:not(.cart-summary .checkout-col)');

      jQuery('.checkout-col:not(.cart-summary .checkout-col)').css({
        border: '1px solid #e01d1d',
      });
    } else {
      jQuery(this).css({ border: '1px solid #d7d7d7' });
    }

    jQuery('.shipment-methods .validate-one-required-by-name').change(
      function () {
        if (
          jQuery(
            '.shipment-methods .validate-one-required-by-name:checked'
          ).val()
        ) {
          jQuery('.error_msg').remove();
          jQuery('.checkout-col:not(.cart-summary .checkout-col)').css({
            border: '1px solid #d7d7d7',
          });
        }
      }
    );

    if (nextStep == false) {
      return false;
    }

    jQuery('#billing_step').hide();
    jQuery('#payment_step').show();
    jQuery('#payment_position').addClass('active_position');
    jQuery('#return_cart').hide();
    jQuery('#return_shipping').show();
    jQuery('#p_method_gene_braintree_creditcard').click();
  });
  //payment
  jQuery('#btn_payment').on('click', function () {
    //debugger;
    jQuery('#checkout-payment-method-load').find('.error_message').remove();
    jQuery('.dropdown-select.type_card').css('box-shadow', 'none');
    jQuery(
      '#checkout-payment-method-load .payment-validation-error'
    ).removeClass('payment-validation-error');
    if (jQuery('#p_method_wsnyc_authorizenet:checked').val()) {
      if (
        jQuery('#wsnyc_authorizenet_payment_id').length &&
        jQuery('.wsnyc_authorizenet_new_card').css('display') == 'none'
      ) {
        if (jQuery('#wsnyc_authorizenet_payment_id').val()) {
          jQuery('#payment_step').hide();
          jQuery('#confirm_step').show();
          jQuery('#confirm_position').addClass('active_position');
          jQuery('#return_shipping').hide();
          jQuery('#return_payment').show();
        } else {
          var error_message = 'Please select method of payment';
          jQuery('#wsnyc_authorizenet_payment_id')
            .closest('.input-box')
            .addClass('payment-validation-error')
            .prepend(
              '<span class="error_message">' + error_message + '</span>'
            );
        }
      } else {
        var wsnyc_authorizenet_cc_number = jQuery(
          '#wsnyc_authorizenet_cc_number'
        );
        var wsnyc_authorizenet_choldder_name = jQuery(
          '#wsnyc_authorizenet_choldder_name'
        );
        var wsnyc_authorizenet_expiration = jQuery(
          '#wsnyc_authorizenet_expiration'
        );
        var wsnyc_authorizenet_expiration_yr = jQuery(
          '#wsnyc_authorizenet_expiration_yr'
        );
        var wsnyc_authorizenet_cc_cid = jQuery('#wsnyc_authorizenet_cc_cid');
        var wsnyc_authorizenet_cc_type = jQuery('#wsnyc_authorizenet_cc_type');

        if (
          wsnyc_authorizenet_cc_type.val() != 'Saved card' &&
          wsnyc_authorizenet_cc_number.val() &&
          wsnyc_authorizenet_choldder_name.val() &&
          wsnyc_authorizenet_expiration.val() &&
          wsnyc_authorizenet_expiration_yr.val() &&
          wsnyc_authorizenet_cc_cid.val()
        ) {
          jQuery('#payment_step').hide();
          jQuery('#confirm_step').show();
          jQuery('#confirm_position').addClass('active_position');
          jQuery('#return_shipping').hide();
          jQuery('#return_payment').show();
        } else {
          var error_message = 'Please enter vaild detail';

          if (!wsnyc_authorizenet_cc_number.val()) {
            wsnyc_authorizenet_cc_number
              .closest('.wsnyc_authorizenet_new_card')
              .addClass('payment-validation-error')
              .prepend(
                '<span class="error_message">' + error_message + '</span>'
              );
          } else if (wsnyc_authorizenet_cc_type.val() == 'Saved card') {
            wsnyc_authorizenet_cc_number
              .closest('.wsnyc_authorizenet_new_card')
              .prepend(
                '<span class="error_message" style="color:red;">Please select card type</span>'
              );
            jQuery('.dropdown-select.type_card').css(
              'box-shadow',
              '0 0 0 1px red'
            );
          }
          if (!wsnyc_authorizenet_choldder_name.val()) {
            wsnyc_authorizenet_choldder_name
              .closest('.wsnyc_authorizenet_new_card')
              .addClass('payment-validation-error')
              .prepend(
                '<span class="error_message">' + error_message + '</span>'
              );
          }
          if (!wsnyc_authorizenet_expiration.val()) {
            wsnyc_authorizenet_expiration
              .closest('.v-fix')
              .addClass('payment-validation-error')
              .prepend(
                '<span class="error_message">' + error_message + '</span>'
              );
          }
          if (!wsnyc_authorizenet_expiration_yr.val()) {
            wsnyc_authorizenet_expiration_yr
              .closest('.v-fix')
              .addClass('payment-validation-error')
              .prepend(
                '<span class="error_message">' + error_message + '</span>'
              );
          }
          if (!wsnyc_authorizenet_cc_cid.val()) {
            wsnyc_authorizenet_cc_cid
              .closest('.v-fix')
              .addClass('payment-validation-error')
              .prepend(
                '<span class="error_message">' + error_message + '</span>'
              );
          }
        }
      }
    } else {
      jQuery('#payment_step').hide();
      jQuery('#confirm_step').show();
      jQuery('#confirm_position').addClass('active_position');
      jQuery('#return_shipping').hide();
      jQuery('#return_payment').show();
    }
  });
  jQuery('#wsnyc_authorizenet_payment_id').on('change', function () {
    jQuery(this)
      .closest('.wsnyc_authorizenet_new_card')
      .find('.error_message')
      .remove();
    jQuery(this)
      .closest('.wsnyc_authorizenet_new_card')
      .removeClass('payment-validation-error');
  });
  jQuery('#wsnyc_authorizenet_cc_number').on('change', function () {
    jQuery(this)
      .closest('.wsnyc_authorizenet_new_card')
      .find('.error_message')
      .remove();
    jQuery(this)
      .closest('.wsnyc_authorizenet_new_card')
      .removeClass('payment-validation-error');
  });
  jQuery('#wsnyc_authorizenet_choldder_name').on('change', function () {
    jQuery(this)
      .closest('.wsnyc_authorizenet_new_card')
      .find('.error_message')
      .remove();
    jQuery(this)
      .closest('.wsnyc_authorizenet_new_card')
      .removeClass('payment-validation-error');
  });
  jQuery('#wsnyc_authorizenet_expiration').on('change', function () {
    jQuery(this).closest('.v-fix').find('.error_message').remove();
    jQuery(this).closest('.v-fix').removeClass('payment-validation-error');
  });
  jQuery('#wsnyc_authorizenet_expiration_yr').on('change', function () {
    jQuery(this).closest('.v-fix').find('.error_message').remove();
    jQuery(this).closest('.v-fix').removeClass('payment-validation-error');
  });
  jQuery('#wsnyc_authorizenet_cc_cid').on('change', function () {
    jQuery(this).closest('.v-fix').find('.error_message').remove();
    jQuery(this).closest('.v-fix').removeClass('payment-validation-error');
  });

  //return_button
  jQuery('#return_shipping').on('click', function () {
    jQuery('#payment_step').hide();
    jQuery('#billing_step').show();
    jQuery('#payment_position').removeClass('active_position');
    jQuery(this).hide();
    jQuery('#return_cart').show();
  });
  //confimation
  //return_button
  jQuery('#return_payment').on('click', function () {
    jQuery('#confirm_step').hide();
    jQuery('#payment_step').show();
    jQuery('#confirm_position').removeClass('active_position');
    jQuery(this).hide();
    jQuery('#return_shipping').show();
  });

  //alternative
  //jQuery('.checkout_step').each(function(){
  //    var stepBtn = jQuery(this).find('.step_btn');
  //    var stepBlock = jQuery(this);
  //    stepBtn.on('click', function(){
  //        jQuery(stepBlock).hide();
  //        jQuery(stepBlock).removeClass('active_step');
  //        jQuery(stepBlock).next().show();
  //        jQuery(stepBlock).next().addClass('active_step');
  //    })
  //});
  jQuery('.become_member_bottom_link').on('click', function () {
    if (jQuery('.become_member_bottom_block_content').hasClass('open')) {
      jQuery('.become_member_bottom_block_content').removeClass('open');
    } else {
      jQuery('.become_member_bottom_block_content').addClass('open');
    }
  });
});
jQuery(window).on('resize', function () {
  if (jQuery(window).width() <= 950 && jQuery(window).width() >= 460) {
    var sliderText = jQuery('.slider_content');
    var maxHeight = 0;
    sliderText.each(function (e, i) {
      if (jQuery(this).height() > maxHeight) {
        maxHeight = jQuery(this).outerHeight();
      }
    });
    sliderText.each(function (e, i) {
      jQuery(this).css('height', maxHeight);
    });

    jQuery('.block_content.top_block').css('padding-top', maxHeight + 15);
  } else {
    jQuery('.block_content.top_block').css('padding-top', 0);
  }
  if (jQuery(window).width() < 800) {
    jQuery('.tabs-nav').addClass('full');
  } else {
    jQuery('.tabs-nav').removeClass('full');
  }
});
jQuery(window).load(function () {
  if (jQuery('.flexslider').length) {
    jQuery('.flexslider').flexslider({
      animation: 'slide',
      directionNav: false,
      start: function () {
        var controlDots = jQuery('.flex-control-paging');
        jQuery('.slider_holder').removeClass('slider_loader');
        jQuery('.slider_overlay').css('opacity', 1);
        controlDots.css('margin-left', -(controlDots.width() + 30) / 2);
      },
    });
  }
});

jQuery(document).ready(function () {
  jQuery(window).bind('load', function () {
    jQuery('.flex-control-paging').on('click', function (e) {
      e.preventDefault();
      e.stopPropagation();
    });
    jQuery('.flex-control-paging a').on('click', function (e) {
      e.preventDefault();
      e.stopPropagation();
      var index = jQuery(this).closest('li').index();
      console.log(index);
      jQuery('.flexslider').flexslider(index);
    });
  });
});