'); modal.find('.slideshow-container').append(photos); modal.find('.mySlides').slice(0).hide(); var dots = photosById.sellerPhotoArray.map(m => ''); modal.find('.slideshow-dots').append(dots); // $('.mySlides:first').hide(); $('.mySlides:eq(' + imageid + ')').show(); $('.slideshow-dot:eq(' + imageid + ')').addClass('slideshow-active'); } addEventDetailsToAnalytics('View Item Photos', 0, true, false); }); // $('#photoModal').on('hide.bs.modal', function (event) { var modal = $(this); modal.find('.mySlides').remove(); modal.find('.slideshow-dot').remove(); }); $("body").on('keydown', "#photoModal", function (e) { console.log(e.keyCode); if (e.keyCode == 39) { $('.next').trigger('click'); } else if (e.keyCode == 37) { $('.prev').trigger('click'); } }); $('.next').on('click', function () { var visImage = $('.mySlides:visible'); var activeDot = $('.slideshow-dot.slideshow-active') if (visImage.is(':last-child')) { visImage.hide(); $('.mySlides:first').show(); activeDot.removeClass('slideshow-active'); $('.slideshow-dot:first').addClass('slideshow-active'); } else { visImage.hide().next().show(); activeDot.removeClass('slideshow-active').next().addClass('slideshow-active'); } }); $('.prev').on('click', function () { var visImage = $('.mySlides:visible'); var activeDot = $('.slideshow-dot.slideshow-active') if (visImage.is('.mySlides:first')) { visImage.hide(); $('.mySlides:last').show(); activeDot.removeClass('slideshow-active'); $('.slideshow-dot:last').addClass('slideshow-active'); } else { visImage.hide().prev().show(); activeDot.removeClass('slideshow-active').prev().addClass('slideshow-active'); } }); $(document).on('click', '.slideshow-dot', function () { var index = $(this).index(); var visImage = $('.mySlides:visible'); var activeDot = $('.slideshow-dot.slideshow-active') visImage.hide(); $('.mySlides:eq(' + index + ')').show(); activeDot.removeClass('slideshow-active'); $('.slideshow-dot:eq(' + index + ')').addClass('slideshow-active'); });