PageSourceSearch

https://www.lasallebajio.edu.mx/js/jquery.background-video.js

js lasallebajio.edu.mx collected 2026-10-02 19:11:37 UTC 7,532 bytes, 246 lines download raw bytes

vendor: 1,167 bytes, lines 1-23
1// The MIT License (MIT)
2
3// Copyright (c) 2015 BG Stock - html5backgroundvideos.com
4
5// Permission is hereby granted, free of charge, to any person obtaining a copy
6// of this software and associated documentation files (the "Software"), to deal
7// in the Software without restriction, including without limitation the rights
8// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9// copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11
12// The above copyright notice and this permission notice shall be included in all
13// copies or substantial portions of the Software.
14
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21// SOFTWARE.
22
23(function($)
vendor: 6,365 bytes, lines 23-246
23{
24	// Add js class to html
25	$('html').addClass('js');
26
27	// Add IE8 shim for Date.now()
28	if (!Date.now){
29		Date.now = function(){ return new Date().getTime(); }
30	}
31
32	// Return current time in seconds
33	function currentTime(){
34		return Math.floor(Date.now() / 1000);
35	}
36
37	// The plugin
38	$.fn.bgVideo = function(options){
39		// @bool iOS
40		function iOSversion(){
41			if (/iP(hone|od|ad)/.test(navigator.platform)){
42				var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
43				return [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)];
44			}
45		}
46
47		var iOSVersion = iOSversion();
48		var old_iOS = false;
49
50		if (iOSVersion && (iOSVersion[0] < 10)){
51			old_iOS = true;
52		}
53
54		// Settings
55		var settings = $.extend({}, $.fn.bgVideo.defaults, options );
56
57		// Do the things
58		return this.each(function(){
59			// Set some handy variables
60			var $video = $(this); // jQuery Object
61			var video = $video[0]; // DOM node
62			var poster = $video.attr('poster') || '';
63			var $container = $video.parent();
64			var $pauseplay = $('<button class="jquery-background-video-pauseplay pause"><span>Pause</span></button>');
65			var start_time; // We'll set this when it starts playing
66
67			// Check for any data attributes that will override the settings for this particular element
68			var el_settings = $.extend({}, settings);
69			var data_attrs = $video.data();
70			$.each( data_attrs, function( data_name, data_val ){
71				if( data_name.indexOf('bgvideo') === 0 ){
72					// It's a match! Strip the bgvideo prefix and lowercase the first letter
73					data_name = data_name.replace('bgvideo', '');
74					data_name = data_name.charAt(0).toLowerCase() + data_name.slice(1);
75					// Then set the setting
76					el_settings[data_name] = data_val;
77				}
78			});
79
80			// Attach to playing event
81			$video.on('playing', function(){
82				if(start_time == null){
83					start_time = currentTime();
84				}
85				$video.addClass('is-playing is-visible');
86				$pauseplay.removeClass('play').addClass('pause').find('span').text('Pause');
87				$.fn.bgVideo.fitVideo( $video );
88			});
89
90			// If the video is already playing before js loads
91			if( video.currentTime > 0 ){
92				$video.addClass('is-playing is-visible');
93			}
94
95			// Attach to pause event
96			$video.on('pause', function(){
97				$video.removeClass('is-playing');
98				$pauseplay.removeClass('pause').addClass('play').find('span').text('Play');
99				if(el_settings.fadeOnPause){
100					$video.removeClass('is-visible');
101				}
102			});
103
104			// Set default styles
105			$container.css({
106				'position': 'relative',
107				'overflow': 'hidden',
108				'background-size': 'cover',
109				'background-position': 'center center',
110				'background-repeat': 'no-repeat',
111				'background-image': 'url(' + poster + ')'
112			});
113			$video.css({
114				'min-width': 'auto',
115				'min-height': 'auto',
116				'width': '100%',
117				'height': 'auto',
118				'position': 'absolute',
119				'left': '50%',
120				'top': '50%',
121				'transform': 'translate(-50%,-50%)'
122			});
123			if( el_settings.fullScreen ){
124				$container.css({
125					'position': 'fixed',
126					'top': '0',
127					'bottom': '0',
128					'left': '0',
129					'right': '0',
130					'height': 'auto',
131					'margin': '0',
132					'z-index': '-1'
133				});
134			}
135
136			// Fade in video by setting the transition duration
137			$video.css('transition-duration', el_settings.fadeIn + 'ms');
138
139			// Remove on iOS
140			if( old_iOS ){
141				// Unset sources to prevent them from continuing to download
142				$video.attr('src', '');
143				$video.find('source').attr('src', '');
144				$video.remove();
145			}
146
147			// Mimic background-size: cover with video element
148			$.fn.bgVideo.fitVideo( $video );
149			$(window).resize(function(){
150				$.fn.bgVideo.fitVideo( $video );
151			});
152
153			// Pause after X seconds
154			el_settings.pauseAfter = parseInt( el_settings.pauseAfter, 10 );
155			if( el_settings.pauseAfter > 0 ){
156				$video.on('timeupdate', function(){
157					var now = currentTime();
158					if( now > start_time + el_settings.pauseAfter ){
159						video.pause();
160						if( el_settings.fadeOnEnd ){
161							$video.removeClass('is-visible');
162						}
163					}
164				});
165			}
166
167			// Play / pause button
168			if( el_settings.showPausePlay && !old_iOS ){
169				// Append pauseplay element created earlier
170				$container.append($pauseplay);
171				// Position element
172				$pauseplay.css({
173					'left':   'auto',
174					'right':  'auto',
175					'top':    'auto',
176					'bottom': 'auto'
177				});
178				$pauseplay.css(el_settings.pausePlayXPos, el_settings.pausePlayXOffset);
179				$pauseplay.css(el_settings.pausePlayYPos, el_settings.pausePlayYOffset);
180				if( el_settings.pausePlayXPos === 'center' ){
181					$pauseplay.css({
182						'left':        '50%',
183						'margin-left': '-10px'
184					});
185				}
186				if( el_settings.pausePlayYPos === 'center' ){
187					$pauseplay.css({
188						'top':        '50%',
189						'margin-top': '-10px'
190					});
191				}
192				// Add functionality
193				$pauseplay.on('click', function(){
194					if(video.paused){
195						video.play();
196						start_time = currentTime();
197					} else{
198						video.pause();
199					}
200				});
201			}
202		});
203	};
204
205	// Default settings
206	$.fn.bgVideo.defaults ={
207		fullScreen: false, // Sets the video to be fixed to the full window
208		fadeIn: 500, // Milliseconds to fade video in/out (0 for no fade)
209		pauseAfter: 0, // Seconds to play before pausing (0 for forever)
210		fadeOnPause: false, // For all (including manual) pauses
211		fadeOnEnd: true, // When we've reached the pauseAfter time
212		showPausePlay: true, // Show pause/play button
213		pausePlayXPos: 'center', // left|right|center
214		pausePlayYPos: 'bottom', // top|bottom|center
215		pausePlayXOffset: '20px', // pixels or percent from side - ignored if positioned center
216		pausePlayYOffset: '15px' // pixels or percent from top/bottom - ignored if positioned center
217	};
218
219	// Fit video
220	$.fn.bgVideo.fitVideo = function( $video ){
221		var $container = $video.parent(),
222			container_height = $container.outerHeight(),
223			container_width = $container.outerWidth();
224
225		// Do this again every time the screen size changes
226		$video.css({
227			'height': 'auto',
228			'width': container_width + 'px'
229		});
230
231		var video_height = $video.height();
232
233		if( container_height > video_height ){
234			//console.log('Container height > video height');
235			$video.css({
236				'height': container_height + 'px',
237				'width': 'auto'
238			});
239		}
240	};
241
242	// Auto run based on data attributes
243	$(document).ready(function(){
244		$('[data-bgvideo]').bgVideo();
245	});
246}(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.