import './mediaDataService'; import '../vendor/jquery.scrollTo-min'; angular.module('footyroom').component('frMediaViewer', { templateUrl: 'media-viewer-template', bindings: { r16x9: '<', }, controller: ['mediaEmbedder', 'mediaData', function (mediaEmbedder, mediaData) { var ctrl = this; var roll; ctrl.$onInit = $onInit; function $onInit() { mediaData.onSelect(function (selectedMedia, scroll) { showMedia(selectedMedia, scroll); }); ctrl.selectedMedia = mediaData.getSelected(); if (ctrl.selectedMedia) { showMedia(ctrl.selectedMedia); } } function showMedia(media, scroll) { ctrl.selectedMedia = media; mediaEmbedder.embed(media, '#video'); // Destroy roll if already exists. if (roll) { roll.destroy(); } // Add preroll ad. if ($('#video iframe').length && window.RollerInlineTag) { roll = new RollerInlineTag('#video iframe', 'https://pubads.g.doubleclick.net/gampad/ads?sz=575x400&iu=/1873845/FR_Match_Video&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&url=[referrer_url]&description_url=' + encodeURIComponent(window.location.href) + '&correlator=[timestamp]'); } setTimeout(function () { if (scroll) { $('body').scrollTo('.videos-wrap', 300); } }, 100); } }], });