PageSourceSearch

https://goksezam.pl/js/sam3/concept.newsbox.0.5.js

js goksezam.pl collected 2026-10-05 11:38:39 UTC 12,654 bytes, 447 lines download raw bytes

1//	Concept Intermedia 2016
2//	Concept Newsbox - wersja z pionowo ułożonymi miniaturkami
3//	Last modified:
4//	2017-05-09
5
6if (typeof globalPause == 'undefined') {
7	globalPause=false;
8}
9
10/* przeniesione z portal.php */
11function newsboxrespo() {
12    var height;
13    height = jQuery(".newsbox-container li.zaj-wrapper.active").outerHeight();				
14    jQuery(".newsbox-container").css("height",height);
15}
16
17
18jQuery(window).on("load", function () {
19	newsboxrespo();			
20	setTimeout(function(){ newsboxrespo(); }, 300);  	
21});
22
23
24var createNewsbox;
25createNewsbox = function(newsboxParams) {
26	//cc(111,'createNewsbox',newsboxParams);
27	//globalPause=true;
28	
29	var params = newsboxParams;
30	
31	
32	//	**********************
33	//	NEW FUNCTIONS		*/
34	params.showPager2 = true;
35	params.showPagerNumbers = false;
36	//	*******************	*/
37	
38	newsboxParams.showNavigationArrows = true;
39	
40	var localPause = false;
41	var focusPause = false;
42	
43	var currentNews = 0;
44	var total = 0;
45	
46	var sliderTimer;
47	var thumbnailHeight = 0;
48		
49	var inTransition = false;
50	
51	//container,slideClass,pager,pagerNumbers,arrows,progressBar
52	var con = jQuery(params.containerClass);
53	var slides = jQuery(con).find(params.singleSlideClass);
54	var pager;
55	var pager2;
56	var pagerButtons = [];
57	var pagerButtons2 = [];
58	var pagerButtonsClones = [];
59	var pagerAnimated = false;
60	
61	total = slides.length;
62	
63	//	ustaw parametry jako false je�li nie zostały przekazane do funkcji w newsboxParams
64	if (!params.showPager) params.showPager = false;
65	if (!params.showPager2) params.showPager2 = false;
66	if (!params.showPagerNumbers) params.showPagerNumbers = false;
67	if (!params.showNavigationArrows) params.showNavigationArrows = false;
68	if (!params.showTimer) params.showTimer = false;
69	if (!params.delay) params.delay = 5000;
70	if (!params.mouseHoverPauseDuration) params.mouseHoverPauseDuration = 1000;
71	if (!params.thumbnailTransitionDuration) params.thumbnailTransitionDuration = '0.3s';
72	if (!params.hideCurrentThumbnailOnChange) params.hideCurrentThumbnailOnChange = true;	//	czy aktualna pozycja na liście ma być chowana czy wyświetlana
73	
74	
75	//	slides data
76	for (var i=0;i<slides.length;i++){
77		jQuery(slides[i]).attr('data-news-id',(i+1));
78	}
79	
80	//	timer
81	if (params.showTimer) {
82		timer = jQuery('<span class="timer"></span>');
83		timerBar = jQuery('<span class="timer-bar"></span>');
84		jQuery(timer).append(timerBar);
85		jQuery(con).append(timer);
86	}
87	
88	var allButtons=null;
89	//	pager - !!! czyli tutaj lista zajawek z boku
90	if (params.showPager) 
91	{
92		pager = jQuery('<span class="pager" aria-hidden="true"></span>');
93		
94		var extraOrder = 0;	//	używany by pokazywać albo chować aktywną miniaturkę poprzez opcje
95		if (params.hideCurrentThumbnailOnChange) extraOrder = 1;
96		
97		if (total<=3) extraOrder = 0;
98		
99		for (var i=0;i<slides.length;i++)
100		{
101			var pagerButtonContent = '';
102			if (params.showPagerNumbers) pagerButtonContent=(i+1);
103			pagerButtonContent = jQuery('a',slides[i]).html();
104			button = jQuery('<span class="pager-button but'+(parseInt(i)+1)+'" data-news-id="'+(i+1)+'" data-order="'+(i-extraOrder)+'"><span class="hidden-wcag">Przejdź na stronę: </span>'+pagerButtonContent+'</span>');
105			pagerButtons.push(button);
106			jQuery(pager).append(button);
107		};
108		//	clone buttons
109		if (total>3){
110			for (var i=0;i<slides.length;i++){
111				var pagerButtonContent = '';
112				if (params.showPagerNumbers) pagerButtonContent=(i+1);
113				pagerButtonContent = jQuery('a',slides[i]).html();
114				button = jQuery('<span class="pager-button clone but'+(parseInt(i)+1)+'" data-news-id="'+(i+1)+'" data-order="'+(i-extraOrder+slides.length)+'"><span class="hidden-wcag">Przejdź na stronę: </span>'+pagerButtonContent+'</span>');
115				pagerButtonsClones.push(button);
116				jQuery(pager).append(button);
117			};
118		}
119		jQuery(con).append(pager);
120		jQuery('.pager',con).wrap('<span class="pager-con"></span>');
121		
122		allButtons = jQuery('.pager-button',con);
123		
124		setButtonsPositions();
125		
126		jQuery('.pager-button',pager).click(function(){
127			if (!jQuery(this).hasClass('active')){
128				nextNews = jQuery(this).attr('data-news-id');
129				showNews(nextNews);
130				newsboxrespo();
131			}
132		});
133	}
134	//	pager 2 - !!! czyli tutaj kwadraciki przełączniki
135	if (params.showPager2) 
136	{
137		pager2 = jQuery('<span class="pager2"></span>');
138		
139		for (var i=0;i<slides.length;i++){
140			var pagerButtonContent2 = '';
141			if (params.showPagerNumbers) pagerButtonContent2=(i+1);
142			var button2 = jQuery('<span class="pager-button2 but'+(parseInt(i)+1)+'" data-news-id="'+(i+1)+'" data-order="'+(i)+'"><span class="hidden-wcag">Przejdź na stronę: </span>'+pagerButtonContent2+'</span>');
143			pagerButtons2.push(button2);
144			jQuery(pager2).append(button2);
145		};
146		
147		jQuery(con).append(pager2);
148		jQuery('.pager2',con).wrap('<span class="pager2-con"></span>');
149		
150		allButtons2 = jQuery('.pager-button2',con);
151		
152		jQuery('.pager-button2',pager2).click(function(){
153			if (!jQuery(this).hasClass('active')){
154				nextNews = jQuery(this).attr('data-news-id');
155				showNews(nextNews);
156				newsboxrespo();
157			}
158		});
159	}
160	
161	
162	//	set buttons positions
163	//	set height of thumbnail containers
164	function setButtonsPositions(dir)
165	{
166		//cc('setButtonsPositions');
167       // console.log('setButtonsPositions');
168		//	count negative thumbnails height
169		var thumbsNegativeH = 0;
170		for (var i=-50; i<0;i++)
171		{
172			var thisB = jQuery(pager).find('.pager-button[data-order='+i+']');
173			if (thisB && thisB != undefined && thisB.length > 0)
174			{
175				var thisH = jQuery(thisB).height();
176				thumbsNegativeH += thisH;
177			}
178		}
179		//console.log(thumbsNegativeH, 'thumbsNegativeH');
180				
181		var allThumbsTotalH = 0;
182		var orgThumbsH = 0;
183		
184		if (allButtons)
185		{
186			for (var i=-5; i<=allButtons.length;i++)
187			{
188				var thisB = jQuery(pager).find('.pager-button[data-order='+i+']');
189				if (thisB && thisB != undefined && thisB.length > 0)
190				{
191                    //console.log(thisB[0], i);
192					myTop = allThumbsTotalH - thumbsNegativeH;
193                    //console.log(myTop, 'myTop['+i+']');					
194					
195					jQuery(thisB).css({'transform':'translate3d(0px,'+myTop+'px,0)'});
196					
197					var thisH = jQuery(thisB).height();
198					//console.log(thisH, 'thisH');
199					allThumbsTotalH += thisH;
200					
201					if (!jQuery(thisB).hasClass('clone')){
202						orgThumbsH += thisH;
203					}
204				}
205			}
206		}
207		var pagerH = jQuery(con).find('.pager-con').height();
208		jQuery(con).find('.pager-con').removeClass('animated-pager');
209		pagerAnimated = false;
210		if (orgThumbsH > pagerH)
211		{
212			jQuery(con).find('.pager-con').addClass('animated-pager');
213			pagerAnimated = true;
214		}
215		
216	}
217	function resetButtonsPositions(){
218		if (allButtons){
219			for (var i=0; i<allButtons.length;i++)
220			{
221				var thisB = jQuery(allButtons[i]);
222				if (thisB)
223				{
224					jQuery(thisB).attr('data-order',i);
225				}
226			}
227		}
228	}
229	
230	
231	//	add focus outlines
232	jQuery(con).append('<div class="newsbox-outline nbo-top"></div><div class="newsbox-outline nbo-right"></div><div class="newsbox-outline nbo-bottom"></div><div class="newsbox-outline nbo-left"></div>');
233	
234	
235	//	navigation arrows
236	if (params.showNavigationArrows && total>3) {
237		navArrows = jQuery('<span class="nav-arrows" aria-hidden="true"></span>');
238		prev = jQuery('<span class="nav-arrow prev">PREV</span>');
239		next = jQuery('<span class="nav-arrow next">NEXT</span>');
240		jQuery(navArrows).append(prev).append(next);
241		jQuery(con).append(navArrows);
242		
243		//	prev click
244		jQuery(prev).click(function(){
245			showPrevNews();
246		});
247		
248		//	next click
249		jQuery(next).click(function(){
250			showNextNews();
251			newsboxrespo();
252		});
253	}
254	
255	//	focus
256	jQuery(con).focusout(function(){
257		jQuery(con).removeClass('focused');
258		focusPause = false;
259		startTimer();
260	});
261	jQuery(params.singleSlideClass,con).focusin(function(){
262		jQuery(con).addClass('focused');
263		focusPause = true;
264		stopTimer();
265
266		nextNews = jQuery(this).attr('data-news-id');
267		showNews(nextNews);
268		newsboxrespo();
269	});
270	
271	//	init
272	currentNews = 1;
273	oldThumbnail = 1;
274	showNews(currentNews);
275	startTimer();
276	
277	function showNews(newsId,dir){
278		if (!inTransition)
279		{
280			//inTransition ==true;
281			
282			currentNews = parseInt(newsId);
283			newsId--;
284			jQuery(params.singleSlideClass,con).removeClass('active');
285			jQuery(slides[newsId]).addClass('active');
286			
287			jQuery('.pager-button,.pager-button2',con).removeClass('active');
288			jQuery(pagerButtons[newsId]).addClass('active');
289			jQuery(pagerButtons2[newsId]).addClass('active');
290			jQuery(pagerButtonsClones[newsId]).addClass('active');
291			
292			showThumbnail(currentNews,dir);
293			newsboxrespo();
294		}
295	}	
296	
297	function showPrevNews(){
298		nextNews = currentNews-1;
299		if (nextNews===0) {nextNews = total;}
300		showNews(nextNews,'prev');
301		newsboxrespo();
302	}
303	function showNextNews(){
304		nextNews = currentNews+1;
305		if (nextNews>total) {nextNews = 1;}
306		showNews(nextNews,'next');
307		newsboxrespo();
308	}
309	
310	function showThumbnail(newThumbnail,dir){
311		// console.log('showThumbnail('+newThumbnail+')');
312		
313		if (total <= 3) return 0;
314		
315		if (typeof(dir) == 'undefined') dir = 'next';
316		var dif = 0;
317		//resizeActions();
318		
319		if (pagerAnimated)
320		{
321			//console.log('!!!');
322			if (newThumbnail>=oldThumbnail) 
323			{
324				dif = newThumbnail - oldThumbnail;
325			}
326			else 
327			{
328				dif = total - oldThumbnail + newThumbnail;
329				//dir = 'back';
330			}
331			
332			// do przodu
333			if (dir == 'next')
334			{
335				//	reset buttons before animation
336				for (var i=0; i<allButtons.length;i++)
337				{
338					jQuery(allButtons[i]).removeClass('animated');
339					var oldOrd = parseInt(jQuery(allButtons[i]).attr('data-order'));
340					if (oldOrd < 0)
341					{
342						oldOrd += total + total;
343					}
344					jQuery(allButtons[i]).attr('data-order',oldOrd);
345				}
346				setButtonsPositions(dir);
347				
348				for (var i=0; i<allButtons.length;i++)
349				{
350					jQuery(allButtons[i]).removeClass('animated');
351					var oldOrd = parseInt(jQuery(allButtons[i]).attr('data-order'));
352									
353					//	move to new positions
354					var extraDiff = 0;
355					var newOrd = oldOrd - dif;
356					jQuery(allButtons[i]).attr('data-order', newOrd);
357					// console.log(oldOrd + ' --> ' + newOrd, 'showThumbnail('+newThumbnail+', '+dir+') ['+i+']');
358					// console.log(jQuery(allButtons[i])[0]);					
359					var newY = newOrd * thumbnailHeight;
360					newY -= thumbnailHeight;
361				}
362				setTimeout(function(i,newY){
363						//console.log(i);
364						jQuery('.pager-button',pager).addClass('animated');
365						setButtonsPositions(dir);
366				},15,i,dir);
367				oldThumbnail = newThumbnail;
368			}
369			//	do tyłu
370			else if (dir == 'prev'){
371				
372				//	reset buttons before animation
373				for (var i=0; i<allButtons.length;i++){
374					jQuery(allButtons[i]).removeClass('animated');
375					var oldOrd = parseInt(jQuery(allButtons[i]).attr('data-order'));
376					if (oldOrd >= (total+total-2)){
377						oldOrd -= (total + total);
378					}
379					jQuery(allButtons[i]).attr('data-order',oldOrd);
380				}
381				setButtonsPositions(dir);
382				
383				for (var i=0; i<allButtons.length;i++){
384					jQuery(allButtons[i]).removeClass('animated');
385					var oldOrd = parseInt(jQuery(allButtons[i]).attr('data-order'));
386									
387					//	move to new positions
388					var newOrd = oldOrd+1;
389					jQuery(allButtons[i]).attr('data-order',newOrd);
390					var newY = newOrd*thumbnailHeight;
391					newY-=thumbnailHeight;
392				}
393				setTimeout(function(i,newY){
394						//console.log(i);
395						jQuery('.pager-button',pager).addClass('animated');
396						setButtonsPositions(dir);
397				},15,i,dir);
398				oldThumbnail = newThumbnail;
399			}
400		}
401	}
402	
403	
404	function startTimer(){
405		clearInterval(sliderTimer);
406		sliderTimer = setInterval(function(){
407			if (!globalPause && !focusPause && !localPause) showNextNews();
408		}, params.delay);
409	}
410	function stopTimer(){
411		clearInterval(sliderTimer);
412	}
413	
414	
415	
416	jQuery(window).resize(function(){resizeActions();});
417	function resizeActions(){
418		resetSlider();
419	}
420	
421	function resetSlider(){
422		currentNews = 1;
423		oldThumbnail = 1;
424		resetButtonsPositions()
425		setButtonsPositions();
426		showNews(currentNews);
427		startTimer();
428	}
429	
430	jQuery(window).on("load", function(){
431		setButtonsPositions();
432	});
433
434	
435	
436	jQuery(con).on("mouseenter", function(){
437		localPause=true;
438		stopTimer()
439	});
440	
441	jQuery(con).on("mouseleave", function(){
442		localPause=false;
443		if (!localPause){
444			startTimer();
445		}
446	});
447}

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.