PageSourceSearch

https://st.uralweb.ru/js/litebox-events.js?2.11

js uralweb.ru collected 2026-09-24 08:26:33 UTC 5,183 bytes, 141 lines download raw bytes

1;
2$(function () {
3
4	/* close modals on ESC */
5	function observeEscKeyPress(e) {
6		if ((e.keyCode === 27 || (e.DOM_VK_ESCAPE === 27 && e.which === 0)))
7		{
8			$.closeBlackContainer(e);
9		}
10	}
11
12	jQuery.closeBlackContainer = function (eventOrObject){
13		let openedObject;
14		if (eventOrObject instanceof Event && eventOrObject.type === 'keyup') {
15			// keyboard event, find opened element
16			openedObject = $('.black-container');
17		} else {
18			// object here
19			openedObject = eventOrObject;
20		}
21		let blackContainer = $(openedObject);
22		if ( $(blackContainer).length > 0 ) {
23			$('body').removeClass('overflow-hidden');
24			$(blackContainer).hide();
25			$(blackContainer).html('');
26		}
27	}
28
29	jQuery.openBlackContainer = function (object){
30		let blackContainer = $(object);
31		if ( $(blackContainer).length > 0 ) {
32			$('body').addClass('overflow-hidden');
33			$(blackContainer).show();
34			// bind keyboadrd close
35			window.addEventListener('keyup', observeEscKeyPress);
36			// bind close
37			$(blackContainer).on('click', '.link-to-whitebox', function (e) {
38				e.preventDefault();
39				$.closeBlackContainer(blackContainer);
40			});
41		}
42	}
43
44	let photosList = [];
45	function getPhotosList(){
46		$('a.litebox-me').each(function(){
47			let aloneurl 	= $(this).data('alone');
48			let photoname	= $(this).data('photo');
49			if ( aloneurl !== '' && $('#blackbox_'+photoname).length > 0 ) {
50				photosList.push(photoname);
51			}
52		});
53		let maxIndex	= photosList.length - 1;
54		photosList.forEach(function(photoname, index, array) {
55			let nextindex;
56			let previndex;
57			
58			if ( index == 0 ) {
59				previndex 	= maxIndex;
60				nextindex	= index + 1;
61			}
62			if ( index == maxIndex ) {
63				previndex 	= index - 1;
64				nextindex	= 0;
65			}
66			if ( index > 0 && index < maxIndex ) {
67				previndex 	= index - 1;
68				nextindex	= index + 1;
69			}
70			let blackBoxObj = $('#blackbox_'+photoname);
71			$(blackBoxObj).find( $('img.big-picture') ).data('index',index);
72			$(blackBoxObj).find( $('img.big-picture') ).data('previndex',previndex);
73			$(blackBoxObj).find( $('img.big-picture') ).data('nextindex',nextindex);
74		});
75		if ( photosList.length > 0 ) {
76			$('body').append('<div class="black-container" style="display:none;"></div>');
77		}
78		return photosList;
79	}
80	
81	photosList = getPhotosList();
82	
83	$('a.litebox-me').on('click',function(e){
84		e.preventDefault();
85		console.log('here');
86		let aloneurl 	= $(this).data('alone');
87		let photoname	= $(this).data('photo');
88		let h_diff 	= 100;
89		let h 			= ($(window).height() - h_diff);
90
91		let index		= photosList.indexOf(photoname);
92		let maxIndex	= photosList.length - 1;
93		
94		$('.photo-neighbors-black').css('min-height',h+'px');
95		$('#photo_full').css('max-height',h+'px');
96
97		let blackBoxObj = $('#blackbox_'+photoname);
98		
99		if ( aloneurl !== '' && $(blackBoxObj).length > 0 ) {
100			$(blackBoxObj).css('min-height',h+'px');
101			$(blackBoxObj).find( $('img.big-picture') ).css('max-height',h+'px');
102			$(blackBoxObj).find( $('img.big-picture') ).attr('src',aloneurl);
103			let pictdata	= $(blackBoxObj).find( $('img.big-picture') ).data();
104			
105			$('.black-container').html( $(blackBoxObj).html() );
106			$('.black-container > .big-picture').wrap('<div class="photo-neighbors-black"><div class="photo-full-block"></div></div>');
107			$('.black-container .photo-full-block').css('min-height',h+'px');
108			$('.black-container .photo-neighbors-black').prepend('<div class="neighbor prev"></div>');
109			$('.black-container .photo-neighbors-black').append('<div class="neighbor next"></div>');
110
111			$('.black-container .photo-neighbors-black').prepend('<div class="link-to-whitebox"><a href="#" class="special-link" title="Закрыть"><span class="icon-uw-photos-uwp2-arrow-min"></span></a></div>');
112			$('.black-container img.big-picture').data(pictdata);
113			if ( maxIndex > 1 ) {
114				$('.black-container .photo-neighbors-black .neighbor.prev').append('<a class="neighbors-link prev"><span class="uwh-icon-arrow-back"></span></a>');
115				$('.black-container .photo-neighbors-black .neighbor.next').append('<a class="neighbors-link next"><span class="uwh-icon-arrow-forward"></span></a>');
116				$('.black-container .photo-neighbors-black .neighbor a.neighbors-link').on('click',function(){
117					console.log('click neighbors-link in litebox');
118					e.preventDefault();
119					let currentdata 	= $('.black-container img.big-picture').data();
120					let newphotoname	= '';
121					if ( $(this).hasClass('prev') ) {
122						newphotoname	= photosList[currentdata.previndex];
123					}
124					if ( $(this).hasClass('next') ) {
125						newphotoname	= photosList[currentdata.nextindex];
126					}
127					if ( $('#blackbox_'+newphotoname).length > 0 ) {
128						let newpicdata	= $('#blackbox_'+newphotoname).find( $('img.big-picture') ).data();
129						$('.black-container img.big-picture').replaceWith( $('#blackbox_'+newphotoname).html() );
130						let newAloneUrl = $('a.litebox-me[data-photo='+newphotoname+']').data('alone');
131						$('.black-container img.big-picture').css('max-height',h+'px');
132						$('.black-container img.big-picture').attr('src',newAloneUrl);
133						$('.black-container img.big-picture').data(newpicdata);
134					}
135				});
136			}
137
138			$.openBlackContainer( $('.black-container') );
139		}
140	});
141});

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.