PageSourceSearch

https://dommuseum.at/items/frontend/js/desktop.js?ver=1790291476

js dommuseum.at collected 2026-09-24 23:11:36 UTC 69,200 bytes, 2,743 lines download raw bytes

1// sameh code
2
3$(window).on('load', function () {
4	// setTimeout(function () {
5	// document.getElementById('loadingCanvas').style.display = 'none';
6	//document.getElementById('container').style.visibility = 'visible';
7	// }, 600);
8	// document.getElementsByClassName('slide')[0].style.visibility = 'visible';
9
10});
11
12$(document).ready(function () {
13	addListeners();
14});
15
16function addListeners() {
17	// cookies
18	$('#warning_close').click(function () {
19		$('#cookie_warning').fadeOut();
20		var $this = $(this);
21		$.ajax({
22			type: "POST",
23			url: rootUrl + "Frontend/saveCookie",
24			data: {},
25			success: function (data) {
26				$('#cookie_warning').fadeOut();
27			}
28		});
29	});
30
31
32	/* OLD newsletter handler (provider: ajabiz) - commented out on provider switch to Listmonk
33$('.module_newsletter_send').click(function(e){
34		e.preventDefault();
35		var $this = $(this);
36		var firstname = $(this).parent().find('input[name="firstName"]').val();
37		var lastname = $(this).parent().find('input[name="lastName"]').val();
38		var email = $(this).parent().find('input[name="email"]').val();
39
40
41		if(email != '' && lastname != '' && firstname != '')
42		{
43			$.ajax({
44				type: "POST",
45				url: rootUrl+'Frontend/subscribeNL',
46				data: {firstName: firstname, lastName: lastname, email: email},
47				success: function (data) {
48					var json = $.parseJSON(data);
49
50					$this.parent().parent().find('.module_error').text(json.msg);
51
52				}
53			});
54		}
55		else
56		{
57			$this.parent().parent().find('.module_error').text('Bitte alle Felder ausfüllen!');
58		}
59
60	});
61
62
63
64	*/
65
66	// NEW newsletter handler (provider: Listmonk) - sends email + name to Frontend/subscribeNL, which calls the Listmonk API.
67	$('.module_newsletter_send').click(function(e){
68		e.preventDefault();
69		var $this   = $(this);
70		var $module = $this.closest('.module_newsletter');
71		var name    = $.trim($this.closest('form').find('input[name="name"]').val());
72		var email   = $.trim($this.closest('form').find('input[name="email"]').val());
73		var emailRe = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
74
75		// Both fields are required.
76		if(name === '' || email === ''){
77			$module.find('.module_error').text(typeof nl_fill_all_string !== 'undefined' ? nl_fill_all_string : 'Bitte alle Felder ausfüllen!');
78			return;
79		}
80
81		// The e-mail field must contain a valid e-mail address.
82		if(!emailRe.test(email)){
83			$module.find('.module_error').text(typeof nl_invalid_email_string !== 'undefined' ? nl_invalid_email_string : 'Bitte geben Sie eine gültige E-Mail-Adresse ein.');
84			return;
85		}
86
87		// The name field must be a name, not an e-mail address.
88		if(name.indexOf('@') !== -1){
89			$module.find('.module_error').text(typeof nl_invalid_name_string !== 'undefined' ? nl_invalid_name_string : 'Bitte geben Sie Ihren Namen ein (keine E-Mail-Adresse).');
90			return;
91		}
92
93		$.ajax({
94			type: "POST",
95			url: rootUrl+'Frontend/subscribeNL',
96			data: {name: name, email: email},
97			success: function (data) {
98				var json = $.parseJSON(data);
99				$module.find('.module_error').text(json.msg);
100			}
101		});
102	});
103
104
105	$('.module_contact_send').click(function () {
106		var mid = $(this).attr('mid');
107		if (!$('#contact_form_' + mid + ' .tnb_checkbox').is(':checked')) {
108			$('.module_error[mid="' + mid + '"]').text(tnb_required_string);
109			return;
110		}
111		$(this).hide();
112		var $this = $(this).parent();
113		var mid = $(this).attr('mid');
114		var contact_email = $this.attr('contact_email');
115		var contact_title = $this.attr('contact_title');
116		var email_subject = $this.attr('email_subject');
117		var contact_email_text = $this.attr('contact_email_text');
118
119		var data = [], obj;
120		$('#contact_form_'+mid+' input').each(function(){
121		    obj = {};
122
123		    if(this.name == "newsletter")
124		    {
125		    	if($(this).is(":checked"))
126		    	{
127		    		obj["name"] = this.name;
128				    obj["value"] = this.value;
129				    obj["class"] =  this.className.replace("module_contact_input ", "");
130				    data.push(obj);
131		    	}
132
133		    }
134		    else
135		    {
136		    	obj["name"] = this.name;
137			    obj["value"] = this.value;
138			    obj["class"] =  this.className.replace("module_contact_input ", "");
139			    data.push(obj);
140		    }
141
142		});
143
144
145		$('#contact_form_'+mid+' textarea').each(function(){
146		    obj = {};
147
148
149		    	obj["name"] = this.placeholder;
150			    obj["value"] = this.value;
151			    obj["class"] =  "";
152			    data.push(obj);
153
154
155		});
156
157
158	//	var data = $('#contact_form_'+mid).serializeArray();
159		data.push({name: 'contact_email', value: contact_email, class: ''});
160		data.push({name: 'contact_title', value: contact_title,  class: ''});
161		data.push({name: 'contact_email_text', value: contact_email_text,  class: ''});
162		data.push({name: 'email_subject', value: email_subject,  class: ''});
163
164
165
166		if($('#contact_form_'+mid).find('.module_contact_input[type="email"]').length > 0 && $('#contact_form_'+mid).find('.module_contact_input[type="email"]').val() != '')
167		{
168			
169
170			 KROT.getSolution().then((solution) => {
171				
172					var cs = JSON.stringify(solution);
173					
174					
175					$.ajax({
176					type: "POST",
177					url: rootUrl + "Frontend/sendContact",
178					data: {data:data, captcha_at_solution: cs},
179					success: function (data) {
180						var json = $.parseJSON(data);
181						if (json.success) {
182							$('.module_error[mid="'+mid+'"]').text(json.message);
183							$(this).show();
184	
185							var firstname ='';
186							var lastname = '';
187							var email = '';
188							var send_nl = false;
189	
190							$.each(json.data, function(index,i){
191	
192								if(i.name == 'newsletter' && i.value == 1)
193								{
194									send_nl = true;
195								}
196	
197								if(i.name == 'Vorname' || i.name == 'Firstname')
198								{
199									firstname = i.value;
200								}
201	
202								if(i.name == 'Nachname' || i.name == 'Lastname')
203								{
204									lastname = i.value;
205								}
206	
207								if(i.name == 'Email')
208								{
209									email = i.value;
210								}
211							});
212	
213	
214							if(send_nl)
215							{
216	
217	
218								$.ajax({
219									type: "POST",
220									url: rootUrl+'Frontend/subscribeNL',
221									data: {firstName: firstname, lastName: lastname, email: $('#contact_form_'+mid).find('.module_contact_input[type="email"]').val()},
222									success: function (data) {
223										var json = $.parseJSON(data);
224	
225										//$this.parent().parent().find('.module_error').text(json.msg);
226	
227									}
228								});
229	
230							}
231	
232						}
233					}
234				});
235		});
236			
237			
238			
239			
240		}
241		else
242		{
243			$('.module_error[mid="'+mid+'"]').text('Bitte Felder ausfüllen!');
244			$(this).show();
245		}
246	});
247
248
249
250	$('.module_tour_send').click(function () {
251		var $this = $(this);
252		var lang = $(this).attr('lang');
253		var sid = $(this).attr('sid');
254		if (!$('.signup_form_' + sid + ' .tnb_checkbox').is(':checked')) {
255			$('.signup_form_' + sid).parent().find('.module_error').text(tnb_required_string);
256			return;
257		}
258		var mid = $(this).attr('mid');
259		var limit = $(this).attr('limit');
260		var is_limited = $(this).attr('limited');
261		var max = $(this).attr('max_ppl');
262		var current_num = $(this).attr('num_ppl');
263		var persons = $('.signup_form_' + sid).find('input[name="tour_num_person"]').val();
264		var ppl = $('.signup_form_' + sid).find('input[name="tour_num_people"]').val();
265		var children = $('.signup_form_' + sid).find('input[name="tour_num_children"]').val();
266		var children_3 = $('.signup_form_' + sid).find('input[name="tour_num_children_3"]').val();
267		var children_7 = $('.signup_form_' + sid).find('input[name="tour_num_children_7"]').val();
268		var children_11 = $('.signup_form_' + sid).find('input[name="tour_num_children_11"]').val();
269
270		if(persons == '' || persons == undefined)
271		{
272			persons = 0;
273		}
274
275		if(ppl == '' || ppl == undefined)
276		{
277			ppl = 0;
278		}
279
280		if(children == '' || children == undefined)
281		{
282			children = 0;
283		}
284
285		if(children_3 == '' || children_3 == undefined)
286		{
287			children_3 = 0;
288		}
289
290		if(children_7 == '' || children_7 == undefined)
291		{
292			children_7 = 0;
293		}
294
295		if(children_11 == '' || children_11 == undefined)
296		{
297			children_11 = 0;
298		}
299		console.log(parseInt(persons)+" "+ parseInt(ppl)+" "+ parseInt(children)+" "+ parseInt(children_3) +" "+ parseInt(children_7)+" "+ parseInt(children_11))
300		var sum = parseInt(persons) + parseInt(ppl) + parseInt(children) + parseInt(children_3) + parseInt(children_7) + parseInt(children_11) ;
301		console.log(sum);
302		console.log(current_num)
303		if (sum > 0) {
304			if (sum > limit && max != 0) {
305				console.log('toomany ppl')
306				var text_msg = 'You can only register ' + limit + ' persons at once.';
307				if(lang == 0)
308				{
309					text_msg = 'Sie dürfen maximal ' + limit + ' Personen auf einmal anmelden.';
310				}
311
312				$('.signup_form_' + sid).parent().find('.module_error').text(text_msg);
313			} else if (sum + parseInt(current_num) > max && max != 0) {
314				console.log('limit reached')
315				var text_msg = 'Unfortunately this event has not enough space to accommodate all of you desired guests.';
316				if(lang == 0)
317				{
318					text_msg = 'Leider hat diese Veranstaltung nicht genügend Plätze für ihre gewünschte Buchung frei.';
319				}
320
321
322				$('.signup_form_' + sid).parent().find('.module_error').text(text_msg);
323			} else {
324				$(this).hide();
325				$('.signup_form_' + sid).parent().find('.module_error').text(please_wait_string).css({'color': 'red'});
326				$.ajax({
327					type: "POST",
328					url: rootUrl + "Frontend/saveSignup",
329					data: $('.signup_form_' + sid).serialize() + '&tour_id=' + mid,
330					success: function (data) {
331						var json = $.parseJSON(data);
332						if (json.success) {
333
334
335							if(json.nl == 1)
336							{
337								/*var first = json.data.name.substr(0,json.data.name.indexOf(' '));
338								var last =	json.data.name.substr(json.data.name.indexOf(' ')+1); */
339
340								var first = json.data.vorname;
341								var last =	json.data.nachname;
342								$.ajax({
343									type: "POST",
344									url: rootUrl+'Frontend/subscribeNL',
345									data: {firstName: first, lastName: last, email: json.data.email},
346									success: function (data) {
347										var json = $.parseJSON(data);
348
349										//$this.parent().parent().find('.module_error').text(json.msg);
350
351									}
352								});
353
354							}
355
356
357
358							$('.signup_form_' + sid).parent().find('.module_error').html(json.message).css({'color': 'red'});
359							//$('.signup_form_' + sid).parent().find('.remaining_places').text(json.remaining);
360							$('.signup_form_' + sid).parent().attr('max_ppl', json.remaining).css({'color': 'red'});
361							$('.signup_form_' + sid)[0].reset();
362							$('.signup_form_' + sid).remove();
363							if (!json.show) {
364								//	$('.signup_form_' + sid).parent().hide();
365								$('.signup_form_' + sid).parent().empty().text(json.full).css({'color': 'red'});
366							}
367						} else {
368							$('.signup_form_' + sid).parent().find('.module_error').html(json.message).css({'color': 'red'});
369							$this.show();
370						}
371
372					}
373				});
374			}
375		}
376
377
378	});
379
380
381	// main searching
382
383	$('#search_field').keypress(function (e) {
384		if (e.which == 13) {
385			var filter = $('#search_field').val();
386			var sf = $('#search_field');
387			var sfv = sf.val();
388			if (filter != "") {
389				sf.val(' ');
390				window.location.href = rootUrl + "search?text=" + filter;
391			}
392
393		}
394	});
395
396
397	// search icon click action
398	$('#search_icon').click(function () {
399		var sf = $('#search_field');
400		var sfv = sf.val();
401		var filter = sfv;
402		if (sfv == "" || sfv.trim() == "") {
403			sf.toggleClass("search_input_open");
404			if (sf.hasClass("search_input_open")) {
405				sf.focus();
406			} else {
407				sf.blur();
408			}
409		} else {
410			sf.val(' ');
411			window.location.href = rootUrl + "search?text=" + filter;
412
413		}
414	});
415
416
417		// search button click action
418		$('#search_button').click(function () {
419			var sf = $('#search_field');
420			var sfv = sf.val();
421			var filter = sfv;
422			sf.val(' ');
423			window.location.href = rootUrl + "search?text=" + filter;
424		});
425
426
427	$('#mobile_search_icon').click(function () {
428		var sf = $('#mobile_search_field');
429		var sfv = sf.val();
430		var filter = sfv;
431		if (sfv !== "" && sfv.trim() !== "") {
432			sf.val(' ');
433			window.location.href = rootUrl + "search?text=" + filter;
434		} else {
435			sf.focus();
436		}
437	});
438
439
440	// collection searching
441
442	$('#collection_search_field').keypress(function (e) {
443		if (e.which == 13) {
444			var filter = $('#collection_search_field').val();
445			var sf = $('#search_field');
446			var sfv = sf.val();
447			if (filter != "") {
448				sf.val(' ');
449				window.location.href = rootUrl + "collection_search?text=" + filter;
450			}
451
452		}
453	});
454
455
456	// collection search icon click action
457	$('#collection_search_icon').click(function () {
458		var sf = $('#collection_search_field');
459		var sfv = sf.val();
460		var filter = sfv;
461		if (sfv == "" || sfv.trim() == "") {
462			sf.toggleClass("search_input_open");
463			if (sf.hasClass("search_input_open")) {
464				sf.focus();
465			} else {
466				sf.blur();
467			}
468		} else {
469
470			window.location.href = rootUrl + "collection_search?text=" + filter;
471
472		}
473	});
474
475
476	// language
477	$('.lang_btn').click(function () {
478		if (!$(this).hasClass('noclick')) {
479			var lang = $(this).attr('lang');
480			window.location.href = rootUrl + "changeLanguage/" + lang;
481		}
482	});
483
484	// menu
485	$('.col_header').click(function () {
486		var this_sub_submenu = $(this).siblings(".sub_submenu_container");
487
488		var this_header = $(this)
489		var this_arrow = $(this).children(".sub_submenu_arrow");
490		if (this_sub_submenu.hasClass("sub_submenu_container_open")) {
491			this_sub_submenu.removeClass("sub_submenu_container_open");
492			this_header.removeClass("col_header_active");
493			this_arrow.removeClass("sub_submenu_arrow_open");
494		} else {
495			$(".sub_submenu_container").removeClass("sub_submenu_container_open");
496			$(".sub_submenu_arrow").removeClass("sub_submenu_arrow_open");
497			$(".col_header").removeClass("col_header_active");
498			this_sub_submenu.addClass("sub_submenu_container_open");
499			this_header.addClass("col_header_active");
500			this_arrow.addClass("sub_submenu_arrow_open");
501
502			// set focus on submenu
503			$(this).parent().find('.sub_submenu_container')[0].focus();
504			console.log($(this).parent().find('.sub_submenu_container')[0]);
505		}
506
507		// toggle aria pressed and aria label
508		var aria_pressed = $(this).attr('aria-pressed');
509		if (aria_pressed == "true") {
510			$(this).attr('aria-pressed', 'false');
511		} else {
512			$(this).attr('aria-pressed', 'true');
513		}
514	});
515
516
517	// small screen
518	$("#mobile_menu_background").hide();
519	if ($(window).width() < 1050) {
520		$(".slider_menu_item_text").hide();
521		$(".dot").css('display', 'inline-block');
522
523	};
524	$(window).resize(function () {
525		if ($(window).width() > 1050) {
526			// set_interval = setInterval(auto_slider_slide, 10000);
527			$("#mobile_menu_background").hide();
528			$("#nav_btn").removeClass('opend');
529			$("#overflow_bug_container").removeClass('overflow_bug_container');
530			$("#nav_left").removeClass("logo_black_important_mobile");
531			$("#logo_text").removeClass('mobile_black_important');
532			$("#logo_sep").removeClass('hr_mobile_black_important');
533			$(".nav_btn_hr").removeClass('hr_mobile_black_important');
534
535
536
537			$(".dot").hide();
538			$(".slider_menu_item_text").css('display', 'inline-block');
539		};
540		if ($(window).width() < 1050) {
541			// set_interval = setInterval(auto_slider_slide, 10000);
542			$("#logo_text , .menu_item , .lang_btn,#search_container").removeClass("black_important");
543			$("#nav_left").removeClass("logo_black_important");
544			$(".sub_menu_background").hide();
545			$(".dot").css('display', 'inline-block');
546			$(".slider_menu_item_text").hide();
547			$("#logo_sep,#lang_sep").removeClass('hr_black_important');
548			$(".nav_btn_hr").removeClass('hr_black_important');
549			$(".menu_item").removeClass("active");
550			social_menu_btns_ids.forEach(function (item) {
551				$("#" + item + "_social_item").removeClass("social_item_" + item +
552					"_black_important");
553			});
554
555		};
556	});
557
558
559	// when click on the mobile menu btn
560	var slide_index = 1;
561	$("#nav_btn").click(function toggle() {
562		// return;
563		// slide_index++
564		// if (slide_index % 2 != 0) {
565		// 	clearInterval(set_interval);
566
567		// } else {
568		// 	set_interval = setInterval(auto_slider_slide, 10000);
569		// }
570
571		$('body').toggleClass('overlayMenuOpen');
572		
573		// toggle aria pressed
574		var aria_pressed = $(this).attr('aria-pressed');
575		if (aria_pressed == "true") {
576			$(this).attr('aria-pressed', 'false');
577		} else {
578			$(this).attr('aria-pressed', 'true');
579		}
580
581		$(this).toggleClass('opend');
582		$("#overflow_bug_container").toggleClass('overflow_bug_container');
583		$("#mobile_menu_background").slideToggle();
584		$("#nav_left").toggleClass("logo_black_important_mobile");
585		$("#logo_text").toggleClass("logo_black_important_mobile");
586		$("#logo_sep").toggleClass("hr_mobile_black_important");
587		$(".nav_btn_hr").toggleClass("hr_mobile_black_important");
588
589		// if opened, focus on #main_menu_mobile
590		if ($(this).hasClass('opend')) {
591			$('#main_menu_mobile').focus();
592		}
593
594		// scroll to the top of #mobile_menu_background
595		$('#mobile_menu_background').scrollTop(0);
596	});
597
598
599
600
601
602
603	var colors = eval(theme_colors);
604
605	/*var slideIndex = 1;
606	showSlides(slideIndex);
607
608	// Next/previous controls
609	function plusSlides(n) {
610		showSlides(slideIndex = n + 1);
611	}
612	// menu tap select
613	function menuSelect(n) {
614		showSlides(slideIndex = n);
615	}
616
617	// auto slider
618	function auto_slider_slide() {
619		plusSlides(1);
620	}
621	var set_interval = setInterval(auto_slider_slide, 10000);
622	// clearInterval(set_interval);
623
624	$(".menu_item").click(function () {
625		clearInterval(set_interval);
626	});
627	$(".slider_menu_item").click(function () {
628		clearInterval(set_interval);
629	});
630	$(".sub_menu_close").click(function () {
631		set_interval = setInterval(auto_slider_slide, 10000);
632	});
633*/
634	function showSlides(n) {
635		return;
636		// $("#loadingCanvasContainer").removeClass("canvas_animation").addClass("canvas_animation");
637
638
639		var i;
640		var slides = document.getElementsByClassName("slide");
641		var slides_menu = document.getElementsByClassName("slider_menu_item");
642
643		var change_color = document.getElementsByClassName("change_color");
644		var logo_change_color = document.getElementsByClassName("logo_change_color");
645		var hr_change_color = document.getElementsByClassName("hr_change_color");
646		var fb_icon_change_color = document.getElementsByClassName("fb_icon_change_color");
647		var t_icon_change_color = document.getElementsByClassName("t_icon_change_color");
648		var yt_icon_change_color = document.getElementsByClassName("yt_icon_change_color");
649		var insta_icon_change_color = document.getElementsByClassName("insta_icon_change_color");
650
651		var arrow_change_color = document.getElementsByClassName("arrow_change_color");
652
653
654
655		if (n > slides.length) {
656			slideIndex = 1
657		}
658		if (n < 1) {
659			slideIndex = slides.length
660		}
661		for (i = 0; i < slides.length; i++) {
662
663
664			slides_menu[i].style.border = "none";
665			dot = $(slides_menu[i]).find(".dot");
666			$(dot).removeClass("hr_" + colors[i]);
667		}
668
669
670		next = slides[slideIndex]
671		current = slides[slideIndex - 1];
672		prev = slides[slideIndex - 2];
673		last_slide = slides[slides.length - 1]
674
675		if (slideIndex == 1) {
676			next = slides[slideIndex]
677			current = slides[slideIndex - 1]
678			prev = slides[slides.length - 1]
679		}
680		if (slideIndex == slides.length) {
681			next = slides[0]
682			current = slides[slideIndex - 1]
683			prev = slides[slideIndex - 2]
684		}
685		// current.style.display = "block";
686		var slider_exist = $("#slider_container").length;
687		if (slider_exist > 0) {
688			current.classList.remove("next_slide", "prev_slide");
689			current.classList.add("current_slide");
690			prev.classList.remove("next_slide", "current_slide");
691			prev.classList.add("prev_slide");
692			next.classList.remove("current_slide", "prev_slide");
693			next.classList.add("next_slide");
694
695
696
697
698
699
700			if ($(window).width() > 1050) {
701				slides_menu[slideIndex - 1].style.borderBottom = "2px solid";
702			} else {
703				dot = $(slides_menu[slideIndex - 1]).find(".dot");
704				$(dot).addClass("hr_" + colors[slideIndex - 1]);
705			};
706			$(window).resize(function () {
707				if ($(window).width() > 1050) {
708					slides_menu[slideIndex - 1].style.borderBottom = "2px solid";
709				} else {
710					dot = $(slides_menu[slideIndex - 1]).find(".dot");
711					$(dot).addClass("hr_" + colors[slideIndex - 1]);
712				};
713			});
714
715			//   changing the colors control
716			// text
717			/* REMOVED color change
718			for (j = 0; j < change_color.length; j++) {
719				for (i = 0; i < colors.length; i++) {
720					change_color[j].classList.remove(colors[i]);
721				}
722				change_color[j].classList.add(colors[slideIndex - 1]);
723			}
724			// logo
725			for (j = 0; j < logo_change_color.length; j++) {
726				for (i = 0; i < colors.length; i++) {
727					logo_change_color[j].classList.remove("logo_" + colors[i]);
728				}
729				logo_change_color[j].classList.add("logo_" + colors[slideIndex - 1]);
730			}
731			// hr
732			for (j = 0; j < hr_change_color.length; j++) {
733				for (i = 0; i < colors.length; i++) {
734					hr_change_color[j].classList.remove("hr_" + colors[i]);
735				}
736				hr_change_color[j].classList.add("hr_" + colors[slideIndex - 1]);
737			}
738			//icons
739			// TODO make the code smaller with a for loop throw the icon names
740			for (j = 0; j < fb_icon_change_color.length; j++) {
741				for (i = 0; i < colors.length; i++) {
742					fb_icon_change_color[j].classList.remove("social_item_fb_" + colors[i]);
743				}
744				fb_icon_change_color[j].classList.add("social_item_fb_" + colors[slideIndex - 1]);
745			}
746			for (j = 0; j < t_icon_change_color.length; j++) {
747				for (i = 0; i < colors.length; i++) {
748					t_icon_change_color[j].classList.remove("social_item_t_" + colors[i]);
749				}
750				t_icon_change_color[j].classList.add("social_item_t_" + colors[slideIndex - 1]);
751			}
752			for (j = 0; j < insta_icon_change_color.length; j++) {
753				for (i = 0; i < colors.length; i++) {
754					insta_icon_change_color[j].classList.remove("social_item_insta_" + colors[i]);
755				}
756				insta_icon_change_color[j].classList.add("social_item_insta_" + colors[slideIndex - 1]);
757			}
758
759			for (j = 0; j < yt_icon_change_color.length; j++) {
760				for (i = 0; i < colors.length; i++) {
761					yt_icon_change_color[j].classList.remove("social_item_yt_" + colors[i]);
762				}
763				yt_icon_change_color[j].classList.add("social_item_yt_" + colors[slideIndex - 1]);
764			}
765
766*/
767
768
769			// $(".prev").click(function () {
770			// 	plusSlides(-1);
771
772			// })
773			// $(".next").click(function () {
774			// 	plusSlides(1);
775			// })
776
777			// !safari 9 let problem
778
779			var slider_menu_item = document.getElementsByClassName("slider_menu_item");
780			// for (let index = 0; index < slides.length; index++) {
781			// 	slider_menu_item[index].addEventListener('click', function () {
782			// 		menuSelect(index+1);
783			// 	})
784			// }
785
786			slider_menu_item[0].addEventListener('click', function () {
787				menuSelect(0 + 1);
788			});
789
790
791
792			slider_menu_item[1].addEventListener('click', function () {
793				menuSelect(1 + 1);
794			});
795
796
797
798			slider_menu_item[2].addEventListener('click', function () {
799				menuSelect(2 + 1);
800			});
801
802			slider_menu_item[3].addEventListener('click', function () {
803				menuSelect(3 + 1);
804			});
805
806			slider_menu_item[4].addEventListener('click', function () {
807				menuSelect(4 + 1);
808			});
809		}
810
811	}
812
813	// tags link pre filter for sammlungen
814	var tags_exist = $("#tags_container").length;
815	var tags_array = [];
816	if (tags_exist > 0) {
817
818		var use_cookies = getCookie("cookie_warning");
819
820		var current_url = window.location.href;
821		current_tag = current_url.split("/");
822		current_tag = current_tag[current_tag.length - 1];
823
824		current_tag = current_tag.replace(/%C3%B6|%C3%BC|%C3%A4|%C3%84|%C3%96|%C3%9C|%20/g, "");
825		current_tag = current_tag.toLowerCase().replace(/[^a-zA-Z0-9]+/g, "");
826
827		var tags = $(".tag")
828		delete tags.selector;
829		Object.keys(tags).forEach(function (item) {
830			var tag = tags[item];
831
832			var pre_tad_id = tag.id
833			var tag_count = $("." + pre_tad_id).length
834
835
836
837			tag_text = tag.innerHTML;
838			if (tag_text) {
839				tag_text = tag_text.toLowerCase().replace(/[^a-zA-Z0-9]+/g, "");
840				tag_text = tag_text.replace(/öüäÄÖÜ/g, "");
841			}
842
843			if (tag_text == current_tag) {
844
845				setTimeout(function(){
846
847					if(!$("#" + pre_tad_id).hasClass('active'))
848					{
849						$("#" + pre_tad_id).click();
850					}
851			    },10);
852
853				/*$("#" + pre_tad_id).addClass("active");
854				tags_array.push(pre_tad_id);
855			*/
856				/*$(".collection_item").fadeOut(200);
857				var collection_items = $(".collection_item");
858				delete collection_items.selector;
859				Object.keys(collection_items).forEach(function (item) {
860					var collection_item = collection_items[item];
861					tags_array.forEach(function tag_class(tag_class) {
862						if ($(collection_item).hasClass(tag_class)) {
863							$(collection_item).fadeIn(200)
864						}
865					});
866				});*/
867			}
868			tag.innerHTML += "<span class='tag_count'>(" + tag_count + ")</span>";
869		});
870
871
872
873		// tags filter for sammlungen
874		$(".tag").click(function (e) {
875
876			// console.log(1);
877			if ($(this).hasClass("active")) {
878				$(this).removeClass("active");
879				var tag_id = $(this).attr('id');
880				var tag_remove = tags_array.indexOf(tag_id);
881				if (tag_remove > -1) {
882					tags_array.splice(tag_remove, 1);
883				}
884				if (tags_array === undefined || tags_array.length > 0) {
885					$(".collection_item").hide();
886					var collection_items = $(".collection_item");
887					delete collection_items.selector;
888					var tag_classes = "";
889
890					tags_array.forEach(function tag_class(tag_class) {
891						if (tag_class == tags_array.slice(-1)[0]) {
892							tag_classes += "." + tag_class
893						} else {
894							tag_classes += "." + tag_class
895						}
896					});
897
898					Object.keys(collection_items).forEach(function (item) {
899						var collection_item = collection_items[item];
900						tags_array.forEach(function tag_class(tag_class) {
901							if ($(collection_item).hasClass(tag_class)) {
902								$(collection_item).fadeIn(10)
903							}
904						});
905					});
906				} else {
907					$(".collection_item").fadeIn(200);
908				}
909				if (use_cookies == 1) {
910
911					document.cookie = "active_tags = " + tags_array + "; path=/;";
912				}
913			} else {
914				// $(this).addClass("active");
915				activate_tag($(this));
916			}
917		})
918
919		// remember where I was .. reactivate tags
920
921		active_tags = getCookie('active_tags');
922		active_tags = active_tags.split(",");
923
924		remember_activate_tag(active_tags);
925
926
927		// mobile tags
928		$("#collection_tags_mobile_btn").click(function() {
929			$("#collection_tags_mobile").toggleClass("active");
930		})
931
932
933
934
935	}; //end if tags exist
936
937	function activate_tag(thiss) {
938		thiss.addClass("active");
939		var tag_id = thiss.attr('id');
940		tags_array.push(tag_id);
941		$(".collection_item").fadeOut(200);
942		var collection_items = $(".collection_item");
943		delete collection_items.selector;
944		var tag_classes = "";
945		tags_array.forEach(function tag_class(tag_class) {
946			if (tag_class == tags_array.slice(-1)[0]) {
947				tag_classes += "." + tag_class
948			} else {
949				tag_classes += "." + tag_class
950			}
951		});
952
953		Object.keys(collection_items).forEach(function (item) {
954			var collection_item = collection_items[item];
955			tags_array.forEach(function tag_class(tag_class) {
956				if ($(collection_item).hasClass(tag_class)) {
957					$(collection_item).fadeIn(200)
958				}
959			});
960		});
961		if (use_cookies == 1) {
962
963			document.cookie = "active_tags = " + tags_array + ";path=/;";
964		}
965	}
966
967
968	function remember_activate_tag(tags_array) {
969
970		$(".collection_item").fadeOut(200);
971		var collection_items = $(".collection_item");
972		delete collection_items.selector;
973		var tag_classes = "";
974		tags_array.forEach(function tag_class(tag_class) {
975			$("#" + tag_class).addClass("active");
976
977			if (tag_class == tags_array.slice(-1)[0]) {
978				tag_classes += "." + tag_class
979			} else {
980				tag_classes += "." + tag_class
981			}
982		});
983
984		Object.keys(collection_items).forEach(function (item) {
985			var collection_item = collection_items[item];
986			tags_array.forEach(function tag_class(tag_class) {
987				if ($(collection_item).hasClass(tag_class)) {
988					$(collection_item).fadeIn(200)
989				}
990			});
991		});
992
993		if (use_cookies == 1) {
994
995			document.cookie = "active_tags = " + tags_array + ";path=/;";
996		}
997	}
998
999
1000	function getCookie(cname) {
1001		var name = cname + "=";
1002		var decodedCookie = decodeURIComponent(document.cookie);
1003		var ca = decodedCookie.split(';');
1004		for (var i = 0; i < ca.length; i++) {
1005			var c = ca[i];
1006			while (c.charAt(0) == ' ') {
1007				c = c.substring(1);
1008			}
1009			if (c.indexOf(name) == 0) {
1010				return c.substring(name.length, c.length);
1011			}
1012		}
1013		return "";
1014	}
1015
1016
1017
1018
1019
1020
1021	// tags pre filter for calendar
1022	var calendar_tags_exist = $("#calendar_tags_container").length;
1023	var calendar_tags_array = [];
1024	if (calendar_tags_exist > 0) {
1025		var current_url = window.location.href;
1026		current_tag = current_url.split("/");
1027		current_tag = current_tag[current_tag.length - 1];
1028
1029		current_tag = current_tag.replace(/%C3%B6|%C3%BC|%C3%A4|%C3%84|%C3%96|%C3%9C|%20/g, "");
1030		current_tag = current_tag.toLowerCase().replace(/[^a-zA-Z0-9]+/g, "");
1031
1032		var tags = $(".tag")
1033		delete tags.selector;
1034		Object.keys(tags).forEach(function (item) {
1035			var tag = tags[item];
1036
1037			var pre_tag_id = tag.id
1038			tag_text = tag.innerHTML;
1039			if (tag_text) {
1040				tag_text = tag_text.toLowerCase().replace(/[^a-zA-Z0-9]+/g, "");
1041				tag_text = tag_text.replace(/öüäÄÖÜ/g, "");
1042			}
1043
1044			if (tag_text == current_tag) {
1045
1046
1047				$("#" + pre_tag_id).addClass("active");
1048				calendar_tags_array.push(pre_tag_id);
1049
1050				$(".category_list_item").fadeOut(200);
1051				$(".calendar_page_month_sep").fadeOut(200);
1052				$(".calendar_page_hr_sep").fadeOut(200);
1053
1054
1055				var category_list_items = $(".category_list_item");
1056				var calendar_page_month_seps = $(".calendar_page_month_sep");
1057				var calendar_page_hr_seps = $(".calendar_page_hr_sep");
1058
1059				delete category_list_items.selector;
1060				delete calendar_page_month_seps.selector;
1061				delete calendar_page_hr_seps.selector;
1062
1063				Object.keys(category_list_items).forEach(function (item) {
1064					var category_list_item = category_list_items[item];
1065					calendar_tags_array.forEach(function tag_class(calendar_tag_class) {
1066						if ($(category_list_item).hasClass(calendar_tag_class)) {
1067							$(category_list_item).fadeIn(200)
1068						}
1069					});
1070				});
1071
1072				Object.keys(calendar_page_month_seps).forEach(function (item) {
1073					var calendar_page_month_sep = calendar_page_month_seps[item];
1074					calendar_tags_array.forEach(function tag_class(calendar_tag_class) {
1075						if ($(calendar_page_month_sep).hasClass(calendar_tag_class)) {
1076							$(calendar_page_month_sep).fadeIn(200)
1077						}
1078					});
1079				});
1080
1081				Object.keys(calendar_page_hr_seps).forEach(function (item) {
1082					var calendar_page_hr_sep = calendar_page_hr_seps[item];
1083					calendar_tags_array.forEach(function tag_class(calendar_tag_class) {
1084						if ($(calendar_page_hr_sep).hasClass(calendar_tag_class)) {
1085							$(calendar_page_hr_sep).fadeIn(200)
1086						}
1087					});
1088				});
1089
1090
1091
1092			}
1093		});
1094	};
1095	// calendar switsh
1096	if ($("#calendar")) {
1097		$("#calendar").fadeOut();
1098		$("#calendar_switch").click(function () {
1099			$(this).toggleClass("active")
1100			$("#calendar").fadeToggle();
1101			$("#list_items_holder").fadeToggle();
1102			$("#calendar_tags_container").fadeToggle();
1103		});
1104
1105	}
1106
1107
1108	// tags filter for calendar
1109
1110	if (calendar_tags_exist > 0) {
1111		var calendar_tags_array = [];
1112		$(".tag").click(function () {
1113			if ($(this).hasClass("active")) {
1114				$(this).removeClass("active");
1115				var calendar_tag_id = $(this).attr('id');
1116				var calendar_tag_remove = calendar_tags_array.indexOf(calendar_tag_id);
1117				if (calendar_tag_remove > -1) {
1118					calendar_tags_array.splice(calendar_tag_remove, 1);
1119				}
1120				if (calendar_tags_array === undefined || calendar_tags_array.length > 0) {
1121
1122					$(".category_list_item").fadeOut(200);
1123					$(".calendar_page_month_sep").fadeOut(200);
1124					$(".calendar_page_hr_sep").fadeOut(200);
1125
1126
1127					var category_list_items = $(".category_list_item");
1128					var calendar_page_month_seps = $(".calendar_page_month_sep");
1129					var calendar_page_hr_seps = $(".calendar_page_hr_sep");
1130
1131
1132
1133					delete category_list_items.selector;
1134					delete calendar_page_month_seps.selector;
1135					delete calendar_page_hr_seps.selector;
1136
1137					var calendar_tag_classes = "";
1138					calendar_tags_array.forEach(function tag_class(calendar_tag_class) {
1139
1140						calendar_tag_classes += "." + calendar_tag_class
1141
1142					});
1143
1144					Object.keys(category_list_items).forEach(function (item) {
1145						var category_list_item = category_list_items[item];
1146						calendar_tags_array.forEach(function calendar_tag_class(calendar_tag_class) {
1147							if ($(category_list_item).hasClass(calendar_tag_class)) {
1148								$(category_list_item).fadeIn(200)
1149							}
1150						});
1151
1152					});
1153
1154					Object.keys(calendar_page_month_seps).forEach(function (item) {
1155						var calendar_page_month_sep = calendar_page_month_seps[item];
1156						calendar_tags_array.forEach(function calendar_tag_class(calendar_tag_class) {
1157							if ($(calendar_page_month_sep).hasClass(calendar_tag_class)) {
1158								$(calendar_page_month_sep).fadeIn(200)
1159							}
1160						});
1161					});
1162					Object.keys(calendar_page_hr_seps).forEach(function (item) {
1163						var calendar_page_hr_sep = calendar_page_hr_seps[item];
1164						calendar_tags_array.forEach(function calendar_tag_class(calendar_tag_class) {
1165							if ($(calendar_page_hr_sep).hasClass(calendar_tag_class)) {
1166								$(calendar_page_hr_sep).fadeIn(200)
1167							}
1168						});
1169					});
1170
1171				} else {
1172					$(".category_list_item").fadeIn(200);
1173					$(".calendar_page_month_sep").fadeIn(200);
1174					$(".calendar_page_hr_sep").fadeIn(200);
1175				}
1176			} else {
1177				$(this).addClass("active");
1178				var calendar_tag_id = $(this).attr('id');
1179				calendar_tags_array.push(calendar_tag_id);
1180
1181
1182				$(".category_list_item").fadeOut(200);
1183				$(".calendar_page_month_sep").fadeOut(200);
1184				$(".calendar_page_hr_sep").fadeOut(200);
1185
1186
1187
1188				var category_list_items = $(".category_list_item");
1189				var calendar_page_month_seps = $(".calendar_page_month_sep");
1190				var calendar_page_hr_seps = $(".calendar_page_hr_sep");
1191
1192
1193
1194				delete category_list_items.selector;
1195				delete calendar_page_month_seps.selector;
1196				delete calendar_page_hr_seps.selector;
1197
1198				var calendar_tag_classes = "";
1199
1200				calendar_tags_array.forEach(function tag_class(calendar_tag_class) {
1201					calendar_tag_classes += "." + calendar_tag_class
1202
1203				});
1204
1205				Object.keys(category_list_items).forEach(function (item) {
1206					var category_list_item = category_list_items[item];
1207					calendar_tags_array.forEach(function calendar_tag_class(calendar_tag_class) {
1208						if ($(category_list_item).hasClass(calendar_tag_class)) {
1209							$(category_list_item).fadeIn(200)
1210						}
1211					});
1212
1213				});
1214
1215				Object.keys(calendar_page_month_seps).forEach(function (item) {
1216					var calendar_page_month_sep = calendar_page_month_seps[item];
1217					calendar_tags_array.forEach(function calendar_tag_class(calendar_tag_class) {
1218						if ($(calendar_page_month_sep).hasClass(calendar_tag_class)) {
1219							$(calendar_page_month_sep).fadeIn(200)
1220						}
1221					});
1222				});
1223				Object.keys(calendar_page_hr_seps).forEach(function (item) {
1224					var calendar_page_hr_sep = calendar_page_hr_seps[item];
1225					calendar_tags_array.forEach(function calendar_tag_class(calendar_tag_class) {
1226						if ($(calendar_page_hr_sep).hasClass(calendar_tag_class)) {
1227							$(calendar_page_hr_sep).fadeIn(200)
1228						}
1229					});
1230				});
1231
1232
1233			}
1234		})
1235	};
1236}
1237
1238
1239
1240
1241// end sameh code
1242
1243var positions = [];
1244var highest_z = 1;
1245var fadeTime = 5000; //ms
1246var hidden_images = [];
1247
1248var mainTimer;
1249var detailTimer;
1250
1251// x = left, y = Top, z = Font size, w = width, h = height
1252var new_positions = [{
1253		x: 1100,
1254		y: 710,
1255		z: 46,
1256		w: 200,
1257		h: 200
1258	},
1259	{
1260		x: 20,
1261		y: 70,
1262		z: 20,
1263		w: 160,
1264		h: 200
1265	},
1266	{
1267		x: 530,
1268		y: 90,
1269		z: 26,
1270		w: 180,
1271		h: 210
1272	},
1273	{
1274		x: 1080,
1275		y: 100,
1276		z: 34,
1277		w: 200,
1278		h: 230
1279	},
1280	{
1281		x: 1650,
1282		y: 113,
1283		z: 26,
1284		w: 180,
1285		h: 210
1286	},
1287	{
1288		x: 2050,
1289		y: 100,
1290		z: 20,
1291		w: 160,
1292		h: 200
1293	},
1294	{
1295		x: 10,
1296		y: 775,
1297		z: 26,
1298		w: 160,
1299		h: 200
1300	},
1301	{
1302		x: 410,
1303		y: 732,
1304		z: 34,
1305		w: 200,
1306		h: 230
1307	},
1308	{
1309		x: 1570,
1310		y: 640,
1311		z: 34,
1312		w: 200,
1313		h: 230
1314	},
1315	{
1316		x: 2050,
1317		y: 690,
1318		z: 20,
1319		w: 170,
1320		h: 200
1321	},
1322	{
1323		x: 125,
1324		y: 1320,
1325		z: 24,
1326		w: 175,
1327		h: 205
1328	},
1329	{
1330		x: 630,
1331		y: 1370,
1332		z: 34,
1333		w: 225,
1334		h: 255
1335	},
1336	{
1337		x: 1260,
1338		y: 1400,
1339		z: 34,
1340		w: 185,
1341		h: 215
1342	},
1343	{
1344		x: 1930,
1345		y: 1178,
1346		z: 24,
1347		w: 175,
1348		h: 205
1349	},
1350	{
1351		x: 2530,
1352		y: 1578,
1353		z: 26,
1354		w: 175,
1355		h: 205
1356	},
1357
1358];
1359
1360
1361// $(document).ready(function()
1362// {
1363// 	generatePositions();
1364// 	addListeners();
1365// 	igniteDrag();
1366
1367// });
1368
1369/*
1370(function (global) {
1371
1372	if (typeof (global) === "undefined") {
1373		throw new Error("window is undefined");
1374	}
1375
1376	var _hash = "!";
1377	var noBackPlease = function () {
1378		global.location.href += "#";
1379
1380
1381		global.setTimeout(function () {
1382			global.location.href += "!";
1383		}, 50);
1384	};
1385
1386	global.onhashchange = function () {
1387		if (global.location.hash !== _hash) {
1388			global.location.hash = _hash;
1389		}
1390	};
1391
1392	global.onload = function () {
1393		noBackPlease();
1394
1395		// disables backspace on page except on input fields and textarea..
1396		document.body.onkeydown = function (e) {
1397			var elm = e.target.nodeName.toLowerCase();
1398			if (e.which === 8 && (elm !== 'input' && elm !== 'textarea')) {
1399				e.preventDefault();
1400			}
1401			// stopping event bubbling up the DOM tree..
1402			e.stopPropagation();
1403		};
1404	}
1405
1406})(window);*/
1407
1408
1409function tutorial(type) {
1410	if (type == "main") {
1411		mainTimer = setTimeout(function () {
1412
1413
1414			$('.tutorial_box.main').fadeIn();
1415
1416		}, fadeTime);
1417	} else {
1418
1419	}
1420}
1421
1422function ignitePackery() {
1423	/*$('#top10_inner').packery({
1424	  percentPosition: true
1425	});*/
1426}
1427
1428// Close the dropdown if the user clicks outside of it
1429$(window).on('click', function (event) {
1430	//if (!event.target.matches('.dropbtn') && !event.target.matches('.infobtn')) {
1431	if(!$(event.target).is('.dropbtn') && !$(event.target).is('.infobtn')){
1432		var dropdowns = $("dropdown-content");
1433		var i;
1434		for (i = 0; i < dropdowns.length; i++) {
1435			var openDropdown = dropdowns[i];
1436			if (openDropdown.classList.contains('show')) {
1437				openDropdown.classList.remove('show');
1438			}
1439		}
1440	}
1441});
1442
1443
1444
1445$(window).on('load', function () {
1446
1447	$('#preload').fadeOut();
1448	tutorial('main');
1449	var w = window.innerWidth;
1450	var h = window.innerHeight;
1451
1452	var nw = (w / 2) - 1250;
1453	var nh = (h / 2) - 900;
1454	$('#canvas').css({
1455		top: nh + "px",
1456		left: nw + "px"
1457	});
1458
1459	$.each($('.chapter'), function (i, item) {
1460		var $this = $(this);
1461		var image_positions = [];
1462		image_positions = generatePositionsArray(250, 200, 40, 10);
1463
1464		var randomSize = (Math.random() * (1.300 - 0.550) + 0.550).toFixed(4);
1465
1466
1467		$.each($this.find('.chapter_item'), function (x, iitem) {
1468
1469			var coords = getRandomPosition(image_positions);
1470
1471
1472			$(iitem).css({
1473				left: coords.x + "px",
1474				top: coords.y + "px"
1475			});
1476			$(iitem).attr('defaultX', coords.x);
1477			$(iitem).attr('defaultY', coords.y);
1478
1479		});
1480
1481	});
1482
1483	var image_positions_top10 = [];
1484	var tw = w * 0.84;
1485	var th = h * 0.88;
1486
1487	image_positions_top10 = generatePositionsArray(tw - 300, th - 300, 40, 10);
1488
1489
1490	$.each($('.top10_item'), function (i, item) {
1491		var $this = $(this);
1492
1493
1494		//var randomSize = (Math.random() * (1.300 - 0.550) + 0.550).toFixed(4);
1495
1496		var coords = getRandomPosition(image_positions_top10);
1497
1498
1499		$(item).css({
1500			left: coords.x + "px",
1501			top: coords.y + "px"
1502		});
1503		$(item).attr('defaultX', coords.x);
1504		$(item).attr('defaultY', coords.y);
1505
1506	});
1507
1508	$('.top10_item').draggable({});
1509
1510});
1511
1512
1513function calculateDistance(elem, mouseX, mouseY) {
1514	var dist = Math.floor(Math.sqrt(Math.pow(mouseX - (elem.offset().left + (elem.width() / 2)), 2) + Math.pow(mouseY - (elem.offset().top + (elem.height() / 2)), 2)));
1515	return dist;
1516}
1517
1518function calculateDistanceDrag(elem, mouseX, mouseY, offsetX, offsetY) {
1519	var dist = Math.floor(Math.sqrt(Math.pow(mouseX - (elem.offset().left + (elem.width() / 2) + offsetX), 2) + Math.pow(mouseY - (elem.offset().top + (elem.height() / 2) + offsetY), 2)));
1520
1521	return dist;
1522}
1523
1524function mobileMenuListeners() {
1525	$('#mobile_menu_btn').click(function () {
1526
1527		$(this).toggleClass('active');
1528
1529		if ($(this).hasClass('active')) {
1530			$(this).attr('src', rootUrl + 'items/frontend/img/icons_35x35_X.svg');
1531			$('#mobile_menu').fadeIn('fast');
1532		} else {
1533			$(this).attr('src', rootUrl + 'items/frontend/img/icons_35x35_menu.svg');
1534			$('#mobile_menu').fadeOut('fast');
1535		}
1536
1537	});
1538
1539	$('.mobile_menu_item.sub').click(function () {
1540
1541		$(this).next('.submenu_holder_mobile').slideToggle();
1542		$(this).toggleClass('active');
1543	});
1544}
1545
1546
1547// function addListeners()
1548// {
1549
1550// 	$(document).click(function(){
1551// 		$('.tutorial_box').fadeOut();
1552// 		clearTimeout(mainTimer);
1553// 		clearTimeout(detailTimer);
1554// 	});
1555
1556// 	$('#top10_btn').click(function(){
1557// 		$('#top10_holder').show();
1558// 		$('.dropbtn').click();
1559
1560// 		//ignitePackery();
1561// 		$('.top10_item').dragMomentum();
1562// 	});
1563
1564// 	$('#popup_close').click(function(){
1565
1566// 		$('#vote_popup_holder').hide();
1567
1568// 	});
1569
1570// 	$('.lang_item').click(function(){
1571// 		if(!$(this).hasClass('noclick'))
1572// 		{
1573// 			var lang = $(this).attr('lang');
1574// 			window.location.href = rootUrl+"changeLanguage/"+lang;
1575// 		}
1576// 	});
1577
1578// 	$('.top10_item').click(function(){
1579// 		var pid = $(this).attr('pid');
1580
1581// 		$('.one_img[img_id="'+pid+'"]').parent().addClass('active').click();
1582
1583// 	});
1584
1585// 	$('.tw_share').click(function(e){
1586// 		var image_id = $(this).parent().parent().find('img').attr('img_id');
1587// 		tweetShare(image_id);
1588// 	});
1589
1590// 	$('#mail_share').click(function(e){
1591// 		var image_id = $(this).parent().parent().find('img').attr('img_id');
1592// 		mailShare(image_id);
1593// 	});
1594
1595// 	$('.mail_share').click(function(e){
1596// 		var image_id = $(this).parent().parent().find('img').attr('img_id');
1597// 		mailShare(image_id);
1598// 	});
1599
1600// 	$('#mail_share').on('mouseover',function(e){
1601// 		$(this).css({'fill': '#444'});
1602// 	});
1603
1604// 	$('#mail_share').on('mouseout',function(e){
1605// 		$(this).css({'fill': '#000'});
1606// 	});
1607
1608// 	$('.mail_share').on('mouseenter',function(e){
1609
1610// 		$(this).css({'fill': '#bbb'});
1611// 	});
1612
1613// 	$('.mail_share').on('mouseleave',function(e){
1614// 		$(this).css({'fill': '#fff'});
1615
1616// 	});
1617
1618
1619// 	$('.fb_share').click(function(e){
1620// 		var image_id = $(this).parent().parent().find('img').attr('img_id');
1621
1622
1623// 		$.ajax({
1624// 		   type: "POST",
1625// 		   url: rootUrl+"Frontend/images_detail",
1626// 		   data: { image_id: image_id },
1627// 		   success: function(data)
1628// 		   {
1629// 				var json = $.parseJSON(data);
1630// 		   		if(json.status == "success")
1631// 		   		{
1632
1633// 		   			facebookShareImage(json.image.fname,json.image.short_description,image_id);
1634// 		   		}
1635
1636// 			    else
1637// 			    {
1638
1639// 			    }
1640
1641
1642// 		   }
1643// 		});
1644
1645
1646
1647// 	});
1648
1649
1650// 	$('.likeb').click(function(e){
1651// 		e.stopImmediatePropagation();
1652// 		$('.tutorial_box').fadeOut();
1653// 		 var $this = $(this);
1654// 		 var image_id = $(this).parent().parent().find('img').attr('img_id');
1655
1656// 		 if(!$this.hasClass('liked'))
1657// 		 {
1658// 			$.ajax({
1659// 			   type: "POST",
1660// 			   url: rootUrl+"Frontend/addLike",
1661// 			   data: { image_id: image_id },
1662// 			   success: function(data)
1663// 			   {
1664// 					var json = $.parseJSON(data);
1665// 			   		if(json.status == "success")
1666// 			   		{
1667// 			   			$this.attr('src', 'items/frontend/img/Icons_40x40_heartvoted.svg');
1668// 			   			$this.removeClass('likeb').addClass('liked');
1669
1670// 			   			$image_like = $('.likeb[img_id="'+image_id+'"]');
1671// 			   			$image_like.attr('src', 'items/frontend/img/Icons_40x40_heartvoted.svg');
1672// 			   			$image_like.removeClass('likeb').addClass('liked');
1673
1674// 			   			var leftOff = $this.offset().left;
1675// 			   			var topOff = $this.offset().top;
1676
1677// 			   			$('#vote_popup_holder').css({left: leftOff-60, top: topOff-100}).show();
1678// 			   			setTimeout(function(){
1679// 				   			$('#vote_popup_holder').fadeOut();
1680// 			   			},5000) ;
1681// 			   		}
1682// 			   }
1683// 			 });
1684// 		 }
1685
1686//      });
1687
1688
1689// 	$('.menu_item').click(function(e){
1690// 		var chapter_id = $(this).attr('chapter_id');
1691// 		$('.chapter[cid="'+chapter_id+'"]').click();
1692// 		$('.dropbtn').click();
1693// 	});
1694
1695// 	$('.dropbtn').click(function(){
1696// 		$(this).toggleClass('active');
1697
1698// 		/*if($('.infobtn').hasClass('active'))
1699// 		{
1700// 			$('#infoDropdown').slideUp();
1701// 			$('.infobtn').removeClass('active');
1702// 		}*/
1703
1704// 		$('#listDropdown').slideToggle();
1705// 	});
1706
1707
1708// 	/*$('.infobtn').click(function(){
1709// 		$(this).toggleClass('active');
1710
1711// 		if($('.dropbtn').hasClass('active'))
1712// 		{
1713// 			$('#listDropdown').slideUp();
1714// 			$('.dropbtn').removeClass('active');
1715// 		}
1716
1717// 		$('#infoDropdown').slideToggle();
1718// 	});
1719// */
1720
1721
1722// 	$('.chapter_item').on('click', function(e){
1723// 		var item = $(this).children('img').attr('img_id');
1724// 		e.stopPropagation();
1725// 		//var item = $(this).attr('img_id');
1726// 		$('#vote_popup_holder').hide();
1727// 		if(!$(this).hasClass('dragging') && $(this).hasClass('active'))
1728// 		{
1729// 			$.ajax({
1730// 			   type: "POST",
1731// 			   url: rootUrl+"Frontend/images_detail",
1732// 			   data: { image_id: item },
1733// 			   success: function(data)
1734// 			   {
1735// 					var json = $.parseJSON(data);
1736// 			   		if(json.status == "success")
1737// 			   		{
1738
1739// 			   			$("#sammlung").empty().text(json.image.chaptername);
1740// 			   			$("#title_content").empty().text(json.image.short_description);
1741// 			   			$("#foto_content").empty().text(json.image.photographer);
1742// 			   			$("#jahr_content").empty().text(json.image.year);
1743// 			   			$("#ort_content").empty().text(json.image.place);
1744// 			   			$("#beschreibung_content").empty().text(json.image.description);
1745
1746// 			   			if(json.image.curatorial_content !== null && json.image.curatorial_content != '')
1747// 			   			{
1748// 			   				$("#kk_content").empty().text(json.image.curatorial_content).show();
1749// 			   				$("#kk_content_title").show();
1750// 			   			}
1751// 			   			else
1752// 			   			{
1753// 			   				$("#kk_content").empty().text(json.image.curatorial_content).hide();
1754// 			   				$("#kk_content_title").hide();
1755// 			   			}
1756
1757
1758// 			   			$("#detail_img").attr("src",rootUrl + "items/uploads/images/" + json.image.fname);
1759// 			   			$('#detail_img').attr('img_id', item);
1760// 			   			$('#detail_vote').attr('img_id', item);
1761// 			   			if(json.can_vote == 0)
1762// 			   			{
1763// 				   			$('#detail_vote').attr('src', rootUrl+'items/frontend/img/Icons_40x40_heartvoted.svg');
1764// 				   			$('#detail_vote').removeClass('likeb').addClass('liked');
1765// 			   			}
1766// 			   			else
1767// 			   			{
1768// 				   			$('#detail_vote').attr('src', rootUrl+'items/frontend/img/herz_s.svg');
1769// 				   			$('#detail_vote').removeClass('liked').addClass('likeb');
1770// 			   			}
1771
1772
1773// 			   			$("#overlay").fadeIn();
1774
1775
1776
1777
1778// 			   		}
1779
1780// 				    else
1781// 				    {
1782
1783// 				    }
1784
1785
1786// 			   }
1787// 			});
1788// 		}
1789// 		else
1790// 		{
1791// 			$(this).parent().click();
1792// 		}
1793// 	});
1794// 	var windowW = $(window).width();
1795// 	var windowH = $(window).height();
1796// 	var centerW = windowW/2;
1797// 	var centerH = windowH/2;
1798
1799// 	$.each($('.chapter'), function(i,item){
1800// 		var $this = $(this);
1801
1802// 		if($this.hasClass('centered'))
1803// 		{
1804// 			var coords = new_positions[0];
1805// 		}
1806// 		else
1807// 		{
1808// 			var coords = getRandomPosition(new_positions, true);
1809// 		}
1810
1811
1812
1813// 		$this.find('.chapter_title').css({'font-size': coords.z +'px'});
1814
1815// 		$this.find('.chapter_item').css({'max-width': coords.w +'px', 'max-height': coords.h +'px'});
1816
1817
1818
1819
1820// 		$this.attr('defaultX', coords.x);
1821// 		$this.attr('defaultY', coords.y);
1822// 		$this.attr('defaultW', coords.w);
1823// 		$this.attr('defaultH', coords.h);
1824
1825// 		var offX = coords.x - centerW;
1826// 		var offY = coords.y - centerH;
1827
1828
1829// 		if(offX < 0)
1830// 		{
1831// 			offX = offX * -1;
1832// 		}
1833
1834// 		if(offY < 0)
1835// 		{
1836// 			offY = offY * -1;
1837// 		}
1838
1839
1840// 		$this.css({left: coords.x+"px", top: coords.y+"px"});
1841
1842
1843// 		/*var distance = calculateDistance($(item), centerW, centerH);
1844// 		var diff = (distance/100);
1845
1846
1847// 		$this.css({'opacity': 1-(diff/10)});
1848// 		*/
1849
1850// 	});
1851
1852// 	$('.chapter_close').click(function(e){
1853
1854// 		$('#viewport').css('z-index', '100');
1855// 		$('.icons1').children('img').css('display', 'none');
1856// 		$('.mail_share').css('display', 'none');
1857// 		e.stopPropagation();
1858// 		var elem = $(this).parent();
1859// 		var x = elem.attr('defaultX');
1860// 		var y = elem.attr('defaultY');
1861// 		var w = elem.attr('defaultW');
1862// 		var h = elem.attr('defaultH');
1863// 		highest_z = 1;
1864// 		elem.find('.chapter_item').removeClass('active');
1865// 		$(this).hide();
1866// 		elem.css({'position': 'absolute', 'z-index': 100, 'background': 'none'});
1867// 		elem.stop().animate({left: x, top:y, width:300, height:300}, 300);
1868// 		elem.find('.chapter_title').css({'top': -22});
1869// 		elem.find('.chapter_item').draggable('destroy');
1870// 		elem.find('.logo').hide();
1871
1872
1873
1874// 		$.each(elem.find('.chapter_item'), function(x,iitem){
1875// 			var left = $(iitem).attr('defaultX');
1876// 			var top = $(iitem).attr('defaultY');
1877
1878
1879// 			$(iitem).stop().animate({'max-width': w, 'max-height': h, left: left, top: top, 'z-index': 0},300);
1880// 		});
1881
1882// 		addChapterListener();
1883// 		igniteDrag();
1884
1885// 	});
1886
1887// 	addChapterListener();
1888
1889// 	$('#info').click(function(){
1890// 		$("#info_overlay").fadeIn();
1891// 	});
1892
1893// 	$('.overlay_close').click(function(){
1894// 		$(this).parent().hide();
1895
1896// 	});
1897
1898// 	$('.upload_overlay_close').click(function(){
1899// 		$(this).parent().parent().fadeOut('100');
1900
1901// 	});
1902
1903// 	$('#upload_btn').click(function(){
1904// 		$('#image_upload_overlay').fadeIn('fast');
1905// 	});
1906
1907
1908// 	$('#image_input_dummy').click(function(){
1909// 		$('#image_input').click();
1910// 	});
1911
1912
1913// 	$('#save_image_btn').click(function(){
1914// 		var $this = $(this);
1915
1916// 		var uploadpath = '/hdgoe/Bildlandschaften/items/uploads/images';
1917// 		var xhr = new XMLHttpRequest();
1918// 		var fd = new FormData;
1919// 		var files = $('#image_input').prop('files');
1920
1921// 		fd.append('data', files[0]);
1922// 		fd.append('filename', files[0].name);
1923// 		fd.append('uploadpath', uploadpath);
1924
1925// 		xhr.addEventListener('load', function(e)
1926// 		{
1927// 			var ret = $.parseJSON(this.responseText);
1928
1929// 			if(ret.success)
1930// 			{
1931// 				$('input[name=fname]').val(ret.filename);
1932// 				/*var elem = '<img src="'+rootUrl + 'items/uploads/images/' + ret.filename+'"></img>';
1933// 				$('#image_input_dummy').hide();
1934// 				$('#image_holder').append(elem);*/
1935
1936// 				$.ajax({
1937// 				   type: "POST",
1938// 				   url: rootUrl+"Frontend/saveImage",
1939// 				   data: $('#image_form').serialize(),
1940// 				   success: function(data)
1941// 				   {
1942// 						var json = $.parseJSON(data);
1943// 				   		if(json.status == "success")
1944// 				   		{
1945// 				   			$('#upload_success').show();
1946// 				   			$this.hide();
1947// 				   			setTimeout(function(){
1948// 					   			$('#image_upload_overlay').hide();
1949// 					   			$('#image_form')[0].reset();
1950// 					   			$('#upload_step_2').hide();
1951// 					   			$('#upload_step_1').show();
1952// 					   			$('#upload_success').hide();
1953// 				   			},2000);
1954
1955// 				   			/*$('#image_holder').empty();
1956// 				   			$('#image_input_dummy').show();*/
1957// 				   		}
1958
1959// 					    else
1960// 					    {
1961
1962// 					    }
1963// 				   }
1964// 				});
1965
1966
1967
1968
1969// 			}
1970// 			else
1971// 			{
1972// 				alert('Error while uploading');
1973// 			}
1974// 	    });
1975
1976// 		xhr.open('post', rootUrl + 'Frontend/upload_image');
1977// 		xhr.send(fd);
1978
1979
1980
1981
1982// 		var $this = $(this);
1983
1984
1985// 	});
1986
1987// 	$('#weiter_image_btn').click(function(){
1988// 		var $this = $(this);
1989// 		$('#upload_error').hide();
1990// 		$('#save_image_btn').show();
1991// 		var can_continue = true;
1992
1993// 		if($('#image_input').val() == "" || $('#image_input').val() == " ")
1994// 		{
1995// 			can_continue = false;
1996// 		}
1997
1998
1999// 		if($('#upload_name').val() == "" || $('#upload_name').val() == " ")
2000// 		{
2001// 			can_continue = false;
2002// 		}
2003
2004// 		if($('#upload_email').val() == "" || $('#upload_email').val() == " ")
2005// 		{
2006// 			can_continue = false;
2007// 		}
2008
2009// 		if($('#upload_description').val() == "" || $('#upload_description').val() == " ")
2010// 		{
2011// 			can_continue = false;
2012// 		}
2013
2014
2015// 		if(!can_continue)
2016// 		{
2017// 			$('#upload_error').show();
2018// 		}
2019// 		else
2020// 		{
2021// 			$('#upload_step_1').hide();
2022// 			$('#upload_step_2').show();
2023// 		}
2024
2025
2026// 	});
2027
2028// 	$('#cancel_image_btn').click(function(){
2029// 		$('#upload_step_2').hide();
2030// 		$('#upload_step_1').show();
2031// 	});
2032
2033// 	$('#setup_submit').on('click', function(){
2034// 		var setup_id = $('#setup_number').val();
2035
2036// 		$.ajax({
2037// 		   type: "POST",
2038// 		   url: rootUrl+"Frontend/SaveSetup",
2039// 		   data: { setup_id : setup_id },
2040// 		   success: function(data)
2041// 		   {
2042// 				var json = $.parseJSON(data);
2043// 		   		if(json.status == "success")
2044// 		   		{
2045
2046// 		   				alert('Setup Successfully')
2047// 		   				window.location.href = rootUrl
2048
2049// 		   		}
2050
2051// 			    else
2052// 			    {
2053
2054// 			    }
2055
2056
2057// 		   }
2058// 		});
2059
2060// 	});
2061
2062// }
2063
2064
2065/*function addDetailViewListener(){
2066	$('.chapter_item').dblclick(function($itemId){
2067
2068
2069		   $data = array();
2070
2071		//get image data
2072	    $item = $this->cm->getPendingByID($itemId)->row();
2073
2074
2075		//move to accepted table
2076		$data = array('fname' => $item->fname,
2077					  'chapter_id' => $item->chapter_id,
2078					  'upload_date' => $item->upload_date,
2079					  'ip_address' => $item->ip_address,
2080					  'short_description' => $item->short_description,
2081					  'description' => $item->description,
2082					  'photographer' => $item->photographer,
2083					  'year' => $item->year,
2084					  'place' => $item->place,
2085					  'email' => $item->email,
2086					  'name' => $item->name);
2087		$this->cm->insertAcceptedImage($data);
2088
2089		//remove DB entry from pending_images
2090		$this->cm->deletePendingByID($itemId);
2091
2092	 $resbons= array('success'=>true);
2093
2094	 echo json_encode($resbons);
2095
2096
2097	}
2098
2099}*/
2100
2101
2102function addChapterListener() {
2103
2104	$('.chapter').click(function (e) {
2105
2106		var cid = $(this).attr('cid');
2107		$('.tutorial_box').fadeOut();
2108
2109		detailTimer = setTimeout(function () {
2110			$('.tutorial_box.detail').fadeIn();
2111		}, fadeTime);
2112
2113
2114		$("#upload_image_chapter").val(cid);
2115
2116		$('#viewport').css('z-index', '10000');
2117		$('#canvas').draggable('destroy');
2118
2119		var $this = $(this);
2120
2121		//$this.find('.chapter_item').children('img').css('width', '100%');
2122		$this.find('.chapter_item').addClass('active');
2123		var windowW = $(window).width();
2124		var windowH = $(window).height();
2125		var defaultW = $this.width();
2126		var defaultH = $this.height();
2127		var x = $this.attr('defaultX');
2128		var y = $this.attr('defaultY');
2129		var w = $this.attr('defaultW');
2130		var h = $this.attr('defaultH');
2131
2132
2133		var Wratio = (windowW / defaultW) * 0.8;
2134		var Hratio = (windowH / defaultH) * 0.8;
2135
2136		var movecanvasLeft = parseInt(windowW / 2) - parseInt(x) - parseInt(defaultW / 2);
2137		var movecanvasTop = parseInt(windowH / 2) - parseInt(y) - parseInt(defaultH / 2);
2138
2139		$('#canvas').stop().animate({
2140			left: movecanvasLeft,
2141			top: movecanvasTop
2142		}, 400, function () {
2143
2144			/*$.each($('.chapter'), function(i,item){
2145
2146				var distance = calculateDistance($(item), windowW/2, windowH/2);
2147				var diff = (distance/100);
2148
2149				$(item).css({'opacity': 1-(diff/10)});
2150			});
2151			*/
2152
2153			$this.css({
2154				'background': '#fff'
2155			});
2156			$this.find('.chapter_title').css({
2157				'top': 30
2158			});
2159			$this.css({
2160				'position': 'fixed',
2161				'z-index': 1000
2162			});
2163
2164			var last_left = 0;
2165			var last_top = 0;
2166
2167			$.each($this.find('.chapter_item'), function (x, iitem) {
2168				var left = $(iitem).attr('defaultX');
2169				var top = $(iitem).attr('defaultY');
2170
2171				var img_h = $(iitem).find('img').height();
2172				var img_w = $(iitem).find('img').width();
2173
2174				var maxW = 90 * Wratio;
2175				var maxH = 450 * Hratio;
2176
2177				if (img_h > img_w) {
2178					var maxW = 90 * Wratio;
2179					var maxH = 90 * Wratio;
2180				}
2181
2182
2183
2184
2185				$(iitem).stop().animate({
2186					'max-width': maxW,
2187					'max-height': maxH,
2188					left: left * Wratio,
2189					top: top * Hratio
2190				}, 300, function () {
2191
2192					var img_h = $(iitem).find('img').height();
2193					var img_w = $(iitem).find('img').width();
2194					if ($(iitem).css('display') != 'none') {
2195
2196						$(iitem).css({
2197							height: img_h
2198						});
2199
2200						if (x < 10) {
2201							last_left = (left * Wratio) + parseInt((img_w - 230));
2202							last_top = (top * Hratio) - parseInt(50);
2203
2204						}
2205
2206					}
2207
2208
2209				});
2210
2211
2212
2213				if ($(iitem).css('display') == 'none') {
2214					var iid = $(iitem).attr('iid');
2215
2216					hidden_images.push(iid);
2217
2218				}
2219
2220
2221			});
2222
2223			setTimeout(function () {
2224				$('#tutorial_like').css({
2225					left: last_left,
2226					top: last_top
2227				});
2228			}, 1000);
2229
2230
2231
2232
2233			$this.stop().animate({
2234				width: windowW,
2235				height: windowH,
2236				left: 0,
2237				top: 0,
2238				'opacity': 1
2239			}, function () {
2240				$this.find('.chapter_close').show();
2241				$this.find('.logo').show();
2242				$this.find('.icons1').children('img').fadeIn().css({
2243					'display': 'block'
2244				});
2245				$this.find('.mail_share').css('display', 'block');
2246				$this.find('.chapter_item').draggable({
2247
2248					// get the initial X and Y position when dragging starts
2249					start: function (event, ui) {
2250						xpos = ui.position.left;
2251						ypos = ui.position.top;
2252						highest_z++;
2253						event.preventDefault();
2254						$(this).addClass('dragging').css({
2255							'z-index': highest_z
2256						});
2257
2258
2259
2260					},
2261					// when dragging stops
2262					stop: function (event, ui) {
2263						// calculate the dragged distance, with the current X and Y position and the "xpos" and "ypos"
2264
2265						var xmove = ui.position.left - xpos;
2266						var ymove = ui.position.top - ypos;
2267						$(this).removeClass('dragging');
2268						event.preventDefault();
2269
2270
2271
2272					}
2273
2274
2275				});
2276				$this.find('.chapter_item').dragMomentum();
2277
2278
2279
2280
2281			});
2282
2283			$('.chapter').unbind('click');
2284
2285
2286
2287		});
2288
2289
2290
2291
2292
2293
2294	});
2295}
2296
2297function loadNextImage(current_elem, parent) {
2298	var current_id = current_elem.attr('iid');
2299
2300	var next = hidden_images[0];
2301
2302	var child = parent.find('.chapter_item[iid="' + parseInt(next) + '"]');
2303
2304	if (child.length > 0) {
2305
2306		var x = 1;
2307		var windowW = $(window).width();
2308		var windowH = $(window).height();
2309
2310		var elems = parent.find('.chapter_item');
2311		$.each(elems, function (i, item) {
2312			var zi = parseInt($(item).css('z-index'));
2313			if (zi > x) {
2314				x = zi;
2315			}
2316
2317			var Wratio = (windowW / 300) * 0.8;
2318			var Hratio = (windowH / 300) * 0.8;
2319
2320			var img_h = $(item).find('img').get(0).height;
2321			var img_w = $(item).find('img').get(0).width;
2322
2323			var maxW = 90 * Wratio;
2324			var maxH = 450 * Hratio;
2325
2326			if (img_h > img_w) {
2327				var maxW = 90 * Wratio;
2328				var maxH = 90 * Wratio;
2329			}
2330
2331
2332
2333			$(item).css({
2334				'z-index': zi + 1,
2335				'max-width': maxW,
2336				'max-height': maxH
2337			});
2338
2339
2340
2341
2342
2343		});
2344		var left = getRandomInt(windowW * 0.35, windowW * 0.50);
2345		var top = getRandomInt(windowH * 0.20, windowH * 0.35);
2346
2347
2348		highest_z++;
2349		child.fadeIn().css({
2350			'z-index': 1,
2351			left: left,
2352			top: top
2353		});
2354
2355		var img_h = child.find('img').height();
2356		var img_w = child.find('img').width();
2357		child.css({
2358			width: img_w,
2359			height: img_h
2360		});
2361
2362
2363		var img_h = child.find('img').height();
2364		var img_w = child.find('img').width();
2365		child.css({
2366			width: img_w,
2367			height: img_h
2368		});
2369
2370		hidden_images.shift();
2371	} else {
2372		if (parent.find('.chapter_item').length > 10) {
2373			var oldest_z = 1000;
2374			var oldest = 1;
2375
2376			parent.find('.chapter_item').each(function (i, item) {
2377
2378				if (parseInt($(item).css('z-index')) < oldest_z && parseInt($(item).css('z-index')) != 1) {
2379					oldest = $(item).attr('iid');
2380					oldest_z = parseInt($(item).css('z-index'));
2381				}
2382			});
2383
2384
2385
2386
2387			parent.find('.chapter_item[iid="' + parseInt(oldest) + '"]').css({
2388				'z-index': highest_z
2389			}).hide();
2390			hidden_images.push(oldest);
2391			loadNextImage(parent.find('.chapter_item[iid="' + parseInt(oldest) + '"]'), parent);
2392		}
2393
2394
2395	}
2396}
2397
2398
2399
2400
2401/***********************
2402 * RANDOM POS
2403 ************************/
2404// Returns a random integer between min (included) and max (excluded)
2405// Using Math.round() will give you a non-uniform distribution!
2406function getRandomInt(min, max) {
2407	return Math.floor(Math.random() * (max - min)) + min;
2408}
2409
2410// generate random positions
2411function generatePositionsArray(maxX, maxY, safeRadius, irregularity) {
2412	// declarations
2413	var positionsArray = [];
2414	var r, c;
2415	var rows;
2416	var columns;
2417	// count the amount of rows and columns
2418	rows = Math.floor(maxY / safeRadius);
2419	columns = Math.floor(maxX / safeRadius);
2420	// loop through rows
2421	for (r = 1; r <= rows; r += 1) {
2422		// loop through columns
2423		for (c = 1; c <= columns; c += 1) {
2424			// populate array with point object
2425			positionsArray.push({
2426				x: Math.round(maxX * c / columns) + getRandomInt(irregularity * -1, irregularity),
2427				y: Math.round(maxY * r / rows) + getRandomInt(irregularity * -1, irregularity)
2428			});
2429		}
2430	}
2431	// return array
2432	return positionsArray;
2433}
2434
2435// get random position from positions array
2436function getRandomPosition(array, removeTaken) {
2437	// declarations
2438	var randomIndex;
2439	var coordinates;
2440	// get random index
2441	randomIndex = getRandomInt(1, array.length - 1);
2442	// get random item from array
2443	coordinates = array[randomIndex];
2444	// check if remove taken
2445	if (removeTaken) {
2446		// remove element from array
2447		array.splice(randomIndex, 1);
2448	}
2449	// return position
2450	return coordinates;
2451}
2452
2453function generatePositions() {
2454	positions = generatePositionsArray(canvasWidth - 400, canvasHeight - 400, 320, 10);
2455}
2456
2457
2458
2459
2460
2461
2462
2463/******************************************************************************************************************************************************************************************************
2464 * DRAGGING
2465 *****************************************************************************************************************************************************************************************************/
2466function igniteDrag() {
2467	$('#canvas').draggable({
2468		start: draggingStart,
2469		stop: draggingStop,
2470		drag: draggingDrag,
2471	});
2472}
2473
2474function draggingStart(event, ui) {
2475	dragging = true;
2476	$('.tutorial_box').fadeOut();
2477	clearTimeout(mainTimer);
2478	$('.chapter').unbind('click');
2479	if ($('.dropbtn').hasClass('active')) {
2480		$('.dropbtn').click();
2481	}
2482
2483
2484}
2485
2486function draggingStop(event, ui) {
2487
2488
2489	setTimeout(function () {
2490		dragging = false;
2491		addChapterListener();
2492
2493	}, 100);
2494}
2495
2496
2497function draggingDrag(event, ui) {
2498
2499	viewport_offset_x = ui.position.left;
2500	viewport_offset_y = ui.position.top;
2501	var screenpos_x = (viewport_offset_x) + ($(window).width() / 2);
2502	var screenpos_y = (viewport_offset_y) + ($(window).height() / 2);
2503
2504
2505
2506	$('.chapter').each(function (i, item) {
2507		/*
2508		var distance = calculateDistanceDrag($(item), screenpos_x, screenpos_y, viewport_offset_x, viewport_offset_y);
2509		var diff = (distance/100)*0.9;
2510
2511		$(item).css({'opacity': 1-(diff/10)});*/
2512	});
2513
2514}
2515
2516function jumpToImage(img_id) {
2517	$('.chapter_item').find('img[img_id="' + img_id + '"]').parent().click();
2518}
2519
2520
2521function tweetShare(img_id) {
2522	var thisCorrectUrl = rootUrl + "detail/" + img_id;
2523	var text = "";
2524
2525	window.open(
2526		'https://twitter.com/share?url=' + encodeURIComponent(thisCorrectUrl) + '&text=' + text,
2527		'facebook-share-dialog',
2528		'width=626,height=436');
2529	return false;
2530}
2531
2532
2533function mailShare(img_id) {
2534	var thisCorrectUrl = rootUrl + "detail/" + img_id;
2535	var text = "";
2536
2537	var subject = 'HdGÖ Bildlandschaften';
2538	var emailBody = thisCorrectUrl;
2539	window.location = 'mailto:?subject=' + subject + '&body=' + emailBody;
2540
2541
2542
2543	return false;
2544}
2545
2546function facebookShareImage(fname, title, pid) {
2547	if (title == " ") {
2548		title = "Image from bildlandschaften.hdgoe.at";
2549	}
2550
2551	FB.ui({
2552			method: 'share_open_graph',
2553			action_type: 'og.shares',
2554			action_properties: JSON.stringify({
2555				object: {
2556					'og:url': rootUrl + "detail/" + pid,
2557					'og:title': title,
2558					'og:description': "See this image with all details on bildlandschaften.hdgoe.at",
2559					'og:image': rootUrl + "items/uploads/images/" + fname
2560				}
2561			})
2562		},
2563		function (response) {
2564			// Action after response
2565
2566		});
2567
2568}
2569
2570
2571function startImageTimer(elem) {
2572	/*var id = $(this).find('img').attr("img_id");
2573
2574    timeouts[id] = setTimeout(function(){
2575        $("#"+id).stop(true).animate({"opacity":"1"},1000);
2576    }, 100);*/
2577}
2578
2579
2580dragMoment = function () {
2581	var howMuch = 150; // change this for greater or lesser momentum
2582	var minDrift = 5; //  minimum drift after a drag move
2583
2584	var containerPadding = [10, 10, 10, 10]; // top, right, bottom, left
2585	//  how near an edge can we get before the spring-back motion happens?
2586	//  positive numbers give a "padding" to the container (or window),
2587	//  negative numbers allow the dragged div to slide some distance outside
2588
2589	var easeType = 'easeOutQuad';
2590
2591	//  The standard ease types are 'linear' and 'swing'
2592	//  jQuery UI includes the following:  'easeInQuad',
2593	//  'easeOutQuad',  'easeInOutQuad',  'easeInCubic',
2594	//  'easeOutCubic',  'easeInOutCubic',  'easeInQuart',
2595	//  'easeOutQuart',  'easeInOutQuart', 'easeInQuint',
2596	//  'easeOutQuint',  'easeInOutQuint',  'easeInSine',
2597	//  'easeOutSine',  'easeInOutSine',  'easeInExpo',
2598	//  'easeOutExpo',  'easeInOutExpo',  'easeInCirc',
2599	//  'easeOutCirc',  'easeInOutCirc',  'easeInElastic',
2600	//  'easeOutElastic',  'easeInOutElastic',  'easeInBack',
2601	//  'easeOutBack',  'easeInOutBack',  'easeInBounce',
2602	//  'easeOutBounce',  'easeInOutBounce'
2603	//  Also see this page for a great display of the easing types.
2604	//  http://jqueryui.com/demos/effect/#easing
2605
2606	//  No user options below this point.
2607
2608	var dXa = [0];
2609	var dYa = [0];
2610	var dTa = [0];
2611
2612	return {
2613		cPadding: containerPadding, // top, right, bottom, left
2614		bounds: {},
2615		uid: 'dragMoID_',
2616		uindex: 1,
2617
2618		setBounds: function (elemID, containment, bbWidth, bbHeight) {
2619			/* dragMoment.bounds[elemID] = [];
2620			 if (!containment) {  // make the window the container, calibrate the boundaries
2621			     var dokWidth= $(window).width();
2622			     var dokHeight = $(window).height();
2623			     dragMoment.bounds[elemID][0] = dragMoment.cPadding[0];
2624			     dragMoment.bounds[elemID][1] = parseInt( $(window).width() - ( dragMoment.cPadding[1] + bbWidth) );
2625			     dragMoment.bounds[elemID][2] = parseInt( $(window).height() - ( dragMoment.cPadding[2] + bbHeight) );
2626			     dragMoment.bounds[elemID][3] = dragMoment.cPadding[3];
2627			 } else {  // container was set, so calibrate the boundaries
2628			     var cOffset = $(containment).offset();
2629
2630			     var cWidth = $(containment).outerWidth();
2631			     var cHeight = $(containment).outerHeight();
2632			     var bTop = parseInt( cOffset.top + dragMoment.cPadding[0] );
2633			     var bRight = parseInt( (cOffset.left + cWidth) - (dragMoment.cPadding[1] + bbWidth) );
2634			     var bBottom = parseInt( (cOffset.top + cHeight) - (dragMoment.cPadding[2] + bbHeight) );
2635			     var bLeft = parseInt( cOffset.left + dragMoment.cPadding[3] );
2636			     dragMoment.bounds[elemID] = [bTop, bRight, bBottom, bLeft];
2637			     // turn off containment, it's now handled by the dragMomentum.
2638			     $('#'+elemID).draggable("option", 'containment', '' );
2639			 }*/
2640		},
2641
2642		start: function (elemId, Xa, Ya, Ta) {
2643			dXa[elemId] = Xa;
2644			dYa[elemId] = Ya;
2645			dTa[elemId] = Ta;
2646			$('#' + elemId).data('moveCheck', 1);
2647
2648			highest_z++;
2649			$('#' + elemId).addClass('dragging').css({
2650				'z-index': highest_z
2651			});
2652
2653			$('.tutorial_box').fadeOut();
2654			loadNextImage($('#' + elemId), $('#' + elemId).parent());
2655
2656		}
2656, // END dragMoment.start()
2657
2658		stop: function (elemId, Xb, Yb, Tb) {
2659			//  record X and Y position, and the time when user stopped dragging.
2660
2661			var Xa = dXa[elemId];
2662			var Ya = dYa[elemId];
2663			var Ta = dTa[elemId];
2664			var Xc = 0;
2665			var Yc = 0;
2666			/*  var boundaryTop = dragMoment.bounds[elemId][0];
2667            var boundaryRight = dragMoment.bounds[elemId][1];
2668            var boundaryBottom = dragMoment.bounds[elemId][2];
2669            var boundaryLeft = dragMoment.bounds[elemId][3];
2670    */
2671			var dDist = Math.sqrt(Math.pow(Xa - Xb, 2) + Math.pow(Ya - Yb, 2));
2672			var dTime = Tb - Ta;
2673			var dSpeed = dDist / dTime;
2674			dSpeed = Math.round(dSpeed * 100) / 100;
2675
2676			var distX = Math.abs(Xa - Xb);
2677			var distY = Math.abs(Ya - Yb);
2678
2679			var dVelX = (minDrift + (Math.round(distX * dSpeed * howMuch / (distX + distY))));
2680			var dVelY = (minDrift + (Math.round(distY * dSpeed * howMuch / (distX + distY))));
2681
2682			var position = $('#' + elemId).position();
2683			var locX = position.left;
2684			var locY = position.top;
2685
2686			if (Xa > Xb) { // we are moving left
2687				Xc = locX - dVelX;
2688			} else { //  we are moving right
2689				Xc = locX + dVelX;
2690			}
2691
2692			if (Ya > Yb) { // we are moving up
2693				Yc = (locY - dVelY);
2694			} else { // we are moving down
2695				Yc = (locY + dVelY);
2696			}
2697			// Boundary Check
2698			/*   if (Xc < boundaryLeft ) { Xc = boundaryLeft }
2699			   if (Xc > boundaryRight ) { Xc = boundaryRight }
2700			   if (Yc < boundaryTop ) { Yc = boundaryTop }
2701			   if (Yc > boundaryBottom ) { Yc = boundaryBottom }
2702			   */
2703			var newLocX = Xc + 'px';
2704			var newLocY = Yc + 'px';
2705			$('#' + elemId).removeClass('dragging');
2706			$('#' + elemId).animate({
2707				left: newLocX,
2708				top: newLocY,
2709				useTranslate3d: true
2710			}, 500, easeType);
2711			startImageTimer($('#' + elemId));
2712
2713		} // END  dragMoment.stop()
2714	}; // END returned (public) functions
2715}(); // END dragMoment
2716
2717jQuery.fn.dragMomentum = function () {
2718	$(this).each(function () {
2719		$(this).css('position', 'absolute');
2720		if (!$(this).attr('id')) {
2721			// make sure the element has an ID, assign if necessary
2722			$(this).attr('id', (dragMoment.uid + dragMoment.uindex));
2723			dragMoment.uindex++;
2724		}
2725		var containment = $(this).draggable("option", 'containment');
2726		var bbWidth = $(this).outerWidth();
2727		var bbHeight = $(this).outerHeight();
2728		dragMoment.setBounds(this.id, containment, bbWidth, bbHeight);
2729
2730		var startOptions = function (e, ui) {
2731			dragMoment.start(this.id, e.clientX, e.clientY, e.timeStamp);
2732		};
2733		var stopOptions = function (e, ui) {
2734			dragMoment.stop(this.id, e.clientX, e.clientY, e.timeStamp);
2735			$(e.originalEvent.target).one('click', function (e) {
2736				e.stopImmediatePropagation();
2737			});
2738		};
2739		$(this).draggable("option", 'start', startOptions);
2740		$(this).draggable("option", 'stop', stopOptions);
2741	});
2742	return $(this);
2743} // END jquery .dragMomentum();

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.