`); if(ids.length>1) { $('.youtube-popup-player-nav').removeClass('hide'); } var id = getNextVideoId(); var youbutePlayer = new YT.Player('youtube-popup-player-iframe', { videoId: id.videoId, startSeconds:id.startSeconds, events: { 'onReady' : function (e) { youbutePlayer.seekTo(id.startSeconds); youbutePlayer.playVideo(); }, 'onStateChange': function (e) { if(typeof ga === "undefined" || e.data != YT.PlayerState.PLAYING) { return; } const videoData = youbutePlayer.getVideoData(); ga('require','ec'); ga('send', 'event', 'youtube', 'popup-play', videoData.video_id,{ 'dimension1' : videoData.title }); } } }); var $player = $('#youtube-popup-player'); var youtubeModal = modal({ modalClass: 'youtube-popup-player', type: 'popup', width: '80%', buttons: [], }, $player); $player.on('modalclosed', function () { $player.remove(); }); $('[data-trigger="youtube-popup-player-previous"]') .click(function (){ youbutePlayer.loadVideoById(getPreviousVideoId()); }); $('[data-trigger="youtube-popup-player-next"]') .click(function (){ youbutePlayer.loadVideoById(getNextVideoId()); }); youtubeModal.openModal(); }); });