PageSourceSearch

https://esvet.si/sites/www.esvet.si/themes/esvet/scripts/script.js?s7chyl

js esvet.si collected 2026-10-04 22:06:35 UTC 41,581 bytes, 1,528 lines download raw bytes

1/* global console:true */
2
3// Returns a function, that, as long as it continues to be invoked, will not
4// be triggered. The function will be called after it stops being called for
5// N milliseconds. If `immediate` is passed, trigger the function on the
6// leading edge, instead of the trailing.
7
8var wait      = 200; // 100 miliseconds;
9var immediate = false; // Trigger conditon
10
11debounce = function(func, wait, immediate) {
12	var timeout;
13	return function() {
14		var context = this, args = arguments;
15		var later = function() {
16			timeout = null;
17			if (!immediate) func.apply(context, args);
18		};
19		var callNow = immediate && !timeout;
20		clearTimeout(timeout);
21		timeout = setTimeout(later, wait);
22		if (callNow) func.apply(context, args);
23	};
24};
25
26/* Stackowerflow
27// Disable mouse scroll and key events that trigger native scroll behaviours
28// @http://stackoverflow.com/questions/4770025/how-to-disable-scrolling-temporarily
29*/
30
31// left: 37, up: 38, right: 39, down: 40,
32// spacebar: 32, pageup: 33, pagedown: 34, end: 35, home: 36
33var keys = [37, 38, 39, 40];
34
35function preventDefault (e) {
36
37	e = e || window.event;
38	if (e.preventDefault)
39	e.preventDefault();
40	e.returnValue = false;
41
42}
43
44function keydown (e) {
45
46	for (var i = keys.length; i--;) {
47
48		if (e.keyCode === keys[i]) {
49
50			preventDefault(e);
51			return;
52
53		}
54
55	}
56
57}
58
59function wheel (e) {
60
61	preventDefault(e);
62
63}
64
65function disable_scroll () {
66
67	if (window.addEventListener) {
68		window.addEventListener('DOMMouseScroll', wheel, false);
69	}
70
71	window.onmousewheel = document.onmousewheel = wheel;
72	document.onkeydown = keydown;
73
74}
75
76function enable_scroll () {
77
78	if (window.removeEventListener) {
79		window.removeEventListener('DOMMouseScroll', wheel, false);
80	}
81
82	window.onmousewheel = document.onmousewheel = document.onkeydown = null;
83
84}
85
86function socialShare(type, title, path) {
87	// Set correct vars
88	var width = 505,
89			height = 370,
90			left = (jQuery(window).width()  - width) / 2,
91	top = (jQuery(window).height() - height) / 2,
92	opts = 'status=1' + ',width=' + width  + ',height=' + height + ',top=' + top + ',left=' + left,
93	url;
94
95	switch (type) {
96		case 'facebook':
97			url = 'https://www.facebook.com/sharer/sharer.php?u='+path;
98			break;
99		case 'twitter':
100			url = 'http://twitter.com/share?text='+title.replace("|","-")+'&url='+path;
101			break;
102		case 'google':
103			url = 'https://plus.google.com/share?url='+path;
104			break;
105		case 'linkedin':
106			url = 'https://www.linkedin.com/shareArticle?mini=true&url='+path+'&title='+title+'&summary=&source==';
107			break;
108	}
109
110	// Open window using set vars
111	window.open(url, type, opts);
112}
113
114(function($) {
115
116	// Document ready
117	$(document).ready(function() {
118
119		//Check if user agent is mobile and correct the .on() event
120		var touchDevice = navigator.userAgent.match(/(iPhone|iPod|iPad|Android)/i)?true:false;
121
122		if(touchDevice) {
123
124			clickAction = "touchstart";
125
126		}
127		else {
128
129			clickAction = "click";
130
131		}
132
133		// Table fix
134		if( $( 'table' ).length > 0 ) {
135
136			// Variables
137			var table_data = [];
138
139			// Feed me with data eh?
140			$( 'table' ).each( function ( index, value ) {
141
142				// Does the table have a table head?
143				var table_head = $( value ).find( 'thead' ).length > 0 ? $( value ).find( 'thead' ) : undefined;
144
145				if( table_head ) {
146
147					// Cool, lets loop through the child nodes and grab the values
148					$( table_head ).find( 'tr th' ).each( function ( index, value ) {
149
150						table_data[ index ] = $( value ).text();
151
152					} );
153
154				}
155
156				// We have the data, lets feed the DOM with it for the appropriate table
157				var table_body = $( value ).find( 'tbody' ).length > 0 ? $( value ).find( 'tbody' ) : undefined;
158
159				if( table_body ) {
160
161					//Cool, lets loop through the table cells and apply the HTML data
162					$( table_body ).find( 'tr' ).each( function ( index, value ) {
163
164							// Does the cell exist?
165							var table_cell = $( value ).find( 'td' ).length > 0 ? $( value ).find( 'td' ) : undefined;
166
167							if( table_cell ) {
168
169								$( table_cell ).each( function ( index, value ) {
170
171									// Grab current value of cell content
172									var table_text = $( value ).text();
173
174									// Clear current value of the cell content
175									$( value ).empty();
176
177									$( value ).html( '<div class="label">' + table_data[ index ] + '</div><div class="text">' + table_text + '</div>' );
178
179								} );
180
181							}
182
183					} );
184
185				}
186
187			} );
188
189		}
190
191		// Menu hamburger icon
192		$('#header-bar').on(clickAction, function(target) {
193
194			$('body').toggleClass('menu-closed');
195			$('.menu-closed #block-search-form').on(clickAction, function() {
196				$('body').removeClass('menu-closed');
197				$(this).find('.custom-search-box').focus();
198			});
199			// Wait for shity transition to end
200			$( '#page' ).one( 'webkitTransitionEnd otransitionend msTransitionEnd transitionend', function ( e ) {
201
202				// Do a quick layout update
203				updateLayout();
204
205
206			} );
207		});
208
209		// Animation link actions
210		$('.animation-link, .chart-link').on(clickAction, function(e) {
211
212			var _this           = $(this);
213			var type            = $(this).attr( 'class' );
214			var node            = _this.closest('.node');
215			var overlay         = $('.overlay-wrapper');
216			var content         = overlay.find('.overlay-content');
217			var closebtn        = overlay.find('#overlay-close');
218
219			// var viewport_width  = window.innerWidth - $( '.header' ).innerWidth();
220			var viewport_width  = window.innerWidth;
221			var viewport_height = window.innerHeight;
222
223			var condition       = viewport_width > 768 ? true : false;
224
225			// Define condition on resize
226			var resize = debounce( function(e) {
227
228				condition = viewport_width > 768 ? true : false;
229
230			}, wait );
231
232			console.log( 'Condition is: ' + condition + ', clickAction is: ' + clickAction );
233
234			// Define wait
235			// wait = 100;
236			// immediate = false;
237
238			// Can we do shit?
239			if( condition ) {
240
241				// Init body scroll
242				$('html, body').animate({
243					'scrollTop': node.offset().top
244				}, 500, 'swing', function () {
245
246					// Disable scroll behaviour
247					disable_scroll();
248
249					// Add states to node
250					// node.addClass('overlay-opened');
251
252					// Display close button
253					closebtn.fadeIn();
254
255					// Open overlay wrapper
256					overlay.addClass('active');
257
258					// Define overlay wrapper dimensions
259					/*
260					overlay.css( {
261
262						'height' : viewport_height + 'px',
263						'width'  : viewport_width + 'px'
264
265					} );
266					*/
267
268					// Do a quick layout update
269					updateLayout();
270
271					overlay.one('webkitAnimationEnd oanimationend msAnimationEnd animationend', function ( e ) {
272
273						// Set overlay as fixed
274						// overlay.addClass( 'fixed' );
275
276						// Open content
277						content.addClass('active');
278
279						// Fetch content
280						if( type === 'animation-link' ) {
281
282							content.html('<iframe src="/sites/www.esvet.si/themes/esvet/animations/' + _this.data('animation') + '.html"></iframe>');
283
284						}else {
285
286							$.ajax({
287
288								url: '/ajax/charts/'+_this.data('chart'),
289								type: 'POST',
290								success: function(data) {
291									var chart = content.html(data).find('.chart-render');
292									mychart = chart.charts();
293
294								}
295
296							});
297
298						}
299
300					});
301
302				} );
303
304			}
305
306		});
307
308		// Create the listener function
309		var updateLayout = debounce( function(e) {
310
311			// Static variables
312			// var _WIDTH  = 960;
313			// var _HEIGHT = 540;
314
315			// Define variables
316			var content        = $( '.overlay-content' );
317			var wrapper        = $( '.overlay-wrapper' );
318			var window_height  = window.innerHeight;
319			var window_width   = window.innerWidth;
320			var header_width   = $( '.header' ).innerWidth();
321
322			// var resize = ( window_width - header_width - 80 ) > _WIDTH ? true : false;
323
324			// 16 * 9 ratio
325			// var content_width  = _WIDTH;
326			// var content_height = _HEIGHT;
327
328			// Do we need to resize?
329			/*
330			if( !resize ) {
331
332				content_width  = _WIDTH - ( _WIDTH - ( window_width - header_width - 80 ) );
333				content_height = ( content_width * 9 ) / 16;
334
335			}
336			*/
337
338			// alert( 'Width is: ' + content_width );
339
340			// Define wrapper dimension
341			/*
342			wrapper.css( {
343
344				'width'  : window_width - header_width + 'px',
345				'height' : window_height + 'px'
346
347			} );
348			*/
349
350			// Define content size
351			content.css( {
352
353				'width'  : ( window_width - header_width - 40 ) + 'px',
354				'height' : ( window_height - 40 ) + 'px'
355
356			} );
357
358			console.log( wait + ' - ' + immediate );
359
360		}, wait, immediate ); // Maximum run of once per 100 milliseconds
361
362		// Add the event listener
363		window.addEventListener('resize', updateLayout, false);
364
365		// Popcorn.js
366		if ($('#video').length > 0) {
367			video = Popcorn('#video');
368
369			// Hide controls
370			video.controls( false );
371
372			// When the video is ready
373			video.on('canplayall', function() {
374				world = $('body').data('world');
375				world = world.replace(/-/g, '_');
376				setVideo(world, video);
377
378				$.each(ranges, function(key) {
379					video.cue(ranges[key].end, function() {
380						this.play(ranges[key].start);
381					});
382				});
383			});
384		}
385
386		// Set window height to content header and front page windows, and don't do it on webform page.
387		if ($('#page').hasClass('menu-depth-0') || $('#page').hasClass('menu-depth-1')){
388			$('#content-header').setHeight();
389		}
390
391		// Hide menu by default on small screens.
392		if (screen.width <= 768) {
393			setTimeout( function () {
394
395				$('body').addClass('menu-closed');
396
397			}, 200 );
398			// $('body').addClass('sidebar-closed');
399		}
400
401		// Set front page notification behaviour
402		if ($('#notification').length > 0) {
403			var notification = $('#notification');
404			setTimeout(function() {
405				notification.show();
406			}, 1000);
407
408			var notificationDelay = setTimeout(function() {
409				notification.addClass('fadeOutRightBig').one(animationEnd, function() {
410					$(this).hide();
411				});
412			}, 30000);
413
414			notification.find('.notification-close').on(clickAction, function() {
415				clearTimeout(notificationDelay);
416				notification.addClass('fadeOutRightBig').one(animationEnd, function() {
417					$(this).hide();
418				});
419			});
420		}
421
422		// Set slider to all columns content type
423		//$('article.node-columns-with-images .field-name-field-columns > .field-items').columnSlider();		//Jan's solution
424
425
426		$('article.node-columns-with-images .field-name-field-columns > .field-items').each(function(){			//Rok's solution - bug in plugin in case of elements matching selector
427			$(this).columnSlider();
428		});
429
430		// Set slider to footer partners logos
431		$('footer.footer #block-bean-partners .field-name-field-images > .field-items').columnSlider({
432			slidesPerWindow: 5,
433			appendPager: $('#block-bean-partners .block-title')
434		});
435
436		if ($('html.touch').length === 0){
437			$('.node-columns-with-images, .node-image-with-text').waypoint({
438				offset: '90%',
439				triggerOnce: true,
440				handler: function(direction) {
441					$(this).find('.field-name-field-image, .field-name-field-images').animated();
442				}
443			});
444		} else{
445			$('.field-name-field-image, .field-name-field-images').css('visibility', 'visible');
446		}
447
448		// Set content images alignment
449		if ($('.node-type-news').length > 0 || $('.node-type-basic-page').length > 0) {
450			if ($('.images-exchanging').length > 0) {
451				$('.fancybox-insert-image:odd').addClass('odd');
452				$('.fancybox-insert-image:even').addClass('even');
453			}
454		}
455
456		// Set footer news slider
457		$('footer.footer #block-views-news-footer_news .views-row-1').newsTimer();
458
459		// Menu click
460		/*
461		$('#header .block-menu-block .level-1.expanded').on('click', function(e) {
462			var _this = $(this);
463
464			if (e.target === this && !isAnimating) {
465
466				isAnimating = true;
467				$('body').toggleClass('menu-expanded');
468
469				_this.toggleClass('opened');
470
471				_this.find('.menu').on(transitionEnd, function() {
472					var _thisMenu = $(this);
473
474					_thisMenu.off(transitionEnd).parent().toggleClass('menu-opened');			//OK
475
476
477					// CODE TO GO BACK // click on vertical link
478					_thisMenu.parent().find('a').not('.level-2 a').on('click', function() {
479						if (_thisMenu.parent().hasClass('opened')) {
480							_thisMenu.parent().removeClass('opened menu-opened');
481							$('body').removeClass('menu-expanded').removeClass("third-level");
482
483							return false;
484						}
485					});
486					isAnimating = false;
487				});
488			}
489		});
490
491		$('#header .block-menu-block li.level-2.expanded').on('click', function(e) {
492			//console.log(e, this);
493			if (e.target.tagName != "SPAN" && !$(e.target).parent().hasClass("level-3")) {
494				$("body").addClass("third-level");
495				$(this).addClass("activated");
496
497				$(this).find("a").one("click",function(e) {
498					if (e.target.tagName != "SPAN" && !$(e.target).parent().hasClass("level-3")) {
499						$("body").removeClass("third-level");
500						$(this).parent().removeClass("activated");
501
502						return false;
503					}
504				});
505
506				$(".level-1 a").one("click", function(e) {
507					if (e.target.tagName != "SPAN" && !$(e.target).parent().hasClass("level-3")) {
508						$("body").removeClass("third-level");
509						$(this).parent().removeClass("activated");
510					}
511				});
512			} else if ($(this).hasClass("activated") && $(this).hasClass("level-2") && $(this).hasClass("menu-opened") && 1 == 2) {
513				//console.log("GREM SEM");
514				$(this).removeClass("activated").removeClass("menu-opened");
515				$("body").removeClass("third-level");
516				return false;
517			}
518		});
519		*/
520
521
522		/* Quick fix to close opened 2nd level submenu */
523		/*
524		$('#header .block-menu-block').on("click", "li.level-2.activated > a", function(e){
525			//console.log(this, "myevent:", e);
526
527			$(this).closest("li").removeClass("activated");
528			$("body").removeClass("third-level");
529
530			return false;
531		});
532		*/
533
534
535		/* $('#header .block-menu-block .level-2.expanded').on('click', function(e) {
536			if ($(this).hasClass("activated")) {
537				//open this menu
538				console.log($(this).removeClass("activated"));
539				$("body").removeClass("third-level");
540
541			} else {
542				//close this menu
543				console.log($(this).addClass("acivated"));
544				$("body").addClass("third-level");
545			}
546		}); */
547
548		/* open menu on 3rd level site */
549		/*
550		if ($(".active-trail.level-3, .active.level-3").length > 0) {
551			$(".active-trail.level-2").trigger("click");
552		}
553		*/
554
555
556		/* open menu on 2nd level site */
557		/*
558		if ($(".active-trail.level-2, .active.level-2").length > 0) {
559			$(".active-trail.active.level-2").trigger("click");
560		}
561		*/
562
563		// Chart link actions
564		/*
565		$('.chart-link').on('click', function() {
566			var _this = $(this);
567
568			_this.closest('.node').find('.overlay-wrapper #overlay-close').show();
569
570			// Open overlay wrapper
571			var overlay = _this.closest('.node').find('.overlay-wrapper').addClass('active');
572			_this.closest(".node").addClass("overlay-opened");
573			overlay.one(animationEnd, function() {
574				// Get chart data
575				$.ajax({
576					url: '/ajax/charts/'+_this.data('chart'),
577					type: 'POST',
578					success: function(data) {
579						var chart = overlay.find('.overlay-content').show().html(data).find('.chart-render');
580						mychart = chart.charts();
581
582						if(_this.data('chart') == 28) {
583						/* mychart = chart.highcharts();
584
585						mychart.addSeries({
586							name: 'Second series',
587							color: 'red',
588							data: $.map(new Array(12), Math.random),
589							yAxis: mychart.yAxis.length - 1
590						}); */
591
592						//mychart.addAxis({ // Secondary yAxis
593							/* id: 'maximum',
594							title: {
595								text: 'Rainfall'
596							},
597							lineWidth: 2,
598							lineColor: '#08F',
599							opposite: false */
600
601							/*
602							type: 'line',
603							name: 'Globale Biokapazität',
604							data: [9000,9000,9000,9000,9000]
605							*/
606						//});
607							/* mychart.addSeries({
608							name: 'Rainfall',
609							type: 'line',
610							color: '#08F',
611							yAxis: 'rainfall-axis',
612							data: [49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
613						}); */
614						/*
615						}
616					}
617				});
618			});
619		});
620		*/
621		if($('.field-name-field-animation-link').length) {
622
623
624			$('.field-name-field-animation-link').each(function() {
625				var animationLinkField = $(this);
626				var imageBlock = $(this).siblings('.field-name-field-image').find('.image-animation');
627
628				animationLinkField.appendTo(imageBlock);
629			});
630		}
631
632		// Handle footer click
633		$('.mailchimp-info').on(clickAction, function() {
634
635			$('#block-bean-footer-message .field-item').slideToggle(200);
636
637		});
638
639		// Overlay close action
640		$('#overlay-close').on(clickAction, function() {
641
642			var _this    = $(this);
643			// var node     = _this.closest('.node');
644			var overlay  = $('.overlay-wrapper');
645			var content  = overlay.find('.overlay-content');
646
647			// Enable native scroll behaviour
648			enable_scroll();
649
650			// Hide button
651			_this.fadeOut();
652
653			// Close content
654			content.removeClass('active');
655
656			// Hide content wrapper
657			overlay.addClass( 'close' );
658
659			overlay.one('webkitAnimationEnd oanimationend msAnimationEnd animationend', function ( e ) {
660
661				// Clear content
662				content.empty();
663
664				// Clear classes
665				overlay.removeClass( 'active close' );
666
667				// Remove states to node
668				// node.removeClass('overlay-opened');
669
670			});
671
672		});
673
674		// Footer mailchimp form
675		/*
676		$.ajaxChimp.translations.sl = {
677			'submit': 'Pošiljam ...',
678			0: 'Poslali smo vam sporočilo, s katerim potrdite svoj pravi e-naslov.',
679			1: 'Vpišite vaš elektronski naslov',
680			2: 'Elektronski naslov mora vsebovati @',
681			3: 'Ups, del vašega naslova je napačen. Še enkrat preverite zapis za @',
682			4: 'Ups, del vašega naslova je napačen. Še enkrat preverite zapis pred @',
683			5: 'Hm, zapisani naslov ali ne obstaja ali pa je neveljaven. Prosimo, da vpišete pravi e-naslov'
684		}*/
685
686		$('#mailchimp-form').ajaxChimp({
687			language: 'sl',
688			//url: 'http://gen-energija.us8.list-manage1.com/subscribe/post?u=96d047e5229d131de43f28034&amp;id=d8ce8659e3'
689			//url: 'http://gen-energija.us9.list-manage1.com/subscribe/post?u=7a5a096975baa211d1271c437627014b&amp;id=ae78f07d89'		//CORRECT!
690			url: 'http://enki.us9.list-manage.com/subscribe/post?u=28be5a10419c5e07acaa78d24&amp;id=ae78f07d89',		//CORRECT 2
691			callback: mailchimpResponse
692		});
693
694		function mailchimpResponse (resp) {
695			if (resp.result === 'success') {
696			// Do stuff
697			}
698		}
699
700		// Hide video when on bottom page
701		/*
702		if ($('#background-video').length > 0) {
703			$('#block-bean-footnote').waypoint({
704				offset: '100%',
705				handler: function(direction) {
706					if (direction === 'down') {
707						$('.page').addClass('background');
708						video.pause();
709					} else {
710						$('.page').removeClass('background');
711						video.play();
712					}
713				}
714			});
715		}
716		*/
717
718		// if we are on touch device, give the .page class .background, because there is no video
719		/*
720		if ($('html.touch').length > 0) {
721			$('.page').addClass('background');
722		}
723		*/
724
725		// Front page specific
726		if ($('.front').length > 0) {
727
728			if ($('#video').length > 0) {
729				// Waypoints to handle video
730				$('.front #content-header').waypoint({
731					offset: function() {
732						return -$(this).height();
733					},
734					handler: function(direction) {
735						if (direction === 'up') {
736							world = 'energija';
737							setVideo(world, video);
738						}
739					}
740				});
741
742				$('.front .window').waypoint({
743					offset: '100%',
744					handler: function(direction) {
745						var category = $(this).data('world');
746						world = category.replace(/-/g, '_');
747						setVideo(world, video);
748					}
749				});
750			}
751
752			if( $( 'html' ).hasClass( 'no-touch' ) ) {
753
754				// Waypoints for front page interaction
755				$('.front .window').waypoint({
756					offset: 'bottom-in-view',
757					triggerOnce: true,
758					handler: function(direction) {
759						var _this = $(this);
760						_this.find('.title').animated();
761						_this.find('.subtitle, .buttons').animated({animation: 'fadeInUp'});
762					}
763				});
764
765			}
766		}
767
768		// News specific
769		if ($('.page-novice').length > 0 || $('.page-taxonomy').length > 0 || $('.page-node.node-type-banner-page').length || $('.front').length > 0) {
770			// Share flip action
771			$('.page-novice .content-body .views-row .buttons .share, .page-novice .content-body .views-row .buttons .share-close, .page-taxonomy .content-body .views-row .buttons .share, .page-taxonomy .content-body .views-row .buttons .share-close, .page-node.node-type-banner-page .titles-wrapper .buttons .share, .page-node.node-type-banner-page .titles-wrapper .buttons .share-close, body.front .titles-wrapper .buttons .share, .front .titles-wrapper .buttons .share-close, .share_front').on(clickAction, function() {
772				$(this).parent().parent().toggleClass('active');
773			});
774		}
775
776		if (($('.node-type-news').length > 0 || $('.node-type-basic-page').length > 0) && (!$('html.touch'))) {
777			// Waypoints for images in news content
778			$('.fancybox-insert-image').waypoint({
779				offset: 'bottom-in-view',
780				triggerOnce: true,
781				handler: function(direction) {
782					$(this).animated();
783				}
784			});
785		}
786
787		// Share options
788		$('.share-icon').on('click', function() {
789			var _this = $(this);
790			share(_this.data('share-type'), _this.parent().data('share-title'), _this.parent().data('share-url'));
791		});
792
793		// Set height to sidebar
794		/*
795		$('#content-body').resize(function() {
796			$('#sidebar').setSidebar();
797		});
798		*/
799
800		// Open and close sidebar
801		$('#sidebar-button').on(clickAction, function() {
802			$('body').toggleClass('sidebar-closed');
803		});
804
805		//Handle Slika s tekstom links if user is logged in
806
807		if ($("body").hasClass("logged-in")) {
808			$("[rel=slug]").each(function(){
809				var slug = $(this).attr("id");
810
811				if ($(this).parent().hasClass("node-image-with-text")) {
812					$(this).parent().find(".field-name-title-field").prepend('<pre>http://www.esvet.si'+window.location.pathname+'#'+slug+'</pre>');
813				} else if ($(this).parent().hasClass("node-columns-with-images")) {
814					$(this).before('<pre style="text-align:center;margin-bottom:20px;">http://www.esvet.si'+window.location.pathname+'#'+slug+'</pre>');
815				}
816			});
817		}
818
819		/*
820		$(".share-icon").on(clickAction, function(){
821			var type = $(this).data("shareType");
822			var title = document.title;
823			var path = location.href;
824
825			socialShare(type, title, path);
826		});
827
828		$("#block-bean-social li a.social").on(clickAction, function(e) {
829			var type = $(this).data("shareType");
830			var title = document.title;
831			var path = location.href;
832
833			if (type != "email") {
834				socialShare(type, title, path);
835				e.preventDefault();
836			}
837		});
838		*/
839
840
841		$("a[data-scroll-to]").on(clickAction, function(){
842			$('html, body').animate({
843				scrollTop: $("#block-system-main").offset().top
844			}, 2000);
845		});
846
847
848	});
849	// Document ready end
850
851	// Window load
852	$(window).load(function() {
853
854		// Open menu
855		$('#header .level-1.expanded.active-trail').click();
856
857		// Show title and subtitle on load
858		$('#content-header .title').animated();
859		$('#content-header .subtitle, #content-header .breadcrumb, #content-header .buttons').animated({animation: 'fadeInUp'});
860
861		// Show front page call to action
862		setTimeout(function() {
863			$('.front #content-header .action').animated({animation: 'fadeInUp'});
864		}, 500);
865
866	});
867	// Window load end
868
869	// Global variables
870	var transitionEnd = 'webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend';
871	var animationEnd  = 'webkitAnimationEnd oanimationend msAnimationEnd animationend';
872	var isAnimating = false;
873	var world = 'energija';
874	var video;
875
876	// Video ranges
877	var ranges = {
878		energija: {
879			start: 0,
880			end: 15
881		},
882		jedrska_energija: {
883			start: 16,
884			end: 24
885		},
886		obnovljivi_viri_energije: {
887			start: 25,
888			end: 32
889		},
890		vodna_energija: {
891			start: 33,
892			end: 40
893		},
894		termo_energije: {
895			start: 41,
896			end: 56
897		}
898	};
899
900	// Adjust elements height based on viewport height
901	$.fn.setHeight = function() {
902		$(this).height($(window).height());
903	};
904
905	// Create multicolumn slider
906	$.fn.columnSlider = function(options) {
907		var _this = $(this);
908
909		// Options
910		options = $.extend({
911			slidesPerWindow: 3,
912			appendPager: _this.parent()
913		}, options);
914
915
916		var slidesPerWindow = options.slidesPerWindow,
917				appendPager = options.appendPager,
918				column = _this.children(),
919				slides = column.length,
920				windows = Math.ceil(slides/slidesPerWindow);
921
922		// Stop function if not enough slides
923		if (slides <= slidesPerWindow) {
924			return false;
925		}
926
927
928
929		if (slides%slidesPerWindow > 0) {
930			while (slides%slidesPerWindow !== 0) {
931				slides++;
932			}
933		}
934
935		// Set width to column
936		column.css('width', 100/slides+'%');
937
938		// Set widht of the wrapper
939		_this.width((100*windows)+'%');
940
941		// Create pager for navigation
942		appendPager.append('<ul class="column-pager"></ul>').addClass('pager-inside');
943		for (var i = 0; i < windows; i++) {
944			appendPager.find('.column-pager').append('<li class="pager" data-pager="'+i+'"></li>');
945		}
946
947		// Bind click handler to pager
948		appendPager.find('.column-pager .pager').on('click', function() {
949			var _pager = $(this),
950					n = _pager.data('pager');
951
952			_pager.addClass('active').siblings().removeClass('active');
953
954			_this.transition({
955				x: '-' + (n * (100/windows)) + '%'
956			}, 800, 'easeInOutQuart');
957		}).first().addClass('active');
958	};
959
960	// Set timer for footer news
961	$.fn.newsTimer = function() {
962		var _this = $(this),
963				current = _this.addClass('current'),
964				next = _this.nextOrFirst('.views-row');
965
966		// If only one item then stop
967		if (_this.parent().find('.views-row').length < 2) {
968			_this.parent().addClass('no-timer');
969			return false;
970		}
971
972		current.find('.timer').addClass('load');
973
974		setInterval(function() {
975
976			current.addClass('out').removeClass('current').find('.image').one(transitionEnd, function() {
977				$(this).parent().removeClass('out');
978				current.find('.timer').removeClass('load');
979				next.find('.timer').addClass('load');
980			});
981
982			current = next.addClass('in current').find('.image').one(transitionEnd, function() {
983				$(this).parent().removeClass('in');
984			}).parent();
985
986			next = current.nextOrFirst('.views-row');
987
988		}, 10000);
989	};
990
991	// Get next or first element
992	$.fn.nextOrFirst = function(selector) {
993    var next = this.next(selector);
994    return (next.length) ? next : this.prevAll(selector).last();
995  };
996
997  // Make element visible and add animated class
998  $.fn.animated = function(options) {
999		options = $.extend({
1000      animation: 'bounceIn',
1001    }, options);
1002
1003		return this.css('visibility', 'visible').addClass('animated '+options.animation);
1004	};
1005
1006	// Open share window
1007	function share(type, title, path) {
1008
1009		// Set correct vars
1010		var width  = 505;
1011		var height = 370;
1012		var left   = ( window.innerWidth / 2 ) - ( width / 2 );
1013        var top    = ( window.innerHeight / 2 ) - ( height / 2 );
1014        var opts   = 'status=1' + ',width=' + width  + ',height=' + height + ',top=' + top + ',left=' + left;
1015        var url;
1016
1017		switch (type) {
1018			case 'facebook':
1019				url = 'https://www.facebook.com/sharer/sharer.php?u='+path;
1020				break;
1021			case 'twitter':
1022				url = 'https://twitter.com/share?text='+title+'&url='+path;
1023				break;
1024			case 'google':
1025				url = 'https://plus.google.com/share?url='+path;
1026				break;
1027			case 'linkedin':
1028				url = 'https://www.linkedin.com/shareArticle?mini=true&url='+path+'&title='+title+'&summary=&source==';
1029				break;
1030		}
1031
1032		// Open window using set vars
1033		window.open(url, type, opts);
1034
1035	}
1036
1037  // Resize sidebar height
1038	$.fn.setSidebar = function() {
1039		var _this = $(this),
1040				height = $('#content-body').height();
1041
1042		if (height > $('#sidebar').height()) {
1043			return _this.height(height+65);
1044		}
1045	};
1046
1047  // Set video range to play on
1048  function setVideo(t, v) {
1049		v.play(ranges[t].start);
1050  }
1051
1052  // Set chart color based on title
1053  function chartColor(category, image) {
1054	var name = category.toLowerCase();
1055	if (name.indexOf('jedr') !== -1) {
1056		if (image) {
1057			return 'jedrska-energija';
1058		} else {
1059		return '#5dbe87';
1060	}
1061	} else if (name.indexOf('naft') !== -1) {
1062		if (image) {
1063			return 'naftni-proizvodi';
1064		} else {
1065		return '#e33736';
1066	}
1067	} else if (name.indexOf('lign') !== -1) {
1068		if (image) {
1069			return 'lignit';
1070		} else {
1071		return '#e76653';
1072	}
1073	} else if (name.indexOf('zem') !== -1) {
1074		if (image) {
1075			return 'zemeljski-plin';
1076		} else {
1077		return '#ed8974';
1078	}
1079	} else if (name.indexOf('bio') !== -1) {
1080		if (image) {
1081			return 'biomasa';
1082		} else {
1083		return '#9fcd59';
1084	}
1085	} else if (name.indexOf('hidr') !== -1) {
1086		if (image) {
1087			return 'hidro-energija';
1088		} else {
1089			return '#40c3dd';
1090	}
1091	} else if (name.indexOf('son') !== -1) {
1092		if (image) {
1093			return 'soncna-energija';
1094		} else {
1095		return '#b1d57c';
1096	}
1097	} else if (name.indexOf('vetr') !== -1) {
1098		if (image) {
1099			return 'energija-vetra';
1100		} else {
1101			return '#b3e7f1';
1102	}
1103	} else if (name.indexOf('termo') !== -1) {
1104		if (image) {
1105		return 'termoenergija';
1106		} else {
1107		return '#f6987a';
1108	}
1109	} else {
1110		return '#fa9979';
1111		}
1112	}
1113
1114  // Initialize chart plugin
1115	$.fn.charts = function(options) {
1116		var _this = $(this),
1117		id = _this.data('chart-id'),
1118		title = _this.data('chart-title'),
1119		type = _this.data('chart-type');
1120
1121
1122		// Highcharts code
1123		if (type === 'column') {
1124			return _this.highcharts({
1125				data: {
1126					table: $('#chart-data-' + id + ' table')[0]
1127				},
1128				chart: {
1129					type: 'column',
1130					backgroundColor: '#f9f9f9',
1131					height: 450,
1132					style: {
1133						fontFamily: '"museo-sans", sans-serif'
1134					}
1135				},
1136				colors: ['#fa9979', '#1ee392', '#1ecee3', '#9ae458', '#e33939', '#f030f0', '#e8e651'],
1137				credits: {
1138					enabled: false
1139				},
1140				labels: {
1141					style: {
1142						color: '#231f20'
1143					},
1144					items: {
1145						html:true,
1146					}
1147				},
1148				legend: {
1149					enabled: true,
1150					useHTML: true,
1151					align: 'left',
1152					y: 43,
1153					verticalAlign: 'top',
1154					symbolPadding:0,
1155					symbolWidth:0,
1156					itemStyle: { }
1157				},
1158				plotOptions: {
1159					column: {
1160						borderWidth: 0
1161					}
1162				},
1163				title: {
1164					align: 'left',
1165					margin: 30,
1166					style: {
1167						color: '#231f20',
1168						fontWeight: 300,
1169						fontSize: '1.8em'
1170					},
1171					text: title
1172				},
1173				xAxis: {
1174					labels: {
1175						formatter: function () {
1176							return '<span class="chart-label-image chart-label-image-' + chartColor(this.value, true) + '"></span><span class="chart-label-text">' + this.value + '</span>';
1177						},
1178					style: {
1179						fontSize: '1.2em',
1180						display: 'block',
1181						height: '50px'
1182					},
1183						useHTML: true,
1184						y: 30
1185					},
1186					title: {
1187						rotation: 90
1188					}
1189				},
1190				yAxis: {
1191					gridLineColor: '#dddddd',
1192					gridLineWidth: 0.5,
1193					labels: {
1194						style: {
1195							fontSize: '1.2em'
1196						},
1197						formatter: function() {
1198							return parseFloat(this.value).toLocaleString();
1199						}
1200					},
1201					title: {
1202						text: ''
1203					}
1204				},
1205				tooltip: {
1206					formatter: function() {
1207						console.log(this.series.name);
1208						return '<b>'+ this.point.name +'</b><br/>' + title + ': <b>' + parseFloat(this.point.y).toLocaleString() + ' ' + this.series.name + '</b>';
1209					},
1210					style: {
1211						textAlign: 'center'
1212					},
1213					shadow: false,
1214					useHTML: true,
1215				}
1216			},
1217			function(chart) {
1218				$.each(chart.series[0].data, function(i, data) {
1219					data.update({
1220						color: chartColor(data.name)
1221					});
1222				});
1223				// Remove table
1224				$('#chart-data-'+_this.data('chart-id')).remove();
1225			});
1226		}
1227		else if (type === 'pie') {
1228
1229			return _this.highcharts({
1230				data: {
1231					table: $('#chart-data-' + id + ' table')[0]
1232				},
1233				chart: {
1234					type: 'pie',
1235					backgroundColor: '#f9f9f9',
1236					height: 450,
1237					style: {
1238						fontFamily: '"museo-sans", sans-serif'
1239					}
1240				},
1241				colors: ['#fa9979', '#1ee392', '#1ecee3', '#9ae458', '#e33939', '#f030f0', '#e8e651'],
1242				credits: {
1243					enabled: false
1244				},
1245				labels: {
1246					style: {
1247						color: '#231f20',
1248					}
1249				},
1250				legend: {
1251					enabled: false
1252				},
1253				plotOptions: {
1254					pie: {
1255						dataLabels: {
1256							connectorColor: '#dddddd',
1257							style: {
1258								fontSize: '1.2em'
1259							}
1260						}
1261					}
1262				},
1263				title: {
1264					align: 'left',
1265					margin: 30,
1266					style: {
1267						color: '#231f20',
1268						fontWeight: 300,
1269						fontSize: '1.8em'
1270					},
1271					text: title
1272				},
1273				tooltip: {
1274					formatter: function() {
1275						return '<b>'+ this.point.name +'</b><br/>' + title + ': <b>' + parseFloat(this.point.y).toLocaleString() + ' ' + this.series.name + '</b>';
1276					},
1277					style: {
1278						textAlign: 'center'
1279					},
1280					shadow: false
1281				}
1282			},
1283			function(chart) {
1284				$.each(chart.series[0].data, function(i, data) {
1285					data.update({
1286						//color: chartColor(data.name)
1287					});
1288				});
1289
1290				// Remove table
1291				$('#chart-data-'+_this.data('chart-id')).remove();
1292			});
1293		}
1294
1295	};
1296
1297	function animation() {
1298
1299		// Parameters
1300		this.data_dir_prefix = '.';
1301		this.images = [];
1302		this.ratio = 720 / 1280;
1303
1304		// Animation points
1305		this.data = [];
1306
1307		this.data['1_1'] = [];
1308		this.data['1_1'][1] = 1;
1309		this.data['1_1'][2] = 99;
1310
1311		this.data['1_2'] = [];
1312		this.data['1_2'][1] = 1;
1313		this.data['1_2'][2] = 99;
1314
1315		this.data[2] = [];
1316		this.data[2][1] = 1;
1317		this.data[2][2] = 8;
1318		this.data[2][3] = 18;
1319		this.data[2][4] = 24;
1320		this.data[2][5] = 32;
1321		this.data[2][6] = 40;
1322		this.data[2][7] = 50;
1323
1324		this.data[6] = [];
1325		this.data[6][1] = 1;
1326		this.data[6][2] = 15;
1327		this.data[6][3] = 25;
1328		this.data[6][4] = 40;
1329		this.data[6][5] = 45;
1330		this.data[6][6] = 50;
1331
1332		// System variables
1333		this.animationStep = [];
1334		this.animationStepTo = [];
1335		this.checklist = [];
1336		this.stop = 1;
1337
1338		this.init = function() {
1339			$('.animation-frame').each(function() {
1340				var id = $(this).attr('data-animation-id');
1341				$(this).attr('id', 'animacija-' + id);
1342				animation.animationStep[id] = 0;
1343				animation.animationStepTo[id] = 0;
1344			});
1345
1346			this.preload();
1347			this.scale();
1348
1349			return true;
1350		};
1351
1352		this.scale = function() {
1353			$('.animation-frame').each(function() {
1354				var id = $(this).attr('data-animation-id');
1355				$(this).css('height', (animation.ratio * $('#animacija-' + id).width()) + 'px');
1356			});
1357		};
1358
1359		this.preload = function() {
1360			// Add control elements to preloader
1361			this.controlElToPreload = [];
1362			this.controlElToPreload.push(this.data_dir_prefix + '/img/videobarstopprevbg.png');
1363			this.controlElToPreload.push(this.data_dir_prefix + '/img/videobarstopia.png');
1364			this.controlElToPreload.push(this.data_dir_prefix + '/img/videobarstopdot.png');
1365			this.controlElToPreload.push(this.data_dir_prefix + '/img/videobarstopactive.png');
1366			this.controlElToPreload.push(this.data_dir_prefix + '/img/videobarpbbg.png');
1367			this.controlElToPreload.push(this.data_dir_prefix + '/img/videobarpbactive.png');
1368
1369			// Add images of each animation to preloader and build controls
1370			$('.animation-frame').each(function() {
1371
1372				// Get animation ID
1373				var id = $(this).attr('data-animation-id');
1374
1375				// Add stop images to preloader
1376				animation.images[id] = [];
1377				for (stop = 1; stop < animation.data[id].length; stop++) {
1378					animation.controlElToPreload.push(animation.data_dir_prefix + '/data/anim' + id + '/a' + id + 'p' + addLeadingZero(stop) + '.jpg');
1379				}
1380
1381				// Add animation images to preloader and create animation elements
1382				var ulc = '';
1383				for (step = 1; step <= animation.data[id][animation.data[id].length - 1]; step++) {
1384					var img = animation.data_dir_prefix + '/data/anim' + id + '/a' + id + addLeadingZero(step) + '.jpg';
1385					animation.images[id].push(img);
1386					ulc += '<li style="background-image: url(\'' + img + '\');"></li>';
1387				}
1388				$('#animacija-' + id + ' .animation-holder').html(ulc);
1389
1390				// Build controls
1391				var i = 1;
1392				for (var key in animation.data[id]) {
1393					if (key !== 'remove') {
1394						var last_frame = animation.data[id][animation.data[id].length - 1];
1395						var bg_style = 'background-image: url(\'' + animation.data_dir_prefix + '/data/anim' + id + '/a' + id + 'p' + addLeadingZero(key) + '.jpg\')';
1396						var li_style = 'left: calc(' + ((animation.data[id][key] / last_frame) * 100) + '% - 12px)';
1397						if (i === 1) {
1398							li_style = 'left: 0';
1399						}
1400						var a_style = '';
1401						if(i === 1) { a_style = 'trail'; }else { a_style = ''; }
1402						$('#animacija-' + id + ' .animation-stops').append('<li class="animation-stop' + key + '" style="' + li_style + '"><a class="' + a_style + '" data-to-frame="' + animation.data[id][key] + '"><div class="stopbg"><div class="stopbg_bg" style="' + bg_style + '"></div></div><div class="stopdot"></div></a></li>');
1403						i++;
1404					}
1405				}
1406
1407			});
1408
1409			$(this.controlElToPreload).preloadImages(function() {
1410				$('.animation-frame .animation-controls-wrapper').fadeIn();
1411				for (var id in animation.images) {
1412					if (id !== 'remove') {
1413						$(animation.images[id]).preloadImages(function(id) {
1414							$('#animacija-' + id + ' .animation-holder').fadeIn();
1415							$('#animacija-' + id + ' .animation-overlay').fadeOut();
1416						}, id);
1417					}
1418				}
1419			});
1420		};
1421
1422		this.animate = function(id, step) {
1423			if (step > 0) {
1424				step--;
1425			}
1426			this.animationStepTo[id] = step;
1427			this.hideText(id);
1428			animation.interval = setInterval(function() {
1429				animation.displayStep(id);
1430			}, 100);
1431		};
1432
1433		this.displayStep = function(id) {
1434			if (this.animationStepTo[id] > this.animationStep[id]) {
1435				this.animationStep[id]++;
1436			} else if (this.animationStepTo[id] < this.animationStep[id]) {
1437				this.animationStep[id] = this.animationStepTo[id];
1438				clearInterval(animation.interval);
1439				this.displayText(id);
1440				$('#animacija-' + id + ' .animation-holder li').css('display', 'none');
1441			} else {
1442				clearInterval(animation.interval);
1443				this.displayText(id);
1444			}
1445			$('#animacija-' + id + ' .animation-holder li:nth-child(' + (this.animationStep[id] + 1) + ')').css('display', 'block');
1446			$('#animacija-' + id + ' .animation-progress').css('width', (((this.animationStep[id] + 1) / this.images[id].length) * 100) + '%');
1447			for (var key in this.data[id]) {
1448				if (key !== 'remove') {
1449					if(this.data[id][key] <= (this.animationStep[id] + 1)) { $('#animacija-' + id + ' .animation-stop' + key + ' a').addClass('trail'); }else { $('#animacija-' + id + ' .animation-stop' + key + ' a').removeClass('trail'); }
1450				}
1451			}
1452		};
1453
1454		this.displayText = function(id) {
1455			for (var key in this.data[id]) {
1456				if (key !== 'remove') {
1457					if (this.data[id][key] === (this.animationStep[id] + 1)) {
1458						this.stop = key;
1459						$('#animacija-' + id + ' .animation-text li').addClass('stop' + key).find('div.box').hide();
1460						$('#animacija-' + id + ' .animation-text li').css('cursor', ($('#animacija-' + id + ' .animation-text li.stop' + key + ' div.box.stop' + key).length) ? 'pointer' : 'default');
1461					}
1462				}
1463			}
1464		};
1465
1466		this.hideText = function(id) {
1467			$('#animacija-' + id + ' .animation-text li').alterClass('stop*').addClass('stop' + key);
1468		};
1469	}
1470
1471	/**
1472	* jQuery alterClass plugin
1473	*
1474	* Remove element classes with wildcard matching. Optionally add classes:
1475	*   $( '#foo' ).alterClass( 'foo-* bar-*', 'foobar' )
1476	*
1477	* Copyright (c) 2011 Pete Boere (the-echoplex.net)
1478	* Free under terms of the MIT license: http://www.opensource.org/licenses/mit-license.php
1479	*
1480	*/
1481	$.fn.alterClass = function(removals, additions) {
1482		var self = this;
1483		if (removals.indexOf('*') === -1) {
1484			// Use native jQuery methods if there is no wildcard matching
1485			self.removeClass(removals);
1486			return !additions ? self : self.addClass(additions);
1487		}
1488		var patt = new RegExp('\\s' + removals.replace(/\*/g, '[A-Za-z0-9-_]+').split(' ').join('\\s|\\s') + '\\s', 'g');
1489
1490		self.each(function(i, it) {
1491			var cn = ' ' + it.className + ' ';
1492			while (patt.test(cn)) {
1493				cn = cn.replace(patt, ' ');
1494			}
1495			it.className = $.trim(cn);
1496		});
1497			return !additions ? self : self.addClass(additions);
1498		};
1499
1500		// Adds leading zero to numbers below 10
1501		function addLeadingZero(val) {
1502		return (val < 10) ? '0' + val : val;
1503	}
1504
1505	// Callback function gets called after all images are preloaded
1506	$.fn.preloadImages = function(callback, id) {
1507		animation.checklist[id] = this.toArray();
1508		this.each(function() {
1509			$('<img>').attr({src: this}).load(function() {
1510				animation.checklist[id].remove($(this).attr('src'));
1511				if (animation.checklist[id].length === 0) {
1512					callback(id);
1513				}
1514			});
1515		});
1516	};
1517
1518	// Helper function, used below.
1519	// Usage: ['img1.jpg','img2.jpg'].remove('img1.jpg');
1520	Array.prototype.remove = function(element) {
1521		for (var i = 0; i < this.length; i++) {
1522			if (this[i] === element) {
1523				this.splice(i, 1);
1524			}
1525		}
1526	};
1527
1528})(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.