Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function() {
  2.     var popup = $('.films__popup');
  3.     var center = popup.find('.films__popup__container');
  4.     var close = popup.find('.films__popup__close');
  5.  
  6.     $('.films__list__item__image__link').on('click', function() {
  7.         var src = $(this).closest('.films__list__item').data('src') + '?autoplay=1';
  8.         var bottom = $(this).find('.films__list__item__bottom').html();
  9.  
  10.         popup.find('iframe').attr('src', src);
  11.         popup.find('.films__popup__bottom').html(bottom);
  12.  
  13.         popup.fadeIn();
  14.         $('body').addClass('no_scroll');
  15.     });
  16.  
  17.     close.on('click', function() {
  18.         closePopup();
  19.         $('body').removeClass('no_scroll');
  20.     });
  21.     $(document).mouseup(function(e) {
  22.     if (!center.is(e.target) && center.has(e.target).length === 0) {
  23.         closePopup();
  24.     }
  25. });
  26.  
  27.     function closePopup() {
  28.         popup.fadeOut();
  29.         popup.find('iframe').attr('src', '');
  30.     }
  31.  
  32. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement