show-more.js 6.16 KB
jQuery(document).ready(function ($) {

  $('.show-more').html("<span>Details</span> &#9658;");
  $('.show-more').addClass('closed-accordion-item');
  $('.show-more').data('toggle', 'closed');

  setTimeout(function () {
    $('.show-more').on("touchstart click", function () {

      var html = $(this).data('toggle');
      $('.gp_menu');
      if (html == 'closed') {
        $('.more-hidden').hide();
        $('.gp_menu').height('225');
        $('.show-more').data('toggle', 'closed').html("<span>Details</span> &#9658;");

      }


      var dataId = $(this).attr('data-id');
      $('#' + dataId).toggle();
      if (html == 'closed') $(this).data('toggle', 'opened').html("<span>Details</span> &#x25BC;");
      else $(this).data('toggle', 'closed').html("<span>Details</span> &#9658;");
      if ($(window).width() > 767) {
        $(this).parents().closest('.product-info').siblings('.gp_menu').height($(this).parents().closest('.product-info').height());
      }
    });

  }, 1000);



  $('.show-more-home').html("Read more &#9658;");
  $('.show-more-home').addClass('closed-accordion-item');
  $('.show-more-home').data('toggle', 'closed');
  $('.show-less-home').html("Read less &#x25b2;");
  $('.show-less-home').data('toggle', 'open');
  $('.show-more').attr('ontouchstart', ' ');


  setTimeout(function () {
    $('.show-more-home').on("touchstart click", function () {

      var html = $(this).data('toggle');

      $('.show-more-home').hide();
      var dataId = $(this).attr('data-id');
      $('#' + dataId).toggle();
      if (html == 'closed') $(this).data('toggle', 'opened');
      else $(this).data('toggle', 'closed');
    });

    $('.show-less-home').on("touchstart click", function () {

      var html = $(this).data('toggle');

      $('.show-more-home').show();
      var dataId = $(this).attr('data-id');
      $('#' + dataId).toggle();
      if (html == 'closed') $(this).data('toggle', 'opened');
      else $(this).data('toggle', 'closed');
    });

  }, 1000);





  $('.carousel[data-type="multi"] .item').each(function () {

    var next = $(this).next();
    if (!next.length) {
      next = $(this).siblings(':first');
    }
    next.children(':first-child').clone().appendTo($(this));

    for (var i = 0; i < 1; i++) {
      next = next.next();
      if (!next.length) {
        next = $(this).siblings(':first');
      }

      next.children(':first-child').clone().appendTo($(this));
    }
  });


  $('#playButton').attr('tabindex', '-1');
  $('#pauseButton').attr('tabindex', '-1');

  $(window).resize(function () {

    if ($(window).width() > 1350) {
      ///  $('#pauseButton').click();
      //  console.log('pause');
      //  $('#carouselButtons').hide();
      $('.carousel-control a').attr('tabindex', '-1');


    } else {
      //    console.log('play');
      //  $('#playButton').click();
      // $('#carouselButtons').show();
      $('.carousel-control a').attr('tabindex', '0');
    }
  });



  setTimeout(function () {
    $('.ui-accordion-header').unbind();
    $('.ui-accordion-header').attr('tabindex', '0');



    $('.ui-accordion-header').each(function () {

      $(this).click(function (e) {
        $('.wp-tab-content').not(this).hide();

        $('.wp-tab-content').not($(this).next('.wp-tab-content')).each(function () {
          $(this).hide().attr('aria-hidden', 'true');
        });
        $('.ui-accordion-header').not($(this)).each(function () {
          $(this).removeClass('ui-accordion-header-active ui-state-active');
          $(this).attr('aria-selected', 'false');
          $(this).attr('aria-expanded', 'false');
        });

        $('.ui-accordion-header-icon').removeClass('ui-icon-triangle-1-s').addClass('ui-icon-triangle-1-e');

        if ($(this).hasClass('ui-state-active')) {

          $(this).next('.wp-tab-content').hide();
          $(this).next('.wp-tab-content').attr('aria-hidden', 'true');
          $(this).removeClass('ui-accordion-header-active ui-state-active');
          $(this).attr('aria-selected', 'false');
          $(this).attr('aria-expanded', 'false');


        } else {
          $(this).attr('aria-selected', 'true');
          $(this).attr('aria-expanded', 'true');

          $(this).next('.wp-tab-content').show().attr('aria-hidden', 'false');
          $(this).addClass('ui-accordion-header-active ui-state-active');
          $(this).find('.ui-accordion-header-icon').addClass('ui-icon-triangle-1-s').removeClass('ui-icon-triangle-1-e');

        }



      });
    });
    $(document).on('keypress', function (e) {
      var key = e.which;
      if (key == 13)  // the enter key code
      {
        $(e.target).click();
        return false;
      }
    });
  }, 1000);



  $(".cta a").on("focus", function () {
    $(this).parent().parent().css({ 'bottom': '0', 'height': '590px' });
    console.log($(this).parent());
  });
  $(".cta a").on("focusout", function () {
    $(this).parent().parent().css({ 'bottom': '0', 'height': '0px' });
    console.log($(this).parent());
  });



  if (typeof qmn_quiz_data !== 'undefined') {
    for (var key in qmn_quiz_data) {

      console.log('#quizForm' + qmn_quiz_data[key].quiz_id + '.qmn_quiz_radio');
      jQuery('#quizForm' + qmn_quiz_data[key].quiz_id + ' .custom-radio').click(function () {
        var chosen_answer = jQuery(this).siblings('.qmn_quiz_radio').val();
        var question_id = jQuery(this).siblings('.qmn_quiz_radio').attr('name').replace(/question/i, '');
        var chosen_id = jQuery(this).siblings('.qmn_quiz_radio').attr('id');
        console.log(qmn_quiz_data[key]);
        jQuery.each(qmn_quiz_data[key].question_list, function (i, value) {
          if (question_id == value.question_id) {
            jQuery.each(value.answers, function (j, answer) {
              if (answer[0] === chosen_answer) {
                if (answer[2] !== 1) {
                  jQuery('#' + chosen_id).parent().addClass("qmn_incorrect_answer");
                }
              }
              if (answer[2] === 1) {
                jQuery(':radio[name=question' + question_id + '][value="' + answer[0] + '"]').parent().addClass("qmn_correct_answer");
              }
            });
          }
        });


      });
    }
  }

  $('img[src*="https://beacon.krxd.net"]').attr('alt', 'beacon pixel')
});