PageSourceSearch

https://akronohio.gov/_assets_/plugins/lightbox/js/jquery.lbt-lightbox.js

js akronohio.gov collected 2026-10-02 04:15:46 UTC 38,892 bytes, 1,349 lines download raw bytes

1/*!
2 * LBT Lightbox v1.1.2
3 * by Jean Kássio
4 *
5 * More info:
6 * https://jeankassio.dev
7 *
8 * Copyright Jean Kássio
9 * Released under the MIT license
10 * https://github.com/jeankassio/LBT-Lightbox/blob/main/LICENSE
11 *
12 * @preserve
13 */
14
15(function($){
16  $.fn.lbtLightBox = function(options){
17	
18	$closebutton = '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M4.227 4.227a.774.774 0 0 1 1.095 0L12 10.905l6.678-6.678a.774.774 0 1 1 1.095 1.095L13.095 12l6.678 6.678a.774.774 0 1 1-1.095 1.095L12 13.095l-6.678 6.678a.774.774 0 1 1-1.095-1.095L10.905 12 4.227 5.322a.774.774 0 0 1 0-1.095Z" fill="currentColor"/></svg>';
19	$dotoptions = '<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10.001 7.8a2.2 2.2 0 1 0 0 4.402A2.2 2.2 0 0 0 10 7.8zm0-2.6A2.2 2.2 0 1 0 9.999.8a2.2 2.2 0 0 0 .002 4.4zm0 9.6a2.2 2.2 0 1 0 0 4.402 2.2 2.2 0 0 0 0-4.402z" fill="currentColor"/></svg>';
20	$odownload = '<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M19 9h-4V3H9v6H5l7 8zM4 19h16v2H4z" fill="currentColor"/></svg>';
21	$oforward = '<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M14.4 14.249v5.228l8.4-8.028-8.4-7.886v4.78c-10.53 0-13.2 11.678-13.2 11.678 2.981-5.266 7.484-5.772 13.2-5.772z" fill="currentColor"/></svg>';
22	$osmile = '<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10 20a10 10 0 1 1 0-20 10 10 0 0 1 0 20zM6.5 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3zm7 0a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3zm2.16 3H4.34a6 6 0 0 0 11.32 0z" fill="currentColor"/></svg>';
23	$ostar = '<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m10 15-5.878 3.09 1.123-6.545L.489 6.91l6.572-.955L10 0l2.939 5.955 6.572.955-4.756 4.635 1.123 6.545z" fill="currentColor"/></svg>';
24	$ochat = '<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill="none" d="M0 0h24v24H0z"/><path d="M5.763 17H20V5H4v13.385L5.763 17zm.692 2L2 22.5V4a1 1 0 0 1 1-1h18a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H6.455z" fill="currentColor"/></svg>';
25	$loading = '<svg version="1.1" id="lbt-loading" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 100 100" enable-background="new 0 0 0 0" xml:space="preserve"> <path fill="#fff" d="M73,50c0-12.7-10.3-23-23-23S27,37.3,27,50 M30.9,50c0-10.5,8.5-19.1,19.1-19.1S69.1,39.5,69.1,50"> <animateTransform attributeName="transform" attributeType="XML" type="rotate" dur="0.5s" from="0 50 50" to="360 50 50" repeatCount="indefinite" /></path></svg>';
26	$btn_play = '<svg class="lbt_btn_play" width="200" height="200" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><path stroke-width="16.667" d="M100 183.333c46.024 0 83.333-37.309 83.333-83.333S146.024 16.667 100 16.667 16.667 53.976 16.667 100 53.976 183.333 100 183.333Zm-20.833-54.166 50-29.167-50-29.167v58.334ZM87.5 112.5l16.667-12.5L87.5 87.5v25Z"/></svg>';
27	
28	$oprofile = 'https://github.com/jeankassio.png';
29	
30	let $lbt_images;
31	let $totalImages;
32	let $allThumbnails = "";
33	$innerHeight = window.innerHeight;
34	$innerWidth = window.innerWidth * 0.7;
35	
36	let videoPlayer;
37	let VideoScr;
38	let mouseout;
39	let lbt_videoTime;
40	let videoControls;
41	let videoProgressLine;
42	let videoProgressBar;
43	let play_n_pause;
44	let volume;
45	let volumeRange;
46	let current;
47	let totalVideoDuration;
48	let pictureInpicture;
49	let fullscreenMode;
50	let loadingIndicator;
51	let db;
52	
53	const cyrb53 = (str, seed = 0) => {
54	  let h1 = 0xdeadbeef ^ seed,
55		h2 = 0x41c6ce57 ^ seed;
56	  for (let i = 0, ch; i < str.length; i++) {
57		ch = str.charCodeAt(i);
58		h1 = Math.imul(h1 ^ ch, 2654435761);
59		h2 = Math.imul(h2 ^ ch, 1597334677);
60	  }
61	  
62	  h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
63	  h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
64	  
65	  return 4294967296 * (2097151 & h2) + (h1 >>> 0);
66	};
67	
68    let defaults = {
69		qtd_pagination: 8,
70		pagination_width: "60px",
71		pagination_height: "60px",
72		captions: false,
73		captions_selector: ".caption",
74		custom_children: "img",
75		db: false
76	};
77	var options = $.extend(defaults, options);
78	
79    function setListeners(container, options){
80		
81		GetIframeVideos();
82		GetHTML5Videos();
83		
84		$lbt_images = $(options.custom_children, options.container_images);
85		$totalImages = $lbt_images.length;
86		
87		if(options.db == true){
88		
89			$version_db = 1;
90			
91			let DBconnection = indexedDB.open("lbt_lightbox", $version_db);
92
93			DBconnection.onupgradeneeded = function(e){
94			  
95				db = DBconnection.result;
96				
97				if(e.oldVersion == $version_db){
98					return;
99				}
100							
101				let _images = db.createObjectStore('images', {keyPath: 'id', autoIncrement: true});
102
103				_images.createIndex('type', 'type');
104				_images.createIndex('image', 'image');
105				_images.createIndex('created', 'created');
106				
107			};
108			
109			DBconnection.onsuccess = function() {
110				
111				db = DBconnection.result;
112			  
113				LoadBdImages($lbt_images);
114			  
115			};
116			
117			DBconnection.onerror = function(){
118				console.error("Error", DBconnection.error);
119			};
120			
121			DBconnection.onblocked = function() {
122				let db = DBconnection.result;
123				db.close();
124				alert("Database is outdated, refresh the page in previous tab.");
125			};
126
127		}
128		
129		$(document).on('click', options.lbr_id + " " + options.custom_children,  function(e){
130			OpenViewer($(this));
131		
132			
133		});
134		
135		$(document).on('click', options.lbt_id + " #lbt-close_lightbox", function(e){
136			
137			RemoveViewer();
138			
139		});
140		
141		$(document).keyup(function(e){
142			
143			if(e.key === "Escape"){
144				RemoveViewer();
145			}else if(e.key === "ArrowRight"){
146				NextImage();
147			}else if(e.key === "ArrowLeft"){
148				PreviousImage();
149			}
150			
151		});
152				
153		$(document).on('click', options.lbt_id + " img.lbr-thumb", function(e){
154			
155			ChangeImage($(this));
156			
157		});
158		
159		$(document).on('click', options.lbt_id + " #lbt_previous", function(e){
160			
161			PreviousImage();
162			
163		});
164		
165		$(document).on('click', options.lbt_id + " #lbt_next", function(e){
166			
167			NextImage();
168			
169		});
170				
171		$(document).on('pointerdown', options.lbt_id + " .video_progress-line", function(e){
172			
173			videoProgressLine.setPointerCapture(e.pointerId);
174			setVideoTime(e);
175			
176			$(".video_progress-line", options.container_lightbox).on("pointermove", function(e){
177			
178				setVideoTime(e);
179				
180			});
181			
182			$(".video_progress-line", options.container_lightbox).on("pointerup", function(e){
183			
184				$(this).off("pointermove");
185				
186			});
187			
188		});
189		
190		$(document).on('mouseout', options.lbt_id + " #lbt_videoplayer", function(e){
191			
192			mouseout = setTimeout(function(){
193				
194				if($("#lbt_videoplayer:hover", options.container_lightbox).length == 0){
195					const isVideoPaused = $(videoPlayer).hasClass("paused");
196					if(isVideoPaused){
197						$(videoControls).removeClass("active");					
198					}
199				}
200				
201			}, 2000);
202			
203		});
204		
205		$(document).on('mouseout', options.lbt_id + " .video_progress-line", function(e){
206			
207			$(".lbt_videoTime", options.container_lightbox).css("display", "none");
208			
209		});
210		
211		$(document).on('click', options.lbt_id + " #lbt_vsrc", function(e){
212			
213			const isVideoPaused = $(videoPlayer).hasClass("paused");
214			if (isVideoPaused){
215				pauseVideo();
216			}else{
217				playVideo();
218			}
219			
220		});
221		
222		$(document).on('mouseenter', options.lbt_id + " #lbt_videoplayer", function(e){
223			
224			clearTimeout(mouseout);
225				
226			$(videoControls).addClass("active");
227			
228		});
229		
230		$(document).on('waiting', options.lbt_id + " #lbt_vsrc", function(e){
231			
232			loadingIndicator.style.display = "block";
233			
234		});
235		
236		$(document).on('canplay', options.lbt_id + " #lbt_vsrc", function(e){
237			
238			loadingIndicator.style.display = "none";
239			
240		});
241		
242		$(document).on('play', options.lbt_id + " #lbt_vsrc", function(e){
243			
244			playVideo();
245			
246		});
247		
248		$(document).on('pause', options.lbt_id + " #lbt_vsrc", function(e){
249			
250			pauseVideo();
251			
252		});
253		
254		$(document).on('click', options.lbt_id + " .lbt_vPlayPause," + options.lbt_id + " .lbt_btn_play", function(e){
255			
256			const isVideoPaused = $(videoPlayer).hasClass("paused");
257			if (isVideoPaused){
258				pauseVideo();
259			}else{
260				playVideo();
261			}
262			
263		});
264		
265		$(document).on('input', options.lbt_id + " .lbt_videoVolumeRange", function(e){
266			
267			setVolume();
268			
269		});
270		
271		$(document).on('click', options.lbt_id + " .lbt_videoVolume", function(e){
272			
273			muteVideoVolume();
274			
275		});
276		
277		$(document).on('click', options.lbt_id + " .lbt_fullScreen", function(e){
278			
279			if(!$(videoPlayer).hasClass("openFullScreen")) {
280				$(videoPlayer).addClass("openFullScreen");
281				$(fullscreenMode).html("fullscreen_exit");
282				videoPlayer.requestFullscreen();
283			}else{
284				$(videoPlayer).removeClass("openFullScreen");
285				$(fullscreenMode).html("fullscreen");
286				document.exitFullscreen();
287			}
288			
289		});
290		
291		$(document).on('click', options.lbt_id + " .lbt_videoPip", function(e){
292			
293			VideoScr.requestPictureInPicture();
294			
295		});
296		
297		$(document).on('mousemove', options.lbt_id + " .video_progress-line", function(e){
298			
299			let progressWidthvalue = videoProgressLine.clientWidth + 2;
300			let x = e.offsetX;
301			let videoDuration = VideoScr.duration;
302			let progressTime = Math.floor((x / progressWidthvalue) * videoDuration);
303			let currentVideoMinute = Math.floor(progressTime / 60);
304			let currentVideoSeconds = Math.floor(progressTime % 60);
305			lbt_videoTime.style.setProperty("--x", `${x}px`);
306			lbt_videoTime.style.display = "block";
307			if (x >= progressWidthvalue - 80) {
308				x = progressWidthvalue - 80;
309			}else if (x <= 75) {
310				x = 75;
311			} else {
312				x = e.offsetX;
313			}
314			  // if the seconds are less then 10 then add 0 at the beginning
315			currentVideoSeconds < 10
316				? (currentVideoSeconds = "0" + currentVideoSeconds)
317				: currentVideoSeconds;
318			lbt_videoTime.innerHTML = `${currentVideoMinute} : ${currentVideoSeconds}`;
319			
320		});
321		
322    }
323	
324	$.fn.OpenViewer = function(obj){
325		
326		MountViewer(obj);		
327		LoadMedia($(obj).index(options.custom_children), null);
328		MountThumbs(obj, "#lbt-thumbnails");		
329		ToLeft();
330		$("body").addClass("lbr-ToFixed");
331		UpdateArrows();
332	}
333	
334	$.fn.update = function(){
335		
336		GetIframeVideos();
337		GetHTML5Videos();
338		
339		setTimeout(function(){
340			
341			$lbt_images = $(options.custom_children, options.container_images);
342			$totalImages = $lbt_images.length;
343			
344			LoadImages($lbt_images);
345			
346		}, 500);
347		
348	}
349	
350	$.fn.preload = function(){
351		
352		$lbt_images = $(options.custom_children, options.container_images);
353		$totalImages = $lbt_images.length;
354		
355		for (var i = 0; i < $totalImages; i++) {
356		   
357			if(typeof $lbt_images.eq(i).data('lbt-thumb') == 'undefined'){
358				
359				CreateThumb($lbt_images.eq(i), {h:Number(options.pagination_height.replace("px", "")), w:Number(options.pagination_width.replace("px", ""))}, null);
360				preloadImage($lbt_images.eq(i).attr('src'));
361				
362			}else{
363				
364				$($thumb).attr('src', $lbt_images.eq(i).data('lbt-thumb'));
365				
366			}
367			
368		}
369		
370	}
371	
372	function preloadImage(url){
373		var img = new Image();
374		img.src = url;
375	}
376	
377	function saveToIndexedDB(storeName, object){
378	  return new Promise(
379		function(resolve, reject) {
380
381		  var dbRequest = indexedDB.open("lbt_lightbox");
382
383		  dbRequest.onerror = function(event) {
384			reject(Error("IndexedDB database error"));
385		  };
386
387		  dbRequest.onupgradeneeded = function(event) {
388			var database    = event.target.result;
389			var objectStore = database.createObjectStore(storeName, {keyPath: "id", autoIncrement: true});
390		  };
391
392		  dbRequest.onsuccess = function(event) {
393			var database      = event.target.result;
394			var transaction   = database.transaction([storeName], 'readwrite');
395			var objectStore   = transaction.objectStore(storeName);
396			var objectRequest = objectStore.put(object); // Overwrite if exists
397
398			objectRequest.onerror = function(event) {
399			  reject(Error('Error text'));
400			};
401
402			objectRequest.onsuccess = function(event) {
403			  resolve('Data saved OK');
404			};
405		  };
406		}
407	  );
408	}
409	
410	function loadFromIndexedDB(storeName, id, obj){
411	  return new Promise(
412		function(resolve, reject) {
413		  var dbRequest = indexedDB.open("lbt_lightbox");
414
415		  dbRequest.onerror = function(event) {
416			reject(Error("Error text"));
417		  };
418
419		  dbRequest.onupgradeneeded = function(event) {
420			// Objectstore does not exist. Nothing to load
421			event.target.transaction.abort();
422			reject(Error('Not found'));
423		  };
424
425		  dbRequest.onsuccess = function(event) {
426			var database      = event.target.result;
427			var transaction   = database.transaction([storeName]);
428			var objectStore   = transaction.objectStore(storeName);
429			var object_index = objectStore.index("type");
430			var objectRequest = object_index.get(id);
431			
432			objectRequest.onerror = function(event) {
433			  reject(Error('Error text'));
434			};
435
436			objectRequest.onsuccess = function(event){
437				if (objectRequest.result){
438				  resolve(objectRequest.result);
439				}else{
440				  reject(Error('object not found'));
441				}			  
442			};
443		  };
444		}
445	  );
446	}
447	
448	function blobToBase64(blob){
449	  return new Promise((resolve, _) => {
450		const reader = new FileReader();
451		reader.onloadend = () => resolve(reader.result);
452		reader.readAsDataURL(blob);
453	  });
454	}
455	
456	function base64toBlob(base64Data, contentType){
457		
458		contentType = contentType || '';
459		var sliceSize = 1024;
460		var byteCharacters = atob(base64Data);
461		var bytesLength = byteCharacters.length;
462		var slicesCount = Math.ceil(bytesLength / sliceSize);
463		var byteArrays = new Array(slicesCount);
464
465		for (var sliceIndex = 0; sliceIndex < slicesCount; ++sliceIndex) {
466			var begin = sliceIndex * sliceSize;
467			var end = Math.min(begin + sliceSize, bytesLength);
468
469			var bytes = new Array(end - begin);
470			for (var offset = begin, i = 0; offset < end; ++i, ++offset) {
471				bytes[i] = byteCharacters[offset].charCodeAt(0);
472			}
473			byteArrays[sliceIndex] = new Uint8Array(bytes);
474		}
475		return new Blob(byteArrays, { type: contentType });
476		
477	}
478	
479	
480	
481	function UpdateArrows(){
482		
483		$totalImages = $lbt_images.length;
484		
485		if($(".lbr-thumb.active", options.container_lightbox).data("thumb_id") == 0){
486			$("#lbt_previous", options.container_lightbox).css('display', 'none');
487		}else{
488			$("#lbt_previous", options.container_lightbox).css('display', 'block');
489		}
490		
491		if($(".lbr-thumb.active", options.container_lightbox).data("thumb_id") == ($totalImages - 1)){
492			$("#lbt_next", options.container_lightbox).css('display', 'none');
493		}else{			
494			$("#lbt_next", options.container_lightbox).css('display', 'block');
495		}
496		
497	}
498	
499	function OpenViewer(obj){
500		
501		MountViewer(obj);		
502		LoadMedia($(obj).index(options.custom_children), null);
503		MountThumbs(obj, "#lbt-thumbnails");		
504		ToLeft();
505		$("body").addClass("lbr-ToFixed");
506		UpdateArrows();
507	}
508	
509	function ToLeft(){
510
511		$th = ($(".lbr-thumb.active", options.container_lightbox).outerWidth() * (options.qtd_pagination / 2)) + ($(".lbr-thumb.active", options.container_lightbox).outerWidth() / 3);
512		$sl = $("#lbt-thumbnails", options.container_lightbox).scrollLeft();
513		
514		
515		$("#lbt-thumbnails", options.container_lightbox).css("left", "calc((50vw - "+ $th +"px) + "+ $sl +"px)");
516		
517	}
518	
519	function NextImage(){
520		
521		$("#lbt-loading", options.container_lightbox).show();
522		
523		$totalImages = $lbt_images.length;
524		
525		$iIndex = $(".lbr-thumb.active", options.container_lightbox).data("thumb_id");
526		$iIndex++;
527		
528		if($iIndex >= $totalImages){
529			$("#lbt-loading", options.container_lightbox).hide();
530			return;
531		}
532		
533		LoadMore($iIndex);
534		
535		$tid = $(".lbr-thumb.active", options.container_lightbox).closest("li").next().find(".lbr-thumb").index(".lbr-thumb");
536		
537		LoadMedia($iIndex, $tid);
538		
539		ToLeft();
540		
541		UpdateArrows();
542		
543	}
544	
545	function PreviousImage(){
546		
547		$("#lbt-loading", options.container_lightbox).show();
548		
549		$totalImages = $lbt_images.length;
550		
551		$iIndex = $(".lbr-thumb.active", options.container_lightbox).data("thumb_id");
552		$iIndex--;
553		
554		if($iIndex < 0){
555			$("#lbt-loading", options.container_lightbox).hide();
556			return;
557		}
558		
559		LoadMore($iIndex);
560		
561		$tid = $(".lbr-thumb.active", options.container_lightbox).closest("li").prev().find(".lbr-thumb").index(".lbr-thumb");
562		
563		LoadMedia($iIndex, $tid);		
564		
565		ToLeft();
566		
567		UpdateArrows();
568		
569	}
570	
571	function ChangeImage(obj){		
572		
573		$("#lbt-loading", options.container_lightbox).show();
574		
575		$totalImages = $lbt_images.length;
576		
577		$iIndex = $(obj).data("thumb_id");
578		
579		LoadMore($iIndex);
580		
581		$tid = $(obj).index(".lbr-thumb");
582		
583		LoadMedia($iIndex, $tid);
584		
585		ToLeft();
586		
587		UpdateArrows();
588		
589	}
590	
591	function RemoveViewer(){
592		
593		$("body").removeClass("lbr-ToFixed");
594		$("#lbt-lightbox_imgs", options.container_lightbox).remove();
595		
596	}
597	
598	function MountViewer(obj){
599		
600		RemoveViewer();
601		
602		$(options.container_lightbox).append([
603			$('<div/>',{"id": "lbt-lightbox_imgs"}).append([
604				$('<div/>',{"id": "lbt_previous"}).append([
605						$('<i/>',{ "class": "fa fa-angle-left"}).attr('aria-hidden', 'true')
606					]),
607				$('<div/>',{"id": "lbt_lightbox-wrapper"}).append([
608						$('<div/>',{ "class": "lbt-image-wrapper"}).append([
609							$loading,
610							$('<div/>',{ "id": "lbt-lightbox-media"}),
611							(options.captions === true ? $('<p/>',{ "id": "lbt-lightbox-caption"}).css({bottom: (Number(options.pagination_height.replace("px", "")) + 50) + "px"}) : '')
612						])
613					]),
614				$('<div/>',{"id": "lbt_next"}).append([
615					$('<i/>',{"class": "fa fa-angle-right"}).attr('aria-hidden', 'true')
616				]),
617				$('<div/>',{"class": "lt-thumbnail-wrapper"}).append([
618					$('<ul/>',{"id": "lbt-headertop"}).append([
619						
620						$('<a/>',{"id": "lbt-close_lightbox"}).append($closebutton)
621					])
622				]),
623				$('<div/>',{"class": "lb-thumbnail-wrapper"}).append([
624					$('<ul/>',{"id": "lbt-thumbnails"}).css({height: (Number(options.pagination_height.replace("px", "")) + 40) + "px"})
625				])
626			])
627		]);
628		
629	}	
630	
631	function LoadMore($end_index){
632		
633		$totalImages = $lbt_images.length;
634		
635		$start_index = $(".lbr-thumb.active", options.container_lightbox).data("thumb_id");
636		
637		$loadto = ($start_index - $end_index);
638		
639		if($loadto < 0){
640			
641			LoadNextTo(Math.abs($loadto));
642			
643		}else if($loadto > 0){
644			
645			LoadPreviousTo($loadto);
646			
647		}
648		
649	}
650	
651	function LoadPreviousTo($qutd){
652		$totalImages = $lbt_images.length;
653		
654		for(var i = 1; i <= $qutd; i++){
655
656			$i_previous = Math.abs($("img.lbr-thumb").first().data('thumb_id')) -1;
657			
658			$i_id = $(".lbr-thumb.active", options.container_lightbox).data("thumb_id") - i;
659			
660			if($i_previous < 0 || ($i_id >= Math.ceil($totalImages - ((options.qtd_pagination / 2) + ((options.qtd_pagination%2 != 0) ? +1 : 0) )))
660){
661				
662				continue;
663				
664			}
665			
666			$obj = $("img.lbr-thumb", options.container_lightbox).not(".removed").last();
667			$obj.addClass("removed");
668			
669			$obj.closest("li").animate(
670			{"width" : "0"},
671			{"duration":120, "queue": true}).queue(function(){
672			  $( this ).remove().dequeue();
673			});
674			
675			
676			$("img.lbr-thumb", options.container_lightbox).closest("li").first().before([
677				$anim = $('<li/>').append([
678					$thumb = $('<img/>',{"class": "lbr-thumb"}).data('thumb_id', $i_previous).css({width: options.pagination_width, height: options.pagination_height})
679				]).css('width', '0').animate({
680					"width" : $(".lbr-thumb.active", options.container_lightbox).outerWidth()
681				}, 120, function(){
682					$anim.removeAttr("style");
683				})
684			]);
685			
686			
687			if(typeof $lbt_images.eq($i_previous).data('lbt-thumb') == 'undefined'){
688				
689				CreateThumb($lbt_images.eq($i_previous), {h:Number(options.pagination_height.replace("px", "")), w:Number(options.pagination_width.replace("px", ""))}, $thumb);
690				
691			}else{
692				
693				$($thumb).attr('src', $lbt_images.eq($i_previous).data('lbt-thumb'));
694				
695			}
696			
697			
698		}
699		
700	}
701	
702	function LoadNextTo($qutd){
703		$totalImages = $lbt_images.length;
704		
705		for(var i = 1; i <= $qutd; i++){
706			
707			$i_next = Math.abs($("img.lbr-thumb").last().data('thumb_id')) +1;
708			
709			$i_id = $(".lbr-thumb.active").data("thumb_id") + i;
710			
711			if($totalImages <= $i_next || ($i_id < (Number.isInteger($f = Math.ceil(((options.qtd_pagination / 2) + ((options.qtd_pagination%2 != 0) ? -1 : 0) ))) ? ($f + 1) : $f ))){
712				
713				continue;
714				
715			}
716			
717			$obj = $("img.lbr-thumb", options.container_lightbox).not(".removed").first();
718			$obj.addClass("removed");
719			
720			$obj.closest("li").animate(
721			{"width" : "0"},
722			{"duration":120, "queue": true}).queue(function(){
723			  $( this ).remove().dequeue();
724			});
725			
726			
727			$("#lbt-thumbnails", options.container_lightbox).append([
728				$anim = $('<li/>').append([
729					$thumb = $('<img/>',{"class": "lbr-thumb"}).data('thumb_id', $i_next).css({width: options.pagination_width, height: options.pagination_height})
730				]).css('width', '0').animate({
731					"width" : $(".lbr-thumb.active", options.container_lightbox).outerWidth()
732				}, 120, function(){
733					$anim.removeAttr("style");
734				})
735			]);
736			
737			
738			if(typeof $lbt_images.eq($i_next).data('lbt-thumb') == 'undefined'){
739				
740				CreateThumb($lbt_images.eq($i_next), {h:Number(options.pagination_height.replace("px", "")), w:Number(options.pagination_width.replace("px", ""))}, $thumb);
741				
742			}else{
743				
744				$($thumb).attr('src', $lbt_images.eq($i_next).data('lbt-thumb'));
745				
746			}
747			
748			
749		}
750		
751	}
752	
753	$("img.lbr-thumb").queue(function( next ) {
754		$(this).remove();
755		next();
756	});
757	
758	function LoadMedia($i, $tid){
759		
760		$("#lbt-lightbox-media", options.container_lightbox).empty();
761		
762		$("img.lbr-thumb", options.container_lightbox).removeClass('active');
763		
764		if($tid !== null){			
765			$(".lbr-thumb", options.container_lightbox).eq($tid).addClass('active');
766		}
767		
768		if($lbt_images.eq($i).data('iframe_src')){
769			
770			PreLoadIframeVideo($i);
771			
772		}else if($lbt_images.eq($i).data('html5Video')){
773			
774			LoadHTML5Video($i);
775			
776		}else{
777			
778			console.log($lbt_images.eq($i).data());
779			
780			$img = $lbt_images.eq($i).attr('src');
781			PreLoadImage($img);
782			
783		}
784		
785		if(options.captions === true){
786			
787			if($lbt_images.eq($i).find(options.captions_selector).length){
788				
789				$("#lbt-lightbox-caption", options.container_lightbox).text($lbt_images.eq($i).find(options.captions_selector).text());
790				
791			}else if($lbt_images.eq($i).next(options.captions_selector).length){
792				
793				$("#lbt-lightbox-caption", options.container_lightbox).text($lbt_images.eq($i).next(options.captions_selector).text());
794				
795			}else if($lbt_images.eq($i).parent().find(options.captions_selector).length){
796				
797				$("#lbt-lightbox-caption", options.container_lightbox).text($lbt_images.eq($i).parent().find(options.captions_selector).text());
798				
799			}			
800			
801		}
802		
803	}
804	
805	function LoadHTML5Video($i){
806		
807		$HVideo = $lbt_images.eq($i).data();
808		
809		
810		$("#lbt-lightbox-media", options.container_lightbox).append('<div id="lbt_videoplayer">\
811			<div class="lbt_loadingVideo"></div>\
812			 ' + $btn_play + '\
813			<video preload="metadata" id="lbt_vsrc">\
814				<source src="'+ $HVideo['html5Video'] +'" type="'+ $HVideo['html5type'] +'" />\
815			</video>\
816			<div class="lbt_videoTime">0:00</div>\
817			<div class="lbt_videoControls active">\
818				<div class="video_progress-line">\
819					<canvas class="video_buffer-bar"></canvas>\
820					<div class="video_progress-bar">\
821						<span></span>\
822					</div>\
823				</div>\
824				<div class="lbt_videoControls-list">\
825					<div class="lbt_videoControls-left">\
826						<span class="icon">\
827						<i class="material-icons lbt_vPlayPause">play_arrow</i>\
828						</span>\
829						<span class="icon">\
830						<i class="material-icons lbt_videoVolume">volume_up</i>\
831						<input type="range" min="0" max="100" class="lbt_videoVolumeRange" />\
832						</span>\
833						<div class="timer">\
834							<span class="lbt_videoCurrent">0:00</span> / \
835							<span class="lbt_videoDuration">0:00</span>\
836						</div>\
837					</div>\
838					<div class="lbt_videoControls-right">\
839						<span class="icon">\
840						<i class="material-icons lbt_videoPip">picture_in_picture_alt</i>\
841						</span>\
842						<span class="icon">\
843						<i class="material-icons lbt_fullScreen">fullscreen</i>\
844						</span>\
845					</div>\
846				</div>\
847			</div>\
848		</div>');
849		
850		$("#lbt-loading", options.container_lightbox).hide();
851		
852		
853		videoPlayer = document.querySelector("#lbt_videoplayer");
854		VideoScr = videoPlayer.querySelector("#lbt_vsrc");
855
856		lbt_videoTime = videoPlayer.querySelector(".lbt_videoTime");
857		videoControls = videoPlayer.querySelector(".lbt_videoControls");
858		videoProgressLine = videoPlayer.querySelector(".video_progress-line");
859		videoProgressBar = videoPlayer.querySelector(".video_progress-bar");
860		fastRewind = videoPlayer.querySelector(".lbt_fastRewind");
861		play_n_pause = videoPlayer.querySelector(".lbt_vPlayPause");
862		volume = videoPlayer.querySelector(".lbt_videoVolume");
863		volumeRange = videoPlayer.querySelector(".lbt_videoVolumeRange");
864		current = videoPlayer.querySelector(".lbt_videoCurrent");
865		totalVideoDuration = videoPlayer.querySelector(".lbt_videoDuration");
866		pictureInpicture = videoPlayer.querySelector(".lbt_videoPip");
867		fullscreenMode = videoPlayer.querySelector(".lbt_fullScreen");
868		loadingIndicator = videoPlayer.querySelector(".lbt_loadingVideo");
869		
870		
871		$("#lbt_vsrc", options.container_lightbox).on("loadeddata", function(e){
872		
873			SetVideoDuration(e);
874			
875		});
876		
877		$("#lbt_vsrc", options.container_lightbox).on("timeupdate", function(e){
878		
879			UpdateTime(e);
880			
881		});
882		
883		
884	}
885	
886	function SetVideoDuration(e){
887		
888		let videoDuration = e.target.duration;
889		let totalMin = Math.floor(videoDuration / 60);
890		let totalSec = Math.floor(videoDuration % 60);
891		// if video seconds are less than 10, then add 0 at the beginning
892		totalSec < 10 ? (totalSec = "0" + totalSec) : totalSec;
893		totalVideoDuration.innerHTML = `${totalMin} : ${totalSec}`;
894		$(".lbt_btn_play", options.container_lightbox).show();
895		
896	}
897	
898	function UpdateTime(e){
899		
900		let currentVideoTime = e.target.currentTime;
901		let currentVideoMinute = Math.floor(currentVideoTime / 60);
902		let currentVideSeconds = Math.floor(currentVideoTime % 60);
903		// if seconds are less than 10 then add 0 at the beginning
904		currentVideSeconds < 10
905			? (currentVideSeconds = "0" + currentVideSeconds)
906			: currentVideSeconds;
907		current.innerHTML = `${currentVideoMinute} : ${currentVideSeconds}`;
908		let videoDuration = e.target.duration;
909		// progressBar width change
910		let progressWidth = (currentVideoTime / videoDuration) * 100 + 0.5;
911		videoProgressBar.style.width = `${progressWidth}%`;
912		
913	}
914	
915	function playVideo(){
916		
917		play_n_pause.innerHTML = "pause";
918		play_n_pause.title = "pause";
919		$(videoPlayer).addClass("paused");
920		$(".lbt_btn_play", options.container_lightbox).hide();
921		VideoScr.play();
922		
923	}
924	
925	function pauseVideo(){
926		
927		play_n_pause.innerHTML = "play_arrow";
928		play_n_pause.title = "play";
929		$(videoPlayer).removeClass("paused");
930		$(".lbt_btn_play", options.container_lightbox).show();
931		VideoScr.pause();
932		
933	}
934	
935	function setVolume(){
936		
937		VideoScr.volume = volumeRange.value / 100;
938		  if (volumeRange.value == 0) {
939			volume.innerHTML = "volume_off";
940		  } else if (volumeRange.value < 39) {
941			volume.innerHTML = "volume_down";
942		  } else {
943			volume.innerHTML = "volume_up";
944		  }
945		
946	}
947	
948	function muteVideoVolume(){
949		
950		if (volumeRange.value == 0) {
951			volumeRange.value = 60;
952			VideoScr.volume = 0.6;
953			volume.innerHTML = "volume_up";
954		  } else {
955			volumeRange.value = 0;
956			VideoScr.volume = 0;
957			volume.innerHTML = "volume_off";
958		  }
959		
960	}
961	
962	function setVideoTime(e){
963		
964		  let videoDuration = VideoScr.duration;
965		  let progressWidthvalue = videoProgressLine.clientWidth + 2;
966		  let ClickOffsetX = e.offsetX;
967		  VideoScr.currentTime = (ClickOffsetX / progressWidthvalue) * videoDuration;
968		  let progressWidth = (VideoScr.currentTime / videoDuration) * 100 + 0.5;
969		  videoProgressBar.style.width = `${progressWidth}%`;
970		  let currentVideoTime = VideoScr.currentTime;
971		  let currentVideoMinute = Math.floor(currentVideoTime / 60);
972		  let currentVideoSeconds = Math.floor(currentVideoTime % 60);
973		  // if seconds are less than 10 then add 0 at the beginning
974		  currentVideoSeconds < 10
975			? (currentVideoSeconds = "0" + currentVideoSeconds)
976			: currentVideoSeconds;
977		  current.innerHTML = `${currentVideoMinute} : ${currentVideoSeconds}`;
978		
979	}
980	
981	function PreLoadIframeVideo($i){
982		
983		$iframe = $lbt_images.eq($i).data();
984		
985		$("#lbt-lightbox-media", options.container_lightbox).append([
986			$_iframe = $('<iframe/>',{"src": $iframe['iframe_src']}).attr('frameborder', $iframe['frameborder']).attr('allow', $iframe['iframe_allow']).attr('fullscreen', $iframe['fullscreen']).addClass("lbt-iframe-video").css("visibility","hidden")
987		]);
988		
989		$_iframe.on("load",function(){
990			$(".lbt-iframe-video", options.container_lightbox).css("visibility","visible");
991			$("#lbt-loading", options.container_lightbox).hide();
992		});
993		
994	}
995	
996	function PreLoadImage(src){
997		
998		$("#lbt-lightbox-media", options.container_lightbox).append([
999			$('<img/>',{"id": "lbt-lightbox-image"}).css({"max-height": "calc(100% - "+ (165 + Number(options.pagination_height.replace("px", ""))) +"px)", top: "calc(50% - "+ (options.pagination_height.replace("px", "") / 2) +"px)"})
1000		]);
1001		
1002		var img = new Image(),
1003		x = document.getElementById("lbt-lightbox-image");
1004		
1005		img.src = src;
1006		
1007		img.onload = function() {
1008			x.src = img.src;
1009			$("#lbt-loading", options.container_lightbox).hide();
1010		};
1011		
1012	}
1013	
1014	function GetHTML5Videos(){
1015		
1016		$lbt_hvideos = $("video", options.container_images);
1017		
1018		$($lbt_hvideos).each(function(i){
1019			
1020			$(this).after([
1021				$obj = $('<img/>', {"class": $(this).attr('class')}).data('html5Video', $(this).find('source').attr('src')).data('html5type', $(this).find('source').attr('type'))
1022			]);
1023			
1024			GetThumHTML5Video($(this).find('source').attr('src'), $obj, $(this).width(), $(this).height());
1025			
1026			$(this).remove();
1027			
1028		});
1029		
1030		$lbt_images = $(options.custom_children, options.container_images);
1031		
1032	}
1033	
1034	function GetIframeVideos(){
1035		
1036		$lbt_ivideos = $("iframe", options.container_images);
1037		
1038		$($lbt_ivideos).each(function(i){
1039			
1040			$lbt_ivideos_thumbnail = "";
1041			$lbt_ivideos_src = $(this).attr('src');
1042			$lbt_ivideos_width = $(this).css('width');
1043			$lbt_ivideos_height = $(this).css('height');
1044			$lbt_ivideos_frameborder = $(this).attr('frameborder');
1045			$lbt_ivideos_fullscre = (typeof $(this).attr('allowfullscreen') !== 'undefined' && $(this).attr('allowfullscreen') !== false ? true : false);
1046			$lbt_ivideos_allow = $(this).attr('allow');
1047			
1048			var youtube = new RegExp("(?:https?:\/\/)?(?:www\.)?youtu(?:\.be\/|be.com\/\S*(?:watch|embed)(?:(?:(?=\/[-a-zA-Z0-9_]{11,}(?!\S))\/)|(?:\S*v=|v\/)))([-a-zA-Z0-9_]{11,})");
1049			var vimeo = new RegExp('(?:https?:\/\/)?(?:www.|player.)?vimeo.com(?:\/*(?:video\/|))([-a-zA-Z0-9_]{9})|.([\w\\-_]+)\&?=([-a-zA-Z0-9_]{10})');
1050
1051			
1052			if(youtube.test($lbt_ivideos_src)){
1053				
1054				$lbt_ivideos_id = $lbt_ivideos_src.match(/(?:https?:\/{2})?(?:w{3}\.)?youtu(?:be)?\.(?:com|be).(?:embed)(?:\/watch\?v=|\/)([^\s&]+)/)[1];
1055				
1056				$lbt_ivideos_thumbnail = 'https://i3.ytimg.com/vi/' + $lbt_ivideos_id + '/maxresdefault.jpg';
1057				
1058				
1059				$(this).after([
1060				$('<img/>').attr('src', $lbt_ivideos_thumbnail).data('lbt-thumb', $lbt_ivideos_thumbnail).css('height', $lbt_ivideos_height).css('width', $lbt_ivideos_width).data('iframe_src', $lbt_ivideos_src).data('frameborder', $lbt_ivideos_frameborder).data('fullscreen', $lbt_ivideos_fullscre).data('iframe_allow', $lbt_ivideos_allow)
1061					]);
1062				
1063				$(this).remove();
1064				
1065			}else if(vimeo.test($lbt_ivideos_src)){
1066				
1067				$lbt_ivideos_id = $lbt_ivideos_src.match(/(?:https?:\/\/)?(?:www.|player.)?vimeo.com(?:\/*(?:video\/|))([-a-zA-Z0-9_]{9}).([\w\\-_]+)\&?/)[1];
1068				
1069				$vimeo_obj = $(this);
1070				
1071				$.getJSON('https://vimeo.com/api/oembed.json?url=https://vimeo.com/' + $lbt_ivideos_id, {format: "json"}, function(data){
1072					
1073					$lbt_ivideos_thumbnail = data.thumbnail_url;
1074					
1075					$vimeo_obj.after([
1076					$('<img/>').attr('src', $lbt_ivideos_thumbnail).data('lbt-thumb', $lbt_ivideos_thumbnail).css('height', $lbt_ivideos_height).css('width', $lbt_ivideos_width).data('iframe_src', $lbt_ivideos_src).data('frameborder', $lbt_ivideos_frameborder).data('fullscreen', $lbt_ivideos_fullscre).data('iframe_allow', $lbt_ivideos_allow)
1077						]);
1078					
1079					$vimeo_obj.remove();
1080					
1081					$lbt_images = $(options.custom_children, options.container_images);
1082					
1083				});
1084				
1085			}else{
1086				return;
1087			}
1088			
1089		});
1090		
1091		$lbt_images = $(options.custom_children, options.container_images);
1092		
1093	}
1094	
1095	function MountThumbs(obj, menu){
1096		
1097		$totalImages = $lbt_images.length;
1098		
1099		$start = Math.max(0, (Math.ceil($(obj).index(options.custom_children) - (options.qtd_pagination / 2))));
1100		
1101		$final = Math.min(($totalImages - 1), (Number.isInteger($f = ((Math.floor($(obj).index(options.custom_children)) + (options.qtd_pagination / 2)))) ? ($f - 1) : $f ) );
1102		
1103		
1104		
1105		
1106		if($start == 0){
1107			
1108			$final = Math.min((options.qtd_pagination - 1), ($totalImages - 1));
1109			
1110		}else if($final == ($totalImages -1)){
1111			
1112			$start = Math.max(0, ($totalImages - options.qtd_pagination));
1113			
1114		}
1115		
1116		for (var i = $start; i <= $final; i++) {
1117		   
1118		   $thumb = null;
1119		   
1120		   if(i != $(obj).index(options.custom_children)){
1121				
1122				$(menu, options.container_lightbox).append([
1123					$('<li/>').append([
1124						$thumb = $('<img/>',{"class": "lbr-thumb"}).data('thumb_id', i).css({width: options.pagination_width, height: options.pagination_height})
1125					])
1126				]);
1127				
1128			}else{
1129				
1130				$(menu, options.container_lightbox).append([
1131					$('<li/>').append([
1132						$thumb = $('<img/>',{"class": "lbr-thumb"}).data('thumb_id', i).addClass('active').css({width: options.pagination_width, height: options.pagination_height})
1133					])
1134				]);
1135				
1136			}
1137			
1138			
1139			if(typeof $lbt_images.eq(i).data('lbt-thumb') == 'undefined'){
1140				
1141				CreateThumb($lbt_images.eq(i), {h:Number(options.pagination_height.replace("px", "")), w:Number(options.pagination_width.replace("px", ""))}, $thumb);
1142				
1143			}else{
1144				
1145				$($thumb).attr('src', $lbt_images.eq(i).data('lbt-thumb'));
1146				
1147			}
1148			
1149		}
1150		
1151	}	
1152		
1153	function LoadImages(imgs){
1154		
1155		$(imgs).each(function(i){
1156			
1157			if(typeof $(this).attr('src') !== 'undefined'){
1158				
1159				if($(this).attr('src').match('^blob:https?:\/\/(?:www\.)?') == null){
1160					
1161					ImageTob64(this);
1162					
1163				}
1164				
1165			}
1166			
1167		});
1168		
1169	}
1170	
1171	function CreateThumbs(imgs, rate){
1172		
1173		$(imgs).each(function(i){
1174			
1175			ResizeImage($(this).attr('src'), rate, this);
1176			
1177		});
1178		
1179	}
1180	
1181	function CreateThumb(img, rate, thumb){
1182		
1183		ResizeImage($(img).attr('src'), rate, $(img, options.container_lightbox), thumb);
1184		
1185	}
1186	
1187	async function GetThumHTML5Video(url, obj, width, height){
1188	
1189		  const video = document.createElement("video");
1190		  const canvas = document.createElement("canvas");
1191		  video.style.display = "none";
1192		  canvas.style.display = "none";
1193		  
1194		  video.setAttribute('crossOrigin', 'anonymous');
1195
1196		  // Trigger video load
1197		await new Promise((resolve, reject) => {
1198			video.addEventListener("loadedmetadata", () => {
1199			  video.width = width;
1200			  video.height = height;
1201			  canvas.width = width;
1202			  canvas.height = height;
1203			  // Seek the video to 25%
1204			  video.currentTime = video.duration * 0.25;
1205			});
1206			video.addEventListener("seeked", () => resolve());
1207			video.src = url;
1208		});
1209
1210		  // Draw the thumbnail
1211		canvas.getContext("2d").drawImage(video, 0, 0, width, height);
1212		const imageUrl = canvas.toDataURL("image/png");
1213
1214		$(obj).attr('src', imageUrl);
1215		
1216	}
1217	
1218	function ResizeImage(url, rate, obj, thumb = null){
1219		rate = rate || {};
1220		rate.q = rate.q || 1;
1221		rate.r = rate.r || 1;
1222
1223		var image = new Image();
1224
1225		image.setAttribute('crossOrigin', 'anonymous');
1226		
1227		image.src = url;
1228		
1229		image.onload = function () {
1230			var canvas = document.createElement('canvas');
1231			if(rate.w && rate.h){				
1232				if(rate.w > rate.h){
1233					canvas.width = rate.w;
1234					canvas.height = this.naturalHeight * rate.w / this.naturalWidth;
1235				}else{
1236					canvas.width = this.naturalWidth * rate.h / this.naturalHeight;
1237					canvas.height = rate.h;
1238				}				
1239			}else if(rate.w) {
1240				canvas.width = rate.w;
1241				canvas.height = this.naturalHeight * rate.w / this.naturalWidth;
1242			}else if(rate.h) {
1243				canvas.width = this.naturalWidth * rate.h / this.naturalHeight;
1244				canvas.height = rate.h;
1245			}else{
1246				canvas.width = this.naturalWidth * rate.r;
1247				canvas.height = this.naturalHeight * rate.r;
1248			}
1249
1250			canvas.getContext('2d').drawImage(this, 0, 0, canvas.width, canvas.height);
1251			
1252			CB_Updater(canvas.toDataURL(), obj, thumb);
1253		};
1254
1255	}
1256	
1257	async function ImageTob64(obj){
1258		
1259		var image = new Image();
1260
1261		image.setAttribute('crossOrigin', 'anonymous');
1262		
1263		image.src = $(obj).attr('src');
1264		
1265		image.onload = function(){
1266			
1267			var canvas = document.createElement('canvas');
1268			canvas.height = this.naturalHeight;
1269			canvas.width = this.naturalWidth;			
1270			canvas.getContext('2d').drawImage(this, 0, 0);
1271			
1272			CB_Updater(canvas.toDataURL(), obj, false, true);
1273			
1274		};
1275		
1276		await image.decode();
1277		
1278	}
1279	
1280	function CB_Updater(dataUrl, img, thumb, gallery = false){
1281		
1282		if(gallery){
1283			
1284			$oimage = $(img, options.container_lightbox).attr('src');
1285			
1286			$(img, options.container_lightbox).attr('src', dataUrl);
1287			
1288			$blob = ConvertToBlob(dataUrl);
1289			
1290			$(img, options.container_lightbox).attr('src', URL.createObjectURL($blob));
1291			
1292			//SaveBD($blob, $oimage);
1293			
1294			let _image = {
1295			  type: $oimage,
1296			  image: $blob,
1297			  created: new Date()
1298			};
1299			
1300			saveToIndexedDB('images', _image);
1301			
1302		}else{
1303			$(img, options.container_lightbox).data('lbt-thumb', dataUrl);
1304		}
1305		
1306		if(thumb){
1307			
1308			$(thumb, options.container_lightbox).attr('src', dataUrl);
1309			
1310		}
1311		
1312	};
1313	
1314	async function LoadBdImages(imgs){
1315		
1316		for (var i = 0; i < $(imgs).length; i++) {
1317			await loadFromIndexedDB('images', $(imgs).eq(i).attr('src')).then(function($res){
1318				$(imgs).eq(i).attr('src', URL.createObjectURL($res['image']));
1319			}).catch(function(error){
1320			});
1321		}
1322		
1323		LoadImages($lbt_images);
1324		
1325	}
1326	
1327	function ConvertToBlob(dataUrl){
1328		
1329		let contentType = dataUrl.split(";base64")[0].replace('data:', '');		
1330		
1331		return base64toBlob(dataUrl.split(",")[1], contentType);
1332		
1333	}
1334	
1335    return this.each(function(i){
1336		
1337		$id = "#" + "lbt-lightbox_" + (Math.floor(Math.random() * 999) + i);
1338		$idi = "#" + (typeof $(this).attr('id') == 'undefined' ? $(this).attr('id', "lbt-img
1338s_" + (Math.floor(Math.random() * 999) + i)).attr('id') : $(this).attr('id'));
1339		
1340		$("body").append([
1341			$con_lightbox = $('<div/>',{"id": $id.replace("#", "")})
1342		]);
1343		
1344		options = $.extend({lbt_id: $id, lbr_id: $idi, container_images: this, container_lightbox: $con_lightbox}, options);
1345		setListeners(this, options);
1346		
1347    });
1348  };
1349})(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.