1(function (scope, $) { 2 'use strict'; 3 4 var MVideo = function () { 5 6 var $ = jQuery; 7 var instances = []; 8 9 function onReady() { 10 $('.module.video').each(function () { 11 instances.push(initInstance($(this))); 12 }); 13 } 14 15 //Add Modernizr test 16 Modernizr.addTest('isios', function(){ 17 return navigator.userAgent.match(/(iPad|iPhone|iPod)/g) ? true : false; 18 }); 19 20 function initInstance(view) { 21 22 // Private properties 23 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 24 25 var $view = view, 26 id = $view.data('id'), 27 players = {}, 28 $iframe, 29 $widthScreen, 30 $heightScreen, 31 $heightVideo, 32 $widthVideo, 33 $leftVideo, 34 videoConfigured; 35 36 // Private methods 37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 38 39 // adjust video screen resolution 40 var adjustVideo = function () { 41 // get height and width screen 42 $widthScreen = $(window).width(); 43 $heightScreen = $(window).height(); 44 45 $view.find('iframe#video').css({ 46 'height': '100%', 47 'width': '100%' 48 }); 49 50 $view.find('.video-full').css({ 51 'width': '100%', 52 'left' : '0px' 53 }); 54 }; 55 56 var setupStop = function () { 57 58 var $parent = $(this).parents('.module.video'); 59 var new_id = $parent.data('id'); 60 61 players[new_id].stopVideo(); 62 63 $parent.find('.module-video-container-wrapper').removeClass('full'); 64 $parent.find('.video-container').css('z-index', -1); 65 $parent.find('.video-container').css('display', 'none'); 66 $parent.find('.text-container').css('z-index', 1); 67 }; 68 69 var adjustHeight = function () {} 70 71 var playVideoFull = function (e) { 72 if (e) { e.preventDefault(); } 73 74 var $parent = $view; 75 var new_id = $parent.data('id'); 76 var body = $("html, body"); 77 78 if ( $parent.find('.headerVideo').length ) { 79 var $aTag = $parent.find('a.headerVideo'); 80 if (!( $('body').hasClass('t-mobile') )) { 81 $('html,body').animate({scrollTop: $aTag.offset().top-69},'slow'); 82 } 83 } 84 85 /* 86 if ($widthScreen < 1024) { 87 console.log('test aca estoy'); 88 $('html,body').animate({ 89 scrollLeft: $leftVideo 90 }, 'slow'); 91 } 92 */ 93 94 $parent.find('.module-video-container-wrapper').addClass('full'); 95 $parent.find('.module.video .module-video-container.full').css('height', $heightVideo + 'px'); 96 97 $parent.find('.video-container').css('z-index', 1000); 98 $parent.find('.video-container').css('display', 'block'); 99 100 // detect if navigation is iOS 101 if (!Modernizr.isios) { 102 players[new_id].playVideo(); 103 } 104 }; 105 106 var configureVideoPlayers = function () { 107 if (!videoConfigured) { 108 var new_id = $view.data('id'); 109 players[new_id] = new YT.Player($view.find(".videoframe").get(0), { 110 'autoplay': 1, 111 'rel': 0, 112 'playsinline': 1, 113 'controls': 2, 114 'events': { 115 'onStateChange': function(event) { 116 switch (event.data) { 117 case YT.PlayerState.ENDED: 118 setupStop(); 119 break; 120 case YT.PlayerState.PLAYING: 121 $(window).resize(adjustHeight); 122 break; 123 case YT.PlayerState.PAUSED: 124 break; 125 case YT.PlayerState.ENDED: 126 setupStop(); 127 $(window).off('resize', adjustHeight); 128 case YT.PlayerState.BUFFERING: 129 break; 130 } 131 } 132 } 133 }); 134 135 window.players = players; 136 137 $view.find('.play-video').on('click', playVideoFull); 138 $view.find('.play-video-bottom').on('click', playVideoFull); 139 $view.find('button.close-video').on('click', setupStop); 140 // Y mostramos el boton 141 $view.find('.play-video').show(); 142 143 videoConfigured = true; 144 } 145 }; 146 147 // instance object 148 var instance = { 149 init: function () { 150 151 adjustVideo(); 152 153 $(window).resize( function() { 154 adjustVideo(); 155 }); 156 157 if (typeof window.isYouTubePlayerAPIReady == 'undefined' || window.isYouTubePlayerAPIReady === false) { 158 Events.subscribe('YOUTUBE_API_READY', configureVideoPlayers); 159 } else { 160 configureVideoPlayers(); 161 } 162 } 163 }; 164 165 instance.init(); 166 return instance; 167 } 168 169 // DOMContentLoaded 170 $(onReady); 171 172 } 173 174 MVideo(); 175 176})(window, jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.