| 1 |
// Poll Maker welcome page simple JS |
| 2 |
(function($){ |
| 3 |
$(function(){ |
| 4 |
// Changelog toggle |
| 5 |
var $toggle = $('#wn-toggle'); |
| 6 |
var $chg = $('.ays-pm-w-changelog'); |
| 7 |
$toggle.on('click', function(){ |
| 8 |
if($chg.hasClass('ays-pm-w-collapsed')){ |
| 9 |
$chg.removeClass('ays-pm-w-collapsed').addClass('ays-pm-w-expanded'); |
| 10 |
$('.ays-pm-w-wn-arrow').html('▴'); |
| 11 |
$toggle.text(poll_maker_ays_welcome.show_less).append($('<span/>',{class:'ays-pm-w-wn-arrow',html:'▴'})); |
| 12 |
}else{ |
| 13 |
$chg.removeClass('ays-pm-w-expanded').addClass('ays-pm-w-collapsed'); |
| 14 |
$('.ays-pm-w-wn-arrow').html('▾'); |
| 15 |
$toggle.text(poll_maker_ays_welcome.show_more).append($('<span/>',{class:'ays-pm-w-wn-arrow',html:'▾'})); |
| 16 |
} |
| 17 |
}); |
| 18 |
|
| 19 |
// Video lightbox |
| 20 |
var $lightbox = $('#ays-pm-w-video-lightbox'); |
| 21 |
var $iframe = $('#ays-pm-w-video-iframe'); |
| 22 |
|
| 23 |
function closeLightbox() { |
| 24 |
$lightbox.removeClass('ays-pm-w-show'); |
| 25 |
setTimeout(function() { |
| 26 |
$iframe.attr('src', ''); |
| 27 |
}, 300); // Wait for fade out transition |
| 28 |
} |
| 29 |
|
| 30 |
$('.ays-pm-w-video-card').on('click', function(){ |
| 31 |
var videoId = $(this).data('video-id'); |
| 32 |
if (videoId) { |
| 33 |
$iframe.attr('src', 'https://www.youtube.com/embed/' + videoId); |
| 34 |
$lightbox.addClass('ays-pm-w-show'); |
| 35 |
} |
| 36 |
}); |
| 37 |
|
| 38 |
$('#ays-pm-w-video-lightbox-close').on('click', closeLightbox); |
| 39 |
|
| 40 |
$lightbox.on('click', function(e){ |
| 41 |
if ($(e.target).is($lightbox)) { |
| 42 |
closeLightbox(); |
| 43 |
} |
| 44 |
}); |
| 45 |
}); |
| 46 |
})(jQuery); |