PageSourceSearch

https://lijstjestijd.be/extensions/ltd/assets/ltd2020/js/lijstjes.js?ver=1.8

js lijstjestijd.be collected 2026-10-01 16:01:44 UTC 73,362 bytes, 2,824 lines download raw bytes

1var lastScrollTop = 0;
2
3var are_cookies_enabled = function()
4{
5	var cookieEnabled = (navigator.cookieEnabled) ? true : false;
6
7	if (typeof navigator.cookieEnabled == "undefined" && !cookieEnabled)
8	{ 
9		document.cookie="testcookie";
10		cookieEnabled = (document.cookie.indexOf("testcookie") != -1) ? true : false;
11	}
12	return (cookieEnabled);
13}
14
15var initContextMenu = function(gbc){
16	$('.dropdown-menu').on("click.bs.dropdown", function (e) { 
17		
18		if($(e.target).is("[data-toggle]")){
19			$(".collapse.show", $($(e.target).data("parent")) ).collapse('toggle');
20			$($(e.target).data("target")).collapse('toggle');
21			e.stopPropagation(); 
22			e.preventDefault(); 
23		}
24	});
25}
26var linkedFeedRows = function(container,ids){
27	for(key in ids){
28		var id = ids[key];
29		$("#item_"+id).addClass("linked");
30		$(".showlinked",$("#item_"+id)).removeClass("d-none");
31		$(".hidelinked",$("#item_"+id)).addClass("d-none");
32	}
33}
34var unlinkedFeedRows = function(container,ids){
35	for(key in ids){
36		var id = ids[key];
37		$("#item_"+id).removeClass("linked");
38		$(".showlinked",$("#item_"+id)).addClass("d-none");
39		$(".hidelinked",$("#item_"+id)).removeClass("d-none");
40	}
41}
42
43var initDataTables = function(container){
44	
45	$(".datatable",container).each(function(){
46		var datatable = $(this);
47		if(datatable.data("url")){
48			var params = {
49				pp 			:	datatable.data("pp")?datatable.data("pp"):50,
50				cp			:	datatable.data("cp")?datatable.data("cp"):1,
51				url			:	datatable.data("url"),
52				selectable	:	datatable.data("selectable")?datatable.data("selectable"):false,
53				multiselect	:	datatable.data("multiselect")?datatable.data("multiselect"):false,
54				onselect	:	datatable.data("onselect")?datatable.data("onselect"):false,
55				ondeselectall : datatable.data("ondeselectall")?datatable.data("ondeselectall"):false,
56				onload		  : datatable.data("onload")?datatable.data("onload"):false,
57				collapsable	  :	datatable.data("collapsable")?datatable.data("collapsable"):false,
58				clickable	  :	datatable.data("clickable")?datatable.data("clickable"):false,
59			};
60			var initparams = {
61				perpage	:	params.pp, 
62				page	:	params.cp
63			};
64			
65			datatable.minidatatable({
66				url				:	params.url,
67				method			:	"POST",
68				params			:	initparams,
69				sortable		:	true,
70				multiselect		:	params.multiselect,
71				selectable		:	params.selectable,
72				refreshrate		:	false,
73				onload			:	function(dt){
74					var container = dt.parents(".datatable-container");
75					$(".datatable-pager",container).minipager({
76						total	:	1,
77						perpage	:	params.pp,
78						page	:	params.cp,
79						onclick	:	function(page){
80							$(".datatable-body .datatable",container).data("minidatatable").setParam("page",page);
81							$(".datatable-body .datatable",container).data("minidatatable").refresh();
82						}
83					});
84					$(".datatable-pager",container).data("minipager").setTotal(dt.getTotalRowCount());
85					$(".datatable-pager",container).data("minipager").refresh();
86					if($(".chosen",container).length > 0){
87						$(".chosen",container).chosen({disable_search_threshold: 10});
88					}
89					$(".clear-filter",container).click(function(){
90						$(".datatable-body .datatable",container).data("minidatatable").clearFilter();
91						return false;
92					});
93					if(params.clickable){
94						$("tr td:not(.disableclick)",container).click(function(){
95							if($(this).closest("tr").hasClass("dialog")){
96							}else{
97								window.location = $(this).closest("tr").data("href");
98							}
99						});
100						
101					}
102					if(params.onload){
103						if (typeof window[params.onload] === "function") {
104							try{
105								window[params.onload](dt);
106							}catch(e){}
107						}
108					}
109					
110				},
111				onselect		:	function(row,dt){
112					if(params.onselect){
113						if (typeof window[params.onselect] === "function") {
114							try{
115								window[params.onselect](row,dt);
116							}catch(e){}
117						}
118					}
119					if(datatable.attr("id"))
120						$(".showonselect[rel="+datatable.attr("id")+"]",container).show();
121				},
122				ondeselectall	:	function(dt){
123					if(params.ondeselectall){
124						if (typeof window[params.ondeselectall] === "function") {
125							try{
126								window[params.ondeselectall](dt);
127							}catch(e){}
128						}
129					}
130					if(datatable.attr("id"))
131						$(".showonselect[rel="+datatable.attr("id")+"]",container).hide();
132				},
133				height			:	"max",
134				scroll			:	false,
135				footer			:	true
136			});
137			
138		}
139		
140	});
141}
142
143var loadlistitem = function(ctr){
144	$("body").addClass("blur loading");
145}
146
147var openlistitem = function(ctr){
148	
149	if(ctr && ctr.is(".dialog") && ctr.get("url")){
150		if (typeof ga == "function") {
151			ga('send', 'pageview', getUrlPath(ctr.get("url")));
152		}
153	}
154	
155	$("body").removeClass("loading");
156	$("body").addClass("blur");
157	initReloadDialogLinks(ctr);
158	
159	if($(".w-50, .wizard-step-1, .confirm, .confirm-dialog,	.dropper.error,.view-listitem,.confirmation,.intro, .upgrade-application",ctr).length > 0){
160		ctr.addClass("half-width");
161		var trigger = ctr.get("trigger");
162	}else if($(".checkout",ctr).length > 0){
163		var trigger = ctr.get("trigger");
164	}else{
165		ctr.removeClass("half-width");
166		var trigger = ctr.get("trigger");
167		if(trigger.hasClass("btn-icon")){
168			trigger =  $("#btn-share");
169		}
170		var top = trigger.offset().top;
171		/*
172		 ctr.css({
173			"top"	:	top
174		});*/
175	}
176	if($(".chosen",ctr).length > 0){
177		setTimeout(function(){
178			$(".chosen",ctr).each(function(){
179				$(this).next().width($(this).parent(0).innerWidth());
180			});
181		},250);
182	}
183	
184	
185	
186	$('.carousel',ctr).carousel({
187		interval: false
188	});
189	
190	setTimeout(function(){
191		if(ctr.height() > $(window).height()){
192			ctr.addClass("max-height");
193			//ctr.css("top",$(document).scrollTop());
194			ctr.css("top", 0);
195			
196			ctr.css("margin-top", "25px" );
197			ctr.css("margin-bottom", "25px" );
198			
199			$(".dialog-container").removeClass("align-items-center");
200			//$(".dialog-container").addClass("py-2");
201		}else{
202			$(".dialog-container").addClass("align-items-center");
203			//$(".dialog-container").removeClass("py-2");
204		}
205	},250);
206	
207	
208	$(".dialog .img-preview  a.remove, .dialog .img-container a.remove").click(function(){
209		if($(".carousel",ctr).length > 0){
210			if($(this).parent(0).next().is(".carousel-item")){
211				$(this).parent(0).next().addClass("active");
212			}else if($(this).parent(0).prev().is(".carousel-item")){
213				$(this).parent(0).prev().addClass("active");
214			}
215			$(this).parent(0).remove();
216			if($(".carousel-item",$(".img-container",ctr)).length == 1){
217				$(".carousel-control-prev",ctr).remove();
218				$(".carousel-control-next",ctr).remove();
219				
220			}
221			if($(".slide",$(".img-container",ctr)).length == 0){
222				$(".img-container",ctr).addClass("empty");
223			}
224		}else{
225			$(this).parent(0).remove();
226		}
227		
228	});
229	
230	stopBodyScrolling(true);
231}
232var closelistitem = function(ctr){
233	stopBodyScrolling(false);
234	$("body").removeClass("blur");
235}
236
237
238var stopBodyScrolling = function(bool) {
239    if (bool === true) {
240        document.body.addEventListener("touchmove", freezeVp, false);
241        if($("#app-container").lenth > 0)
242        	$("#app-container").get(0).addEventListener("touchmove", freezeVp, false);
243    } else {
244        document.body.removeEventListener("touchmove", freezeVp, false);
245        if($("#app-container").lenth > 0)
246        	$("#app-container").get(0).removeEventListener("touchmove", freezeVp, false);
247    }
248}
249var freezeVp = function(e) {
250    e.preventDefault();
251};
252
253var initForms = function(container){
254	
255	
256	$("form.ajaxform",container).each(function(){
257		var form 	= $(this);
258		var iframe;
259		
260		if($("iframe#"+form.attr("target")).length ==  0){
261			iframe 	= $("<iframe src='about:blank' name='"+form.attr("target")+"' id='"+form.attr("target")+"'></iframe>");
262			iframe.css({width:0,height:0,visibility:'hidden',position:'absolute','bottom':0});
263			setTimeout(function(){
264				$("body").append(iframe);
265			},250);
266			
267		}else{
268			iframe = $("iframe#"+form.attr("target"));
269		}
270		
271		form.submit(function(){
272			if(form.data("onsubmit")){
273				var fn = window[form.data("onsubmit")];
274				if(typeof fn === 'function') {
275					fn(form);
276				}
277			}
278			$(".message-error,.message-error-fixed,.alert-error",form).remove();
279			return true;
280		});
281		
282		setTimeout(function(){
283			iframe.off("load");
284			
285			iframe.on("load",function(){
286				var w = this.contentWindow;
287				if(!w) w = iframe[0];
288				if(w){
289					try{
290						if(form.data("callback")){
291							var fn = window[form.data("callback")];
292							if(typeof fn === 'function') {
293								if(form.data("response") && form.data("response") == "html" ){
294									fn($(w.document.body).html(),form);
295								}else{
296									fn($(w.document.body).text(),form);
297								}
298							}
299						}
300						form.removeClass("loading");
301					}catch(e){
302						
303					}
304					
305					
306				}
307			});
308		},400);
309	});
310	
311	
312	
313	if($(".input-tag-container",container).length > 0){
314		$(".input-tag-container",container).each(function(){
315			initTagger($(this));
316		});
317	}
318	
319	$(".submitonchange",container).change(function(){
320		if($(this).data("onchange")){
321			if (typeof window[$(this).data("onchange")] === "function") {
322				try{
323					window[$(this).data("onchange")]($(this));
324				}catch(e){}
325			}
326		}
327		$(this).parents("form").submit();
328	});
329	
330	
331	/*
332	if($("input.currency",container).length > 0){
333		$("input.currency",container).each(function(){
334			$(this).inputmask("currency");
335		});
336	}
337	*/
338	
339	/*
340	$("input.spinner",container).each(function(){
341		var options = {};
342		if($(this).data("max")){
343			options["max"] = $(this).data("max");
344		}
345		options["icons"] = { down: "ui-icon-minus", up: "ui-icon-plus" };
346		options["min"] = 1;
347		$(this ).spinner(options);
348	});*/
349	
350	
351	if($("input.masked",container).length > 0){
352		$("input.masked",container).each(function(){
353			$(this).inputmask();
354		});
355	}
356	
357	$("form.login input").bind("keydown",function(e){
358		if(e.which == 13){
359			$("button[name=user_login]").trigger("click");
360			return false;
361		}
362	});
363	
364	/*$(".input-field input[type=text], .input-field input[type=number], .input-field textarea,.input-field select",container).bind("focus",function(){
365		$(this).addClass("active");
366	});
367	$(".input-field input[type=text], .input-field input[type=number], .input-field textarea,.input-field select",container).bind("blur",function(){
368		$(this).removeClass("active");
369		
370		if($(this).val() != ""){
371			$(this).addClass("notempty");
372		}else{
373			$(this).removeClass("notempty");
374		}
375	});
376	$(".input-field > input[type=file]").change(function(){
377		$(this).next("label").next("span").html($(this).val());
378		if($(this).val()){
379			$(this).addClass("active");
380		}else{
381			$(this).removeClass("active");
382		}
383	});
384	$(".input-field select",container).bind("change",function(){
385		if($(this).val() == ""){
386			$(this).removeClass("active");
387		}else{
388			$(this).addClass("active");
389		}
390	});*/
391	
392	
393	$("input[type=text].number",container).on("keyup",function(e){
394		var value = $(this).val();
395		$(this).val(value.replace(",","."));
396	});
397	
398	if($(".file-preview input[type=file]",container).length > 0){
399		
400		if (window.File && window.FileReader && window.FileList && window.Blob) {
401			
402			var handleImgPreview = function(e){
403				var files  = e.target.files; 
404				var reader = new FileReader();
405				
406				
407				reader.onload = function (e) {
408					if($(".file-preview .preview .cover").length > 0){
409						
410						$(".file-preview .preview .cover").get(0).style.backgroundImage = 'url(' + e.target.result + ')';
411						
412					}else{
413						$(".file-preview .preview img").remove();
414						var img = $("<img/>");
415						img.get(0).src = e.target.result;
416						$(".file-preview .preview").append(img);
417					}
418			    };
419			    reader.readAsDataURL(files[0]);
420				 
421			}
422			$(".file-preview input[type=file]",container).on("change",handleImgPreview);
423		}
424	}
425	$(".custom-on-off",container).each(function(){
426		var check = $("input[type=checkbox]",$(this));
427		var clone  = $("<input type='checkbox' name='"+check.attr("name")+"' value='0' class='hidden' />");
428		$(this).after(clone);
429		$("input[type=checkbox]",$(this)).on("change",function(e){
430			if(!check.is(":checked")){
431				clone.prop("checked",true);
432			}else{
433				clone.prop("checked",false);
434			}
435			return true;
436		});
437		check.trigger("change");
438	});
439	
440	
441	
442	if($(".chosen",container).length > 0){
443		$(".chosen",container).each(function(){
444			
445			var opts = {
446				disable_search_threshold: 10
447			};
448			if($(this).data("maxselected")){
449				opts['max_selected_options'] = $(this).data("maxselected");
450			}
451			
452			$(this).chosen(opts);
453		});
454		
455		$('.chosen-container').on('touchstart', function(e){
456		     e.stopPropagation(); e.preventDefault();
457		     // Trigger the mousedown event.
458		    $(this).trigger('mousedown');
459		});
460		
461	}	
462	if($(".datepicker",container).length > 0){
463		$(".datepicker",container).datepicker({
464			dateFormat	:	"dd-mm-yy",
465			beforeShow: function() {
466		        setTimeout(function(){
467		            $('.ui-datepicker').css('z-index', 10000);
468		        }, 0);
469		    }
470		});
471	}
472	
473	$("form.validateform").on("submit",function(e){
474		if(!validateForm($(this)))
475			return false;
476	});
477	
478	
479}
480
481var removeError = function(){
482	if($(this).is("input[type=radio]")){
483		var name = $(this).attr("name");
484		$("input[name='"+name+"']").parent(0).removeClass("err-required");
485		$("input[name='"+name+"']").off("change",removeError);
486	}else{
487		$(this).parent(0).removeClass("err-required");
488		$(this).off("change",removeError);
489	}
490}
491
492var validateForm = function(form){
493	var submit = true;
494	$("input[data-required], select[data-required], textarea[data-required]",form).each(function(){
495		//NOT NECESSARY IF NOT SHOWN
496		if($(this).parents(".collapse:not(.show)").length > 0)
497			return;
498		if($(this).parents(".togglefield.d-none").length > 0)
499			return;
500		
501		var validate = true;
502		if($(this).data("required") == true){
503			if($(this).is("input[type=checkbox]")){
504				if(!$(this).is(":checked")){
505					validate = false;
506					submit   = false;
507					$(this).parent(0).addClass("err-required")
508					$(this).on("change",removeError);
509				}
510			}
511			if($(this).is("input[type=text]") || $(this).is("select")){
512				if($(this).val() == "" || ($(this).val() == "0" && $(this).is("select"))){
513					validate = false;
514					submit   = false;
515					$(this).parent(0).addClass("err-required");
516					$(this).on("change",removeError);
517				}
518			}
519			if($(this).is("textarea") && $(this).val() == ""){
520				validate = false;
521				submit   = false;
522				$(this).parent(0).addClass("err-required");
523				$(this).on("change",removeError);
524			}
525		}
526		$("input[data-validation]",form).each(function(){
527			if($(this).parents(".collapse:not(.show)").length > 0)
528				return;
529			
530			if(!validateField($(this))){
531				$(this).parent(0).addClass("err-required");
532				validate = false;
533				submit   = false;
534				$(this).on("change",removeError);
535			}
536			
537		});
538	});
539	
540	return submit;
541}
542var validateField = function(field){
543	if(field.data("validation") == "IBAN"){
544		try {
545			var vatval = field.val();
546			var fvat   = "BE";
547			
548			vatval = vatval.replace(/\D/g,'');
549			if(!IBAN.isValid(fvat+vatval)){
550				return false;
551			}
552			
553			field.val(vatval);
554		} catch (error) {
555			
556		}
557	}
558	if(field.data("validation") == "EMAIL"){
559		
560		    var emailRegex = /^([A-Za-z0-9_\-.+])+@([A-Za-z0-9_\-.])+\.([A-Za-z]{2,})$/;
561		    try {
562		    	var email =  field.val();
563		    	if(!emailRegex.test(email)){
564			    	return false;
565			    }
566			} catch (error) {
567				
568			}
569	}
570	if(field.data("validation") == "MOD97"){
571		 try {
572			
573			var val = field.val().replace(/\D/g,'');
574			var test = val.substring(val.length-2,val.length);
575	    	var mod =  modulo(val.substring(0,val.length-2),97);
576	    	if(mod == 0){
577	    		mod = 97;
578	    	}
579	    	if(parseInt(test) != parseInt(mod)){
580	    		throw Exception();
581	    	}
582		} catch (error) {
583			return false;
584		}
585	}
586	if(field.data("validation") == "NUMBER"){
587		 try {
588			 	var val = field.val();
589			 	if(!isNaN(parseFloat(val)) && isFinite(val)){
590			 	}else{
591			 		throw Exception();
592			 	}
593				/*if(!IsRRNoValid(val)){
594		    		
595		    	}*/
596			} catch (error) {
597				return false;
598			}
599	}
600	return true;
601}
602
603var parseFormResponse = function(responseStr,form){
604	if(!responseStr)
605		return;
606	
607	if(typeof(responseStr) == "object"){
608		var response = responseStr;
609	}else{
610		eval("var response = "+responseStr+";");
611	}
612	
613	var dialog = false;
614	var container = form.parent();
615	if(form.is(".dialog")){
616		dialog = getDialog(form);
617	}else if(form.parents(".dialog").length > 0){
618		dialog = getDialog(form.parents(".dialog"));
619	}else{
620		
621	}
622	var feedbackTimeout = false;
623	for(key in response){
624		var action = response[key];
625		if(action.action == "close" && dialog){
626			dialog.close();
627		}
628		if(action.action == "clear"){
629			if($(action.id).length > 0){
630				$(action.id).children().fadeOut(function(){
631					$(this).remove();
632				});
633			}
634		}
635		if(action.action == "show"){
636			if(action["id"]){
637				$("#"+action.id).removeClass("d-none");
638			}
639		}
640		if(action.action == "hide"){
641			if(action["id"]){
642				$("#"+action.id).addClass("d-none");
643			}
644		}
645		if(action.action == "remove"){
646			if(action["id"]){
647				if(action["animation"] && action["animation"] == "none"){
648					$("#"+action.id).remove();
649				}else{
650					$("#"+action.id).fadeOut(function(){
651						$(this).remove();
652					});
653				}
654			}else if(action["ids"]){
655				for(key in action["ids"]){
656					var id = action["ids"][key];
657					$("#"+id).fadeOut(function(){
658						$(this).remove();
659					});
660				}
661			}
662		}
663		if(action.action == "append"){
664			
665			var prepend_id = action.id;
666			$.get(action.url,function(html){
667				var el = $(html);
668				$("input[name='runjs[]']",el).each(function(){
669					var func = $(this).val();
670					if (typeof window[func] === "function") {
671						try{
672							window[func](el);
673						}catch(e){
674							
675						}
676					}
677				});
678				$("#"+prepend_id).append(el);
679			});
680		}
681		if(action.action == "prepend"){
682			var prepend_id = action.id;
683			$.get(action.url,function(html){
684				var el = $(html);
685				
686				$("input[name='runjs[]']",el).each(function(){
687					var func = $(this).val();
688					if (typeof window[func] === "function") {
689						try{
690							window[func](el);
691						}catch(e){
692							
693						}
694					}
695				});
696				
697				$("#"+prepend_id).prepend(el);
698				initContextMenu(el);
699				initDialogLinks(el);
700				if(el.hasClass("dialog-link"))
701					initDialogLink(el);
702				
703				
704				
705			});
706		}
707		if(action.action == "replace"){
708			var replace_id = action.id;
709			if(action.html){
710				var toreplace = $("#"+replace_id);
711				var el = $(action.html);
712				toreplace.replaceWith(el);
713				$("input[name='runjs[]']",el).each(function(){
714					var func = $(this).val();
715					if (typeof window[func] === "function") {
716						try{
717							window[func](el);
718						}catch(e){
719							
720						}
721					}
722				});
723				initAjaxLinks(el);
724				
725			}else if(action.url){
726				$.get(action.url,function(html){
727					var el = $(html);
728					
729					$("input[name='runjs[]']",el).each(function(){
730						var func = $(this).val();
731						if (typeof window[func] === "function") {
732							try{
733								window[func](el);
734							}catch(e){
735								
736							}
737						}
738					});
739					
740					$("#"+replace_id).replaceWith(el);
741					initContextMenu(el);
742					initDialogLinks(el);
743					if(el.hasClass("dialog-link"))
744						initDialogLink(el);
745				});
746			}
747		}
748		
749		if(action.action == "refreshdatatable"){
750			if($(".datatable-container",form.parents(".container")).length > 0){
751				if($(".datatable-body .datatable",form.parents(".container")).data("minidatatable")){
752					$(".datatable-body .datatable",form.parents(".container")).data("minidatatable").refresh();
753				}
754			}else if($(".datatable-container",$("body")).length > 0){
755				if($(".datatable-body .datatable",$("body")).data("minidatatable")){
756					$(".datatable-body .datatable",$("body")).data("minidatatable").refresh();
757				}
758			}
759		}
760		if(action.action == "download"){
761			if(action.url){
762				download(action.url);
763			}
764		}
765		if(action.action == "set"){
766			if($(action.id).length > 0 && action.content){
767				$(action.id).html(action.content);
768			}
769		}
770		if(action.action == "dli"){
771			if($(".css-grid").length > 0){
772				if(action["ids"]){
773					for(key in action["ids"]){
774						removeGridItem(id);
775					}
776					$(".grid").masonry( 'layout');
777				}else if(action["id"]){
778					removeGridItem(action.id);
779				}
780				
781				
782			}else{
783				if(action["ids"]){
784					for(key in action["ids"]){
785						var id = action["ids"][key];
786						$(".grid").masonry( 'remove', $("div#item_"+id) );
787						//removeListItem(id);
788					}
789					$(".grid").masonry( 'layout');
790				}else if(action["id"]){
791					removeListItem(action.id);
792				}
793			}
794		}
795		if(action.action == "rli"){
796			if($(".css-grid").length > 0){
797				refreshGridItems();
798			}else if($(".grid").length > 0){
799				refreshListItems();
800			}
801		}
802		if(action.action == "rit"){
803			refreshListItem(action.id,action.url);
804		}
805		if(action.action == "rcl"){
806			refreshReservations();
807		}
808		if(action.action == "rfi"){
809			if(action.object){
810				refreshFeedItem(action.id,action.object);
811			}else{
812				refreshFeedItem(action.id,action.url);
813			}
814		}
815		if(action.action == "afi"){
816			if(action.container){
817				addFeedItem(action.object,$(action.container));
818			}else{
819				addFeedItem(action.object,$("div.feed-table"));
820			}
821		}
822		
823		if(action.action == "loadcontent"){
824			//loadContent(action.url,action.target);
825		}
826		if(action.action == "opendialog"){
827			var data = action;
828			if(data["onload"]){
829				eval("data[\"onload\"] = "+data["onload"]);
830			}
831			if(data["onclose"]){
832				eval("data[\"onclose\"] = "+data["onclose"]);
833			}else{
834				eval("data[\"onclose\"] = closelistitem");
835			}
836			if(data["onbeforeload"]){
837				eval("data[\"onbeforeload\"] = "+data["onbeforeload"]);
838			}
839			data["container"] 	= ".dialog-container";
840			data["trigger"] 	=  form;
841			
842			var dialog = new Dialog(data);
843			dialog.open();
844			
845		}
846		if(action.action == "reloaddialog"){
847			if(dialog){
848				if(action.url){
849					dialog.reload(action.url);
850				}else if(action.html){
851					dialog.reloadhtml(action.html);
852				}
853			}else{
854				//loadContent(action.url,container);
855			}
856		}
857		if(action.action == "toast"){
858			var timeout = 2500;
859			var focus = null;
860			var cssclass=null;
861			if(action.timeout)
862				timeout = action.timeout;
863			if(action.focus)
864				focus = action.focus;
865			if(action.class)
866				cssclass=  action.class;
867			
868			showToast(action.content,timeout,focus,cssclass);
869		}
870		if(action.action == "feedback"){
871			$(".alert",form).remove();
872			if(action.type == "error" && action.content.indexOf("alert-danger") != -1){
873				msg = $(action.content);
874			}else{
875				if(action.type == "error")
876					action.type = "danger";
877				if(action.type == "confirm")
878					action.type = "success";
879				
880				msg = $("<div class='alert alert-"+action.type+"'>"+action.content+"</div>");
881			}
882			
883			form.removeClass("loading");
884			if($(".feedback-container",form).length > 0){
885				$(".feedback-container",form).html("");
886				$(".feedback-container",form).append(msg);
887			}else{
888				form.prepend(msg);
889			}
890			if(action.timeout){
891				setTimeout(function(){
892					msg.remove();
893				},action.timeout)
894			}
895			initMessage(msg);
896			initErrFields(container);
897			
898		}
899		if(action.action == "reloadhtml"){
900			if(dialog){
901				dialog.reloadhtml(action.html);
902			}
903		}
904		if(action.action == "runjs"){
905			if (typeof window[action.func] === "function") {
906				try{
907					window[action.func](container,action.args);
908				}catch(e){}
909			}
910		}
911		if(action.action == "redirect"){
912			window.location.href = action.url;
913		}
914		if(action.action == "introjs"){
915			if(action.url){
916				
917				$.get("/ltd/help/introjs/reservation",function(steps){
918					setTimeout(function(){
919						introJs().setOptions({
920							steps      		: 	steps,
921							showBullets		: 	false,
922							showProgress	: 	false,
923							showStepNumbers	:	false,
924							overlayOpacity	:	0.4,
925					     	nextLabel  	: 'Volgende &rarr;',
926					     	prevLabel  	: '&larr; Vorige',
927					     	skipLabel  	: 'OK',
928					     	doneLabel  	: 'OK'
929					    }).start();
930					},250);
931				},"json");
932			}
933		}
934	}
935}
936
937var preloadForm = function(form){
938	form.addClass("loading");
939}
940
941var initErrFields = function(form){
942	if($("input[name=errfields]",form).length > 0){
943		var fields = $("input[name=errfields]",form).val().split(";");
944		for(key in fields){
945			var fieldname = fields[key];
946			var field = false;
947			
948			if($("input[name="+fieldname+"]",form).length > 0){
949				field = $("input[name="+fieldname+"]",form);
950			}else if($("textarea[name="+fieldname+"]",form).length > 0){
951				field = $("textarea[name="+fieldname+"]",form);
952			}
953			
954			if(field){
955				field.addClass("error");
956				field.change(function(){
957					$(this).removeClass("error");
958				});
959			}
960			
961		}
962		
963	}
964}
965
966
967var	collectFormFields = function(form){
968	var ob = {};
969	var fieldnames = [];
970	$("input,select,textarea",form).each(function(){
971		if($(this).parents(".rte-toolbar").length > 0)
972			return;
973		if(!$(this).attr("name"))
974			return;
975		
976		var isArray		 = $(this).attr("name").indexOf("[]") != -1 ? true : false;
977		var fieldName 	 = $(this).attr("name");
978		var isMultiArray = false;
979		
980		if(isArray && $(this).attr("name").indexOf("[]") == $(this).attr("name").length - 2){
981			var fieldName 	= fieldName.replace("[]","");
982		}else if($(this).attr("name").indexOf("[][") > 0){
983			isMultiArray = true;
984			isArray = false;
985		}else{
986			
987			isArray = false;
988		}
989		var check		= $(this).is("input[type=checkbox]") ? true : false;
990		var radio		= $(this).is("input[type=radio]") ? true : false;
991		
992		if(fieldName){
993			var val = "";
994			if(check){
995				val = $(this).is(":checked")? $(this).attr("value") : '';
996			}else if(radio){
997				if($(this).is(":checked"))
998					val = $(this).attr("value");
999				else
1000					return;
1001			}else{
1002				val = $(this).val();
1003			}
1004			if(isArray){
1005				var vals = [];
1006				if(ob[fieldName])
1007					vals = ob[fieldName];
1008				vals[vals.length] = val;
1009				ob[fieldName] 	  = vals;
1010				
1011			}else if(isMultiArray){
1012				var cnt = 0;
1013				tmpname = fieldName.replace("[][","["+cnt+"][");
1014				while(array_contains(tmpname,fieldnames)){
1015					cnt++;
1016					tmpname = fieldName.replace("[][","["+cnt+"][");
1017				}
1018				fieldnames[fieldnames.length] = tmpname;
1019				ob[tmpname] = val;
1020			
1021			}else{
1022				ob[fieldName] = val;
1023			}
1024		}
1025	});
1026	return ob;
1027};
1028
1029var initToggleFields = function(container){
1030	
1031	$(".togglefield",container).each(function(){
1032		
1033		if($(this).attr("rel") && $(this).attr("opts")){
1034			var values 	=	$(this).attr("opts").split(",");
1035			var rel		=	$("#"+$(this).attr("rel"));
1036			var field	=	$(this);
1037			
1038			
1039			if(rel.length > 0){
1040				var checktogglefield = function(){
1041					if(rel.is("input[type=radio], input[type=checkbox]")){
1042						if(rel.is(":checked") && array_contains(rel.val(),values)){
1043							field.show();
1044							field.removeClass("d-none");
1045						}else{
1046							field.addClass("d-none");
1047							field.hide();
1048						}
1049					}else{
1050						if(array_contains(rel.val(),values)){
1051							field.show();
1052							field.removeClass("d-none");
1053						}else{
1054							field.hide();
1055							field.addClass("d-none");
1056						}	
1057					}
1058					
1059				};
1060				checktogglefield();
1061				if(rel.is("input[type=radio],input[type=checkbox]")){
1062					$("input[name="+rel.attr("name")+"]").bind("change",checktogglefield);
1063				}else{
1064					rel.bind("change",checktogglefield);
1065					rel.bind("blur",checktogglefield);
1066				}
1067			}else{
1068				var rel = $("input[name="+$(this).attr("rel")+"]");
1069				if(rel.length > 0){
1070					var checktogglefield = function(){
1071						var show = false;
1072						rel.each(function(){
1073							if($(this).is("input[type=radio],input[type=checkbox]")){
1074								if($(this).is(":checked") && array_contains($(this).val(),values)){
1075									show=true;
1076								}
1077							}else if(array_contains($(this).val(),values)){
1078								show=true;
1079							}
1080						});
1081						if(show){
1082							field.show();
1083							field.removeClass("d-none");
1084						}else{
1085							field.hide();
1086							field.addClass("d-none");
1087						}
1088					};
1089					checktogglefield();
1090					rel.each(function(){
1091						rel.bind("change",checktogglefield);
1092						rel.bind("blur",checktogglefield);
1093					});
1094					
1095				}
1096			}
1097		}
1098	});
1099}
1100
1101var array_contains = function(value,arr){
1102	for(i=0;i<arr.length;i++){
1103		if(value == arr[i]){
1104			return true;
1105		}
1106	}
1107	return false;
1108};
1109
1110var removeListItem = function(id){
1111	$(".grid").masonry( 'remove', $("div#item_"+id) );
1112	$(".grid").masonry( 'layout');
1113}
1114
1115var refreshListItem = function(id,url){
1116	$("div#item_"+id).addClass("refresh");
1117	$.get(url,function(html){
1118		
1119		$("div#item_"+id).html(html);
1120		
1121		initDialogLinks($("div#item_"+id));
1122		initTags($("div#item_"+id));
1123		initContextMenu($("div#item_"+id));
1124		initPinit($("div#item_"+id));
1125		
1126		setTimeout(function(){
1127			$("div#item_"+id).removeClass("refresh");
1128		},150);
1129	});
1130	
1131}
1132
1133var refreshReservations= function(){
1134	var current = $("#actionmenu #reservations");
1135	var url 	= $("#actionmenu input[name=clurl]").val();
1136	$.get(url,{},function(response){
1137		current.remove();
1138		if(response){
1139			var el = $(response);
1140			$("#actionmenu input[name=clurl]").after(el);
1141			initAjaxLinks(el);
1142		}
1143	});
1144	
1145}
1146
1147
1148var initLinkaLikes = function(container){
1149	$(".linkalike",container).click(function(e){
1150		if($(e.target).is("a") || $(e.target).parent(0).is("a")){
1151			return;
1152		}
1153		if($(this).data("target")){
1154			window.open($(this).data("href"),$(this).data("target"));
1155		}else{
1156			window.location.href = $(this).data("href");
1157		}
1158	});
1159}
1160
1161var initSelectable = function(container){
1162	$("article > .input-field label",container).on('click',function(){
1163		$(this).prev().prop("checked", !$(this).prev().prop("checked"));
1164		$(this).parents("article").removeClass("ignoreclick");
1165		return false;
1166	});
1167	$("article > .input-field label",container).on('mousedown',function(){
1168		$(this).parents("article").addClass("ignoreclick");
1169	});
1170}
1171
1172var beforeDeleteArticles = function(dialog){
1173	var params = collectFormFields($(".grid"));
1174	dialog.setparams(params);
1175}
1176
1177var initSticky = function(container){
1178	$("label.article-sticky, label.shop-love",container).click(function(e){
1179		$("input[type='checkbox']",$(this)).prop('checked', ($("input[type='checkbox']",$(this)).is(":checked")?false:true));
1180		var url = $(this).data("url")+"/"+($("input[type='checkbox']",$(this)).is(":checked")?1:0);
1181		$.get(url);
1182		return false;
1183	});
1184}
1185
1186
1187var initClipboard = function(container){
1188	$(".clipboard",$(".grid")).on('click',function(){
1189		$(this).parents("article").removeClass("ignoreclick");
1190		return false;
1191	});
1192	$(".clipboard",$(".grid")).on('touchstart',function(){
1193		$(this).parents("article").addClass("ignoreclick");
1194	});
1195	$(".clipboard",$(".grid")).on('mousedown',function(){
1196		$(this).parents("article").addClass("ignoreclick");
1197	});
1198	$(".clipboard",$(".grid")).each(function(){
1199		var clipboard = new Clipboard($(this).get(0));
1200		clipboard.on('success', function(e) {
1201			showToast($(e.trigger).data("feedback"),2500,null,null);
1202			e.clearSelection();
1203			return false;
1204		});
1205	});
1206}
1207
1208var initPinit = function(container){
1209
1210	if($(".article-trigger",container).length > 0){
1211		
1212		$(".article",container).on("mousedown touchstart",function(e){
1213			if(!$(e.target).is(".article-sticky")
1214					&&  $(e.target).parents(".dropdown").length == 0 
1215						&& $(e.target).parents(".selector").length == 0 
1216							&& $(e.target).parents(".article-tags").length == 0){
1217				
1218				$(this).on("mouseout touchend",function(e){
1219					$(this).removeClass("active");
1220					$(this).off("mouseout touchend");
1221				});
1222				$(this).addClass("active");
1223			}
1224		});
1225		$(".article",container).on("click",function(e){
1226			if(!$(e.target).is(".reallink") 
1227					&& $(e.target).parents(".selector").length == 0 ){
1228				$(this).off("mouseout touchend");
1229				$(".article-trigger",$(this)).trigger("click");
1230				$(this).removeClass("active");
1231			}else{
1232				return true;
1233			}
1234		});
1235	}
1236	return;
1237	
1238	$(".pinit",container).on('click',function(){
1239		$(this).parents("article").removeClass("ignoreclick");
1240		return false;
1241	});
1242	$(".pinit",container).on('mousedown ',function(){
1243		$(this).parents("article").addClass("ignoreclick");
1244	});
1245	
1246	$(".pinit",container).click(function(e){
1247		
1248		var ctr = $(this).parents("article");
1249		var url		 	= $(this).attr("href");
1250		var media 		= $(".image > img",ctr).attr("src");
1251		var description = encodeURI($("header",ctr).text()+" | Lijstjestijd");
1252			
1253		var pin_url = 'http://pinterest.com/pin/create/button/?url=' + url +
1254	    	'&media=' + media +
1255	    	'&description=' + description;
1256		$("<a>").attr("href", pin_url).attr("target", "_blank")[0].click();
1257		return false;
1258	});
1259}
1260
1261
1262var busy = false;
1263var initLists = function(){
1264	var form = $(".ltd-grid form");
1265	
1266	var ctr = form;
1267	if($(".fw-panel").length > 0){
1268		ctr = $(".fw-panel");
1269	}
1270	
1271	$("input[name=search]").on("focus",function(){
1272		$("input[name=search]").data("lastval",$(this).val());
1273	});
1274	$("input[name=search]").on("blur",function(){
1275		if($(this).val() != $(this).data("lastval")){
1276			refreshListItems();
1277		}
1278		
1279		if($(this).hasClass("autogrow") && $(this).val())
1280			$(this).addClass("notempty")
1281		else
1282			$(this).removeClass("notempty")
1283				
1284		
1285	});
1286	$("input[name=search]").on("keydown",function(e){
1287		$("input[name=search]").not(this).val($(this).val());
1288		
1289		
1290		if($(this).hasClass("autogrow") && $(this).val())
1291			$(this).addClass("notempty")
1292		else
1293			$(this).removeClass("notempty")
1294				
1295		
1296		if(e.keyCode == "13"){
1297			if($(this).val() != $(this).data("lastval")){
1298				$(this).data("lastval",$(this).val());
1299				refreshListItems();
1300			}
1301			return false;
1302		}else if(e.keyCode == "27"){
1303			$(this).val("");
1304			$(this).blur();
1305			return false;
1306		}
1307	});
1308	if($("nav.filter").length > 0){
1309		
1310		$("span.badge",$("nav.filter")).click(function(e){
1311			rel = $(this).attr("rel");
1312			$('body').find("span[rel='"+rel+"']").remove();
1313			refreshListItems();
1314		});
1315	}
1316	
1317	$("input[name=sortby]").on("change",function(){
1318		refreshListItems();
1319	});
1320	$("button[name='btn-filter']",ctr).click(refreshListItems);
1321    
1322	if($("label#btn-select-all",ctr).length > 0){
1323	   $("label#btn-select-all",ctr).click(function(){
1324		   checks = $(".selector > input[type=checkbox]",$(".grid"));
1325		   checks.prop("checked", !checks.prop("checked"));
1326	   });
1327    }
1328	
1329	if($(".grid").length > 0){
1330	    initTags($(".grid"));
1331	    initLinkaLikes($(".grid"));
1332		initPinit($(".grid"));
1333		initSelectable($(".grid"));
1334		initClipboard($(".grid"));
1335		initSticky($(".grid"));
1336		
1337		/**START PRELOADING **/
1338		$(".grid").after("<div class='gridloader'></div>");
1339		var count = 1;
1340		
1341		
1342		$(".mylist-item",$(".grid")).each(function(){
1343			$box = $(this);
1344			if(count > 0){
1345				$(".gridloader").append($box);
1346			}else{
1347				$box.imagesLoaded(function(instance){
1348					$mbox = $(instance.elements[0]);
1349					$(".grid").masonry( 'appended', $mbox );
1350					$mbox.removeClass("init");
1351				});
1352			}
1353			count++;
1354		});
1355		/**START MASONRY**/
1356		$(".grid").masonry({
1357			  itemSelector	: '.mylist-item',
1358			  columnWidth	: '.mylist-sizer',
1359			  isAnimated	:	false,
1360			  animationOptions: {
1361				    duration: 750,
1362				    easing: 'linear',
1363				    queue: false
1364			  }
1365		});
1366		
1367		
1368		
1369		
1370		var init = 0;
1371		$(".grid").imagesLoaded(function(){
1372			$(".grid").masonry( 'layout');
1373		});
1374		
1375		//$(".mylist-item",$container).addClass($(".mylist-sizer").attr("class").replace("mylist-sizer",""));
1376		$(".mylist-item",$(".grid,.gridloader")).addClass($(".mylist-sizer").attr("class").replace("mylist-sizer",""));
1377		
1378		$(".grid").masonry().on('layoutComplete',function(){
1379        	$(".grid").removeClass("loading");
1380        	if(init == 0){
1381        		loadInitial();
1382        	}
1383        	init++;
1384        });
1385		/** LOAD INITIAL **/
1386		
1387		var loadInitial = function(){
1388			
1389			var $container = $(".gridloader");
1390			$boxes = $(".mylist-item",$container);
1391			var time = 100;
1392			$boxes.each(function(){
1393				var $box = $(this);
1394				$box.addClass("init");
1395				setTimeout( function(){	
1396					$(".grid").append($box);
1397					$box.imagesLoaded(function(instance){
1398						$mbox = $(instance.elements[0]);
1399						$(".grid").masonry( 'appended', $mbox );
1400						$mbox.removeClass("init");
1401					});
1402				},time);
1403				time += 50;
1404			});
1405		}
1406		
1407
1408   }
1409	
1410	var scroll = $("div.grid");
1411	initscrollpage();
1412}
1413
1414
1415var loadListItems = function(){
1416	var form = $(".ltd-grid form");
1417	
1418	
1419	var params = collectFormFields($("body"));
1420		params["offset"] = $("div.grid > div:not(.mylist-sizer)").length;
1421		
1422	if(busy || ($(".gridloader").length > 0 && $(".mylist-item",$(".gridloader")).length > 0)){
1423		//still loading PREV PAGE
1424		//console.log(params);
1425		return false;
1426	}else{
1427		busy = true;
1428		$(".grid").addClass("loading");
1429		
1430		if (typeof ga == "function") {
1431			url = getUrlPath(form.attr("action"))+"?offset="+params["offset"];
1432			ga('send', 'pageview', url);
1433		}
1434		
1435		$.post(form.attr("action"), params, function(resp){
1436			var $container = $("<div>"+resp+"</div>");
1437			if($(".mylist-item",$container).length == 0){
1438				$(".grid").removeClass("loading");
1439				LOADING_DONE = true;
1440				busy = false;
1441				return true;
1442			}else if($(".listinfo",$container).length > 0){
1443				if(params["offset"] > 0){
1444					$(".grid").removeClass("loading");
1445					busy = false;
1446					return true;
1447				}
1448			}
1449			
1450			$(".mylist-item",$container).addClass("init");
1451			
1452			initDialogLinks($container);
1453			initTags($container);
1454			initLinkaLikes($container);
1455			initPinit($container);
1456			initSelectable($container);
1457			initClipboard($container);
1458			initSticky($container);
1459			initContextMenu($container);
1460			
1461			
1462			$boxes = $(".mylist-item",$container);
1463			$(".grid").removeClass("loading");
1464			var time = 100;
1465			$boxes.each(function(){
1466				var $box = $(this);
1467				if($("#"+$box.attr("id"),$(".grid")).length == 0){
1468					setTimeout( function(){	
1469						$(".grid").append($box);
1470						$box.imagesLoaded(function(instance){
1471							$mbox = $(instance.elements[0]);
1472							$(".grid").masonry( 'appended', $mbox );
1473							$mbox.removeClass("init");
1474						});
1475						if($(".mylist-item",$container).length == 0){
1476							busy = false;
1477						}
1478					},time);
1479				}else{
1480					/*console.log("exists");
1481					console.log($box);*/
1482					$box.remove();
1483				}
1484				time += 100;
1485			});
1486		 });
1487		 return true;
1488	}
1489}
1490
1491var refreshListItems = function(){
1492	if(busy){
1493		showToast("Even geduld...",2500,null,null);
1494		return false;
1495	}
1496	LOADING_DONE = false;
1497	
1498	$(".grid").addClass("loading");
1499	//keep the fixable stuff
1500	$('html, body').scrollTop(150);
1501	
1502	$(".grid").masonry( 'remove', $("div.grid > *:not(.mylist-sizer)")).masonry( 'layout');
1503    $("div.grid > *:not(.mylist-sizer)").remove();
1504    $(".grid").masonry();
1505    
1506    /** DOIT **/
1507    loadListItems();
1508}
1509
1510var LOADING_DONE = false;
1511var initscrollpage = function(){
1512	$.scrollPaging({
1513		$viewport		: $(window),
1514		$scrollable		: $(document),
1515		additive		: 1000,
1516		getPage			: function(scrollPaging) {
1517			if(LOADING_DONE == false){
1518				if(loadListItems()){
1519					scrollPaging.page = scrollPaging.page+1;
1520				}
1521				scrollPaging.page++;
1522			}
1523		 }
1524	 });
1525}
1526
1527var initTags	  = function(container){
1528	$("nav > a",container).on("mousedown",function(e){
1529		$(this).parents("article").addClass("ignoreclick disabled");
1530	});
1531	$("nav > a",container).on("mouseup",function(e){
1532		var a = $(this);
1533		setTimeout(function(){
1534			a.parents("article").removeClass("ignoreclick disabled");
1535		},250);
1536	});
1537	
1538	
1539	$("a.tag",container).on("mousedown",function(e){
1540		$(this).parents("article").addClass("ignoreclick");
1541	});
1542	$("a.tag",container).on("mouseup",function(e){
1543		$(this).parents("article").removeClass("ignoreclick");
1544	});
1545	$("a.tag",container).click(function(e){
1546		$("body nav.filter").html();
1547		var tagfilter = $("<span class='badge badge-light my-auto mr-2' rel='"+$(this).text().replace(" ","")+"'><input type='hidden' name='filter[tags][]' value='"+$(this).text()+"'/>"+$(this).text()+"<i class='reset fa text-danger ml-2 fa-close'></i></span>");
1548		$("body nav.filter").append(tagfilter);
1549		
1550		
1551		$("span.badge",$("nav.filter")).off("click");
1552		$("span.badge",$("nav.filter")).on("click",function(e){
1553			if($(e.target).is("i"))
1554				rel = $(e.target).parent(0).attr("rel");
1555			else
1556				rel = $(e.target).attr("rel");
1557			
1558			$('body').find("span[rel='"+rel+"']").remove();
1559			
1560			//$(this).remove();
1561			refreshListItems();
1562		});
1563		/*$(tagfilter).click(function(e){
1564			if($(e.target).is("i"))
1565				rel = $(e.target).parent(0).attr("rel");
1566			else
1567				rel = $(e.target).attr("rel");
1568			
1569			console.log("go");
1570			
1571			$('body').find("span[rel='"+rel+"']").remove();
1572			refreshListItems();
1573		});*/
1574		refreshListItems();
1575		return false;
1576	});
1577}
1578var initConfirmLinks = function(container){
1579	$(".confirm-link, .confirmlink",container).off("click");
1580	$(".confirm-link, .confirmlink",container).on("click",function(){
1581		var el = $(this);
1582		bootbox.confirm({
1583		    message: el.data("message"),
1584		    centerVertical: true,
1585		    buttons: {
1586		        confirm: {
1587		            label: el.data("yes"),
1588		            className: 'btn-success btn-sm'
1589		        },
1590		        cancel: {
1591		            label: el.data("no"),
1592		            className: 'btn-danger btn-sm '
1593		        }
1594		    },
1595		    callback: function (result) {
1596		    	if(result == true){
1597		    		$.post(el.attr("href"),{confirm:true},function(rsp){
1598		    			parseFormResponse(rsp,container);
1599		    		},"json");
1600		    	}
1601		    }
1602		});
1603		
1604		return false;
1605	});
1606}
1607
1608var initAjaxLinks = function(container){
1609	
1610	$(".ajax-link",container).click(function(){
1611		var url = $(this).is("a")?$(this).attr("href"):$(this).data("href");
1612		
1613		if($.isFunction("ga")){
1614			ga('send', 'pageview', getUrlPath(url));
1615		}
1616		
1617		
1618		$.get(url,function(rsp){
1619			parseFormResponse(rsp,container);
1620		},"json");
1621		
1622		if($(this).parents(".dropdown").length > 0){
1623			$(".dropdown-toggle",$(this).parents(".dropdown")).dropdown("toggle");
1624		}
1625		
1626		if($(this).is("a"))
1627			return false;
1628		
1629		return true;
1630	});
1631}
1632var initFncLinks = function(container){
1633	
1634	
1635	$(".fnc-link, .fnclink",container).on("click",function(){
1636		if($(this).data("fnc")){
1637			var fn = window[$(this).data("fnc")];
1638			if(typeof fn === 'function') {
1639				fn($(this));
1640			}
1641		}
1642		return false;
1643	});
1644}
1645
1646var getUrlPath = function(url){
1647	 var l = document.createElement("a");
1648	 l.href = url;
1649	 return l.pathname;
1650}
1651var initFileDrop = function(container){
1652		$(".filedrop",container).each(function(){
1653			var dropbox = $(this);
1654			if($(this).is("a")){
1655				url = $(this).attr("href");
1656			}else{
1657				url = $(this).data("href");
1658			}
1659			
1660			dropbox.filedrop({
1661				url				:	url,
1662				paramname		:	'dropped',	
1663				maxfiles		:	1,
1664				maxfilesize		:	8,
1665				uploadFinished	:	function(i,file,response){
1666					$("i.fa-spinner",dropbox).remove();
1667					dropbox.removeClass("dropped");
1668					parseFormResponse(response,dropbox);
1669					
1670				},
1671				drop			:	function(){
1672					dropbox.removeClass("hoverdrop");
1673					dropbox.addClass("dropped");
1674					$("span",dropbox).prepend("<i class='fa fa-spinner fa-pulse fa-3x fa-fw margin-bottom'></i>");
1675				},
1676				dragEnter		:	function(){
1677					dropbox.addClass("hoverdrop");
1678				},
1679				dragLeave		:	function(){
1680					dropbox.removeClass("hoverdrop");
1681				},
1682				error: function(err, file) {
1683					switch(err) {
1684						case 'BrowserNotSupported':
1685							alert('Your browser does not support HTML5 file uploads!');
1686							break;
1687					}
1688					$("i.fa-spinner",dropbox).remove();
1689					dropbox.removeClass("dropped");
1690				}
1691			});
1692			
1693			
1694		});
1695		return false;
1696		var dropbox = $('#dropbox'),
1697			message = $('.message', dropbox);
1698		
1699		dropbox.filedrop({
1700			// The name of the $_FILES entry:
1701			paramname:'pic',
1702			
1703			maxfiles	: 5,
1704	    	maxfilesize	: 8,
1705			url: 'post_file.php',
1706			
1707			uploadFinished:function(i,file,response){
1708				$.data(file).addClass('done');
1709				// response is the JSON object that post_file.php returns
1710			},
1711			
1712	    	error: function(err, file) {
1713				switch(err) {
1714					case 'BrowserNotSupported':
1715						showMessage('Your browser does not support HTML5 file uploads!');
1716						break;
1717					case 'TooManyFiles':
1718						alert('Too many files! Please select 5 at most! (configurable)');
1719						break;
1720					case 'FileTooLarge':
1721						alert(file.name+' is too large! Please upload files up to 2mb (configurable).');
1722						break;
1723					default:
1724						break;
1725				}
1726			},
1727			
1728			// Called before each upload is started
1729			beforeEach: function(file){
1730				if(!file.type.match(/^image\//)){
1731					alert('Only images are allowed!');
1732					
1733					// Returning false will cause the
1734					// file to be rejected
1735					return false;
1736				}
1737			},
1738			
1739			uploadStarted:function(i, file, len){
1740				createImage(file);
1741			},
1742			
1743			progressUpdated: function(i, file, progress) {
1744				$.data(file).find('.progress').width(progress);
1745			}
1746	    	 
1747		});
1748		
1749		var template = '<div class="preview">'+
1750							'<span class="imageHolder">'+
1751								'<img />'+
1752								'<span class="uploaded"></span>'+
1753							'</span>'+
1754							'<div class="progressHolder">'+
1755								'<div class="progress"></div>'+
1756							'</div>'+
1757						'</div>'; 
1758		
1759		
1760		function createImage(file){
1761
1762			var preview = $(template), 
1763				image = $('img', preview);
1764				
1765			var reader = new FileReader();
1766			
1767			image.width = 100;
1768			image.height = 100;
1769			
1770			reader.onload = function(e){
1771				
1772				// e.target.result holds the DataURL which
1773				// can be used as a source of the image:
1774				
1775				image.attr('src',e.target.result);
1776			};
1777			
1778			// Reading the file as a DataURL. When finished,
1779			// this will trigger the onload function above:
1780			reader.readAsDataURL(file);
1781			
1782			message.hide();
1783			preview.appendTo(dropbox);
1784			
1785			// Associating a preview container
1786			// with the file, using jQuery's $.data():
1787			
1788			$.data(file,preview);
1789		}
1790
1791		function showMessage(msg){
1792			message.html(msg);
1793		}
1794
1795}
1796var s = e = 0;
1797var startdebug = function(){
1798	s = new Date().getTime();
1799	console.time("concatenation");
1800}
1801var enddebug = function(){
1802	e = new Date().getTime();
1803	console.log(e - s);
1804	console.timeEnd("concatenation");
1805}
1806
1807
1808var scrollTo = function(href){
1809	console.log($(href));
1810	if($(href).length > 0){
1811		if($.isFunction(ga)){
1812			ga('send', 'pageview', href);
1813		}
1814		noscroll = true;
1815		
1816		$('html, body').animate({
1817	        scrollTop	:	$(href).offset().top
1818	    }, 500,function (x, t, b, c, d) {
1819			return -c *(t/=d)*(t-2) + b;
1820		});
1821		setTimeout(function(){
1822			noscroll = false;
1823		},500);
1824	}else{
1825		return false;
1826	}
1827}
1828
1829
1830var initMessage = function(msg){
1831	$(".message-close",msg).click(function(){
1832		msg.addClass("animated bounceOutUp");
1833			setTimeout(function(){
1834				msg.remove();
1835			},1000);
1836		return false;
1837	});
1838	setTimeout(function(){
1839		if($(".message-close",msg).length > 0){
1840			$(".message-close",msg).trigger("click");
1841		}
1842	},2500);
1843}
1844var showToast = function(content, timer, focus, cssclass){
1845	if(timer == null){
1846		timer = 2500;
1847	}
1848	var toast = $("<div class='toast'>"+content+"</div>");
1849	if(cssclass != null)
1850		toast.addClass(cssclass);
1851		
1852	if(focus != -1 && focus != null){
1853		$(focus).after(toast);
1854	}else{
1855		$("body").append(toast);
1856	}
1857	
1858	
1859	if(timer == "click"){
1860		$(".dismiss",toast).on("click",function(){
1861			toast.remove();
1862			return false;
1863		});
1864	}else{
1865		setTimeout(function(){
1866			toast.remove();
1867		},timer);
1868	}
1869}
1870var initMailPreview = function(){
1871	$("textarea[name=content]").on("keyup",function(){
1872		var content = $(this).val();
1873		 $('#mailpreview').contents().find('body p.user-content').html(content.replace(/(?:\r\n|\r|\n)/g, '<br />'));
1874		
1875	});
1876}
1877
1878/*
1879var initNotifications = function(){
1880	var form = $("form.notifications");
1881	var page = 1;
1882	var initNewNotifications = function(slide){
1883		var container = $("form.notifications > .timeline");
1884		$(".timeline-icon",slide).on("click",function(e){
1885			
1886			var parent = $(this).parents(".list-line");
1887			if(!parent.hasClass("static")){
1888				if($("input[name=removable]").is(":checked")){
1889					$.get($(this).parent(0).data("remove"));
1890					
1891					parent.addClass("animated slideOutLeft");
1892					setTimeout(function(){
1893						parent.remove();
1894						container.height(slide.height());
1895					},750);
1896					return false;
1897				}
1898			}
1899			
1900			return true;
1901		});
1902	}
1903	
1904	var lp = 0;
1905	var loadNotifications = function(page){
1906		var container = $("form.notifications > .timeline");
1907		
1908		var params ={};
1909		params["page"] 		 = page;
1910		params["perpage"] 	 = 5;
1911		params["sortfield"]  = "created";
1912		params["sortorder"]  = "desc";
1913		$.post(form.attr("action"),params,function(resp){
1914			
1915			var newslide = $(resp);
1916			var count = 1;
1917			$("nav.paging",container).fadeOut(function(){
1918				$(this).remove();
1919			});
1920			
1921			var slide = $(".slide",container);
1922			if(slide.length > 0){
1923				if(lp > page)
1924					slide.addClass("animated slideOutRight");
1925				else
1926					slide.addClass("animated slideOutLeft");
1927				
1928				setTimeout(function(){
1929					slide.remove();
1930					
1931					if(lp > page)
1932						newslide.addClass("animated slideInLeft");
1933					else
1934						newslide.addClass("animated slideInRight");
1935							
1936					container.append(newslide);
1937					initDialogLinks(newslide);
1938					initAjaxLinks(newslide);
1939					initNewNotifications(newslide);
1940					
1941					$("nav.paging a.next",container).click(function(){
1942						loadNotifications(page+1);
1943						return false;
1944					});
1945					$("nav.paging a.prev",container).click(function(){
1946						loadNotifications(page-1);
1947						return false;
1948					});
1949					
1950					container.height(newslide.height());
1951					
1952				},500);
1953			}else{
1954				container.append(newslide);
1955				initDialogLinks(newslide);
1956				initAjaxLinks(newslide);
1957				initNewNotifications(newslide);
1958				
1959				$("nav.paging a.next",container).click(function(){
1960					loadNotifications(page+1);
1961					return false;
1962				});
1963				$("nav.paging a.prev",container).click(function(){
1964					loadNotifications(page-1);
1965					return false;
1966				});
1967				
1968				container.height(newslide.height());
1969			}
1970			lp = page;
1971
1972			
1973		});
1974	}
1975	loadNotifications(1);	
1976}*/
1977
1978var initRemoveTableLine = function(slide){
1979	var form = $("form.alt-table");
1980	var page = 1;
1981	
1982	var container = slide.parents("form.alt-table");
1983	var input	  = $("input[name=removable]",container.parent(0));
1984	if(input.length == 0)
1985		return false;
1986	
1987	$(".timeline-icon",slide).on("click",function(e){
1988		var parent = $(this).parents(".list-line");
1989		if(!parent.hasClass("static")){
1990			
1991			if(input.is(":checked")){
1992				$.get(parent.data("remove"));
1993				parent.addClass("animated slideOutLeft");
1994				
1995				setTimeout(function(){
1996					parent.remove();
1997					container.height(slide.height());
1998				},750);
1999				return false;
2000			}
2001		}
2002		return true;
2003	});
2004}
2005
2006var initAltTables = function(form){
2007	var container 	= $("div:first-child",form);
2008	
2009	var page = 1;
2010	var lp = 0;
2011	var perpage = form.data("perpage")?form.data("perpage"):5;
2012	
2013	var loadItems = function(page){
2014		var params ={};
2015		params["page"] 		 = page;
2016		params["perpage"] 	 = perpage;
2017		params["sortfield"]  = "created";
2018		params["sortorder"]  = "desc";
2019	
2020		
2021		$.post(form.attr("action"),params,function(resp){
2022			var newslide = $(resp);
2023			var count = 1;
2024			$("nav.paging",container).fadeOut(function(){
2025				$(this).remove();
2026			});
2027			var slide = $(".slide",container);
2028			
2029			if(slide.length > 0){
2030				if(lp > page)
2031					slide.addClass("animated slideOutRight");
2032				else
2033					slide.addClass("animated slideOutLeft");
2034				
2035				setTimeout(function(){
2036					slide.remove();
2037					
2038					if(lp > page)
2039						newslide.addClass("animated slideInLeft");
2040					else
2041						newslide.addClass("animated slideInRight");
2042							
2043					container.append(newslide);
2044					initDialogLinks(newslide);
2045					initAjaxLinks(newslide);
2046					initRemoveTableLine(newslide);
2047					
2048					$("nav.paging a.next",container).click(function(){
2049						loadItems(page+1);
2050						return false;
2051					});
2052					$("nav.paging a.prev",container).click(function(){
2053						loadItems(page-1);
2054						return false;
2055					});
2056					container.height(newslide.outerHeight());
2057					if(newslide.next().length > 0){
2058						container.height(container.height() + newslide.next().outerHeight());
2059					}
2060					
2061				},500);
2062			}else{
2063				container.append(newslide);
2064				initDialogLinks(newslide);
2065				initAjaxLinks(newslide);
2066				initRemoveTableLine(newslide);
2067				
2068				$("nav.paging a.next",container).click(function(){
2069					loadItems(page+1);
2070					return false;
2071				});
2072				$("nav.paging a.prev",container).click(function(){
2073					loadItems(page-1);
2074					return false;
2075				});
2076				container.height(newslide.outerHeight());
2077				if(newslide.next().length > 0){
2078					container.height(container.height() + newslide.next().outerHeight());
2079				}
2080			}
2081			lp = page;
2082		});
2083	}
2084	loadItems(1);
2085}
2086
2087
2088var initReservations = function(){
2089	var form = $("form.reservations");
2090	var container = $("form.reservations > div");
2091	var page = 1;
2092	
2093	var lp = 0;
2094	
2095	
2096	var loadReservations = function(page){
2097		var params ={};
2098		params["page"] 		 = page;
2099		if(container.width() > 1200){
2100			params["perpage"] 	 = 21;
2101		}else if(container.width() > 524){
2102			params["perpage"] 	 = 14;
2103		}else{
2104			params["perpage"] 	 = 10;
2105		}
2106		params["sortfield"]  = "created";
2107		params["sortorder"]  = "desc";
2108	
2109		
2110		$.post(form.attr("action"),params,function(resp){
2111			
2112			var newslide = $(resp);
2113			var count = 1;
2114			$("nav.paging",container).fadeOut(function(){
2115				$(this).remove();
2116			});
2117			
2118			var slide = $(".slide",container);
2119			if(slide.length > 0){
2120				if(lp > page)
2121					slide.addClass("animated slideOutRight");
2122				else
2123					slide.addClass("animated slideOutLeft");
2124
2125				setTimeout(function(){
2126					slide.remove();
2127					
2128					if(lp > page)
2129						newslide.addClass("animated slideInLeft");
2130					else
2131						newslide.addClass("animated slideInRight");
2132							
2133					container.append(newslide);
2134					initDialogLinks(newslide);
2135					initAjaxLinks(newslide);
2136					//initContextMenu(newslide);
2137					
2138					$("nav.paging a.next",container).click(function(){
2139						loadReservations(page+1);
2140						return false;
2141					});
2142					$("nav.paging a.prev",container).click(function(){
2143						loadReservations(page-1);
2144						return false;
2145					});
2146					
2147					container.height(newslide.height());
2148					
2149				},500);
2150			}else{
2151				container.append(newslide);
2152				initDialogLinks(newslide);
2153				initAjaxLinks(newslide);
2154				//initContextMenu(newslide);
2155				
2156				$("nav.paging a.next",container).click(function(){
2157					loadReservations(page+1);
2158					return false;
2159				});
2160				$("nav.paging a.prev",container).click(function(){
2161					loadReservations(page-1);
2162					return false;
2163				});
2164				if($(".list-line",newslide).length > 0){
2165					container.height(newslide.height());
2166				}
2167			}
2168			lp = page;
2169		});
2170	}
2171	loadReservations(1);
2172}
2173
2174var initCharts = function(){
2175	$(".morris-plot").each(function(){
2176		try{
2177			if($(this).data("plottype") == "line"){
2178				new Morris.Line({
2179					  element	: $(this).attr("id"),
2180					  data		: $(this).data("json"),
2181					  xkey		: $(this).data("x"),
2182					  ykeys		: $(this).data("y"),
2183					  labels	: $(this).data("l"),
2184					  lineColors: $(this).data("lc"),
2185					  parseTime	:	false,
2186					  resize: true
2187				});
2188			}else if($(this).data("plottype") == "area"){
2189				new Morris.Area({
2190					  element	: $(this).attr("id"),
2191					  data		: $(this).data("json"),
2192					  xkey		: $(this).data("x"),
2193					  ykeys		: $(this).data("y"),
2194					  labels	: $(this).data("l"),
2195					  lineColors: $(this).data("lines"),
2196					  parseTime	:	false,
2197					  resize: true
2198				});
2199				
2200			}else if($(this).data("plottype") == "donut"){
2201				new Morris.Donut({
2202					  element	: $(this).attr("id"),
2203					  data		: $(this).data("json"),
2204					  colors	: ["#60A89A","#80b9ae","#a0cbc2","#bfdcd7","#dfeeeb"],
2205					  resize: true
2206				});
2207				
2208			}
2209		}catch(e){
2210			console.log(e);
2211		}
2212	});
2213}
2214var initCopyClipboard = function(ctr){
2215	if($(".clipboard",ctr).length > 0){
2216		var clipboard = new Clipboard('.clipboard');
2217		clipboard.on('success', function(e) {
2218			
2219			if($(e.trigger).data("feedback")){
2220				showToast($(e.trigger).data("feedback"),2500,-1,null);
2221			}
2222			e.clearSelection();
2223		    
2224		    if($(e.trigger).parents(".dropdown").length > 0){
2225				$(".dropdown-toggle",$(e.trigger).parents(".dropdown")).dropdown("toggle");
2226			}
2227		    return false;
2228		});
2229	}
2230}
2231var initDialogListIt = function(dialog){
2232	
2233	$("a.listit, .closeit",dialog).on("click",function(e){
2234		
2235		dialog.toggleClass("listit");
2236		dialog.on("click",function(e){
2237			if($(e.target).parents(".linklists").length > 0){
2238				return;
2239			}
2240			dialog.toggleClass("listit");
2241			dialog.off("click");
2242		});
2243		return false;
2244	});
2245	//console.log($("input[name='searchlist']",dialog));
2246	$("input[name='searchlist']",dialog).on("keyup",function(e){
2247		var searchval = $(this).val();
2248		$(".lists a",dialog).each(function(){
2249			if($(this).text().toLowerCase().includes(searchval.toLowerCase())){
2250				$(this).removeClass("d-none").addClass("d-flex");
2251			}else{
2252				$(this).removeClass("d-flex").addClass("d-none");
2253			}
2254		});
2255	});
2256}
2257
2258var initCarousel = function(ctr){
2259	
2260	
2261	
2262	$(".carousel-multi").each(function(){
2263		
2264		var carousel = $(this);
2265		var nr	    = 4;
2266   		var current = 1;
2267   		var ml      = 0;
2268   			
2269       	var setBSNr = function(){
2270        	var ww	   = $(window).outerWidth();
2271	    	if(ww <= 576){
2272				ml = 100;
2273			}else if(ww > 576 && ww <= 768){
2274				ml = carousel.data("sm")?(100/carousel.data("sm")):50
2275	    	}else if(ww > 768 && ww <= 992) {
2276				ml = carousel.data("md")?(100/carousel.data("md")):33.3
2277	    	}else if(ww > 992 && ww <= 1200){
2278	    		ml = carousel.data("lg")?(100/carousel.data("lg")):25;
2279	      	}else if(ww > 1200){
2280	      		ml = carousel.data("xl")?(100/carousel.data("xl")):16.6;
2281	      	}
2282	    }
2283       	
2284       	$(window).on("resize",function(){
2285       		var curml = ml;
2286       		setBSNr();
2287       		if(curml != ml)
2288       			carousel.carousel(0);
2289       		if(carousel.data("ctr"))
2290       			$(carousel.data("ctr")).css("padding-bottom",carousel.outerHeight());
2291       		
2292       		
2293       	});
2294       	
2295       	setBSNr();
2296       	$('.carousel-control-prev',carousel).hide();
2297       	var fel = $(".carousel-item:first-child",carousel);
2298       	if(carousel.data("ctr"))
2299   			$(carousel.data("ctr")).css("padding-bottom",carousel.outerHeight());
2300
2301       	var setBSMargin = function(nextindex){
2302	        var items = Math.floor(100 / ml);
2303	        var i = $(".carousel-item",carousel).index($(".carousel-item.active",carousel))+1;
2304	        var nextindex;
2305	       	var ol = nextindex * ml;
2306	        fel.css("margin-left",-(ol)+"%");
2307	        var st = $(".active",carousel);
2308	        for(i=0;i<items;i++){
2309	            st = st.next();
2310	            if(st.length == 0)
2311	            	continue;
2312	        }
2313			if(st.length > 0 && st.next().length > 0){
2314				$('.carousel-control-next',carousel).show();
2315           	}else{
2316           		carousel.carousel('pause');
2317			   	$('.carousel-control-next',carousel).hide();
2318           }
2319           if(nextindex == 0){
2320               	$('.carousel-control-prev',carousel).hide();
2321           }else{
2322                $('.carousel-control-prev',carousel).show();
2323           }
2324           			
2325       	}
2326       	carousel.on('slide.bs.carousel', function (e) {
2327				setBSMargin(e.to);
2328		});
2329       	carousel.on('slid.bs.carousel', function (e) {
2330			return false;
2331		});
2332	});
2333	
2334	
2335	
2336	/*
2337	
2338	
2339	
2340	
2341	
2342	$('.carousel-multi').on('slide.bs.carousel', function (e) {
2343		
2344	    var $e = $(e.relatedTarget);
2345	    var idx = $e.index();
2346	    var itemsPerSlide = 5;
2347	    var totalItems = $('.carousel-item').length;
2348	 
2349	    if (idx >= totalItems-(itemsPerSlide-1)) {
2350	        var it = itemsPerSlide - (totalItems - idx);
2351	        for (var i=0; i<it; i++) {
2352	            // append slides to end
2353	            if (e.direction=="left") {
2354	                $('.carousel-item').eq(i).appendTo('.carousel-inner');
2355	            }
2356	            else {
2357	                $('.carousel-item').eq(0).appendTo('.carousel-inner');
2358	            }
2359	        }
2360	    }
2361	});*/
2362	/*
2363	$('.owl-carousel',ctr).each(function(){
2364		
2365		$(this).owlCarousel({
2366		    loop			:	true,
2367		    margin			:	($(this).data("margin")?$(this).data("margin"):10),
2368		    lazyLoad		: 	true,
2369		    responsiveClass : 	true,
2370		    dots			: 	false,
2371		    nav: true,
2372		    navText			: 	["<i class='fa fa-fw fa-angle-left'></i>","<i class='fa fa-fw fa-angle-right'></i>"],
2373		    responsive:{
2374		        0:{
2375		            items	:	($(this).data("responsive-mobile")?$(this).data("responsive-mobile"):1),
2376		            nav		:	true
2377		        },
2378		        600:{
2379		            items	:	($(this).data("responsive-tablet")?$(this).data("responsive-tablet"):3),
2380		            nav		:	false
2381		        },
2382		        1000:{
2383		            items	:	($(this).data("responsive-desktop")?$(this).data("responsive-desktop"):5),
2384		            nav		:	true,
2385		            loop	:	false
2386		        }
2387		    }
2388		});
2389		
2390	});*/
2391	
2392}
2393
2394var validateEmail = function(email) { 
2395    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
2396    return re.test(email);
2397} 
2398var createTag = function(val,el){
2399	var fieldname = el.data("field");
2400	var tag = $("<a href='#'><input type='hidden' name='"+fieldname+"[]' value='"+val+"'/><span>"+val+"</span><i class='closeit closeit-sm'></i></a>");
2401	$(".closeit",tag).click(function(){
2402		$(this).parent(0).remove();
2403		return false;
2404	});
2405	$("input[type=text]",el).before(tag);
2406	$("input[type=text]",el).val("");
2407	tag.click(function(){
2408		return false;
2409	});
2410}
2411var initTagger = function(el){
2412	var datatype = el.data("datatype");
2413	var tm = false;
2414	el.click(function(e){
2415		if($(e.target).get(0) == this){
2416			$("input[type=text]",$(this)).focus();
2417		};
2418	});
2419	$("input[type=text]",el).on("blur",function(e){
2420		if($(this).val() == "")
2421			return true;
2422		
2423		if(datatype == "email" && validateEmail($(e.target).val())){
2424			createTag($(e.target).val(),el);
2425		}else if(datatype == "email"){
2426			$("input[type=text]",el).addClass("error");
2427			setTimeout(function(){
2428				$("input[type=text]",el).removeClass("error");
2429			},500);
2430			
2431		}else{
2432			createTag($(e.target).val(),el);
2433		}
2434	});
2435	$("input[type=text]",el).keydown(function(e){
2436		if(e.which == 9 || e.which == 13){
2437			if($(this).val() == "")
2438				return true;
2439			if($(e.target).is("input[type=text]")){
2440				if(datatype == "email" && validateEmail($(e.target).val())){
2441					createTag($(e.target).val(),el);
2442				}else if(datatype == "email"){
2443					$("input[type=text]",el).addClass("error");
2444					setTimeout(function(){
2445						$("input[type=text]",el).removeClass("error");
2446					},500);
2447					
2448				}else{
2449					createTag($(e.target).val(),el);
2450				}
2451			//	$("#mailer-subject").focus();
2452			}
2453			return false;
2454		}
2455	});
2456	if($("input[type=text]",el).val()){
2457		var arr = $("input[type=text]",el).val().split(",");
2458		for(key in arr){
2459			createTag(arr[key],el);
2460		}
2461		
2462	}
2463}
2464
2465
2466var showUPloader = function(el){
2467	$("label[for='dropped']").addClass("loading");
2468}
2469
2470
2471var initContentLoaders = function(container){
2472	$(".content-loader",container).click(function(){
2473		var target = $(this).data("target");
2474		var url	   = $(this).data("href");
2475		loadContent(url,target);
2476		$(".active",$(this).parent(0)).removeClass("active");
2477		$(this).addClass("active");
2478		
2479		return true;
2480	});
2481}
2482var loadContent = function(url,target){
2483	$.get(url,function(resp){
2484		/*if(ga && $.isFunction(ga)){
2485			ga('send', 'pageview', getUrlPath(url));
2486		}*/
2487		if($(target).is("input,textarea")){
2488			$(target).val(resp);
2489		}else{
2490			doLoadContent(resp,target);
2491		}
2492	});
2493}
2494var doLoadContent = function(content,target){
2495	$(target).html(content);
2496	$("input[name='runjs[]']",$(target)).each(function(){
2497		var func = $(this).val();
2498		if (typeof window[func] === "function") {
2499			try{
2500				window[func]($(target));
2501			}catch(e){}
2502		}
2503	});
2504}
2505var emptyformfields = function(form){
2506	$("input[type=text]",form).val("");
2507	$("textarea",form).val("");
2508}
2509
2510var togglepayments = function(el){
2511	$("input",el).prop("checked",!$("input",el).prop("checked"));
2512	$.post(el.data("url"),{'prepaid': !$("input",el).prop("checked")},function(resp){ parseFormResponse(resp,$("form.wizard"))});
2513}
2514
2515var disableAmount = function(el){
2516	$("input",el).prop("checked",!$("input",el).prop("checked"));
2517	
2518	//alert($("input",el).prop("checked"));
2519	$("input[name=amount]",el.parents("form")).attr("disabled",$("input",el).prop("checked"));
2520	
2521	
2522	//$.post(el.data("url"),{'prepaid': !$("input",el).prop("checked")},function(resp){ parseFormResponse(resp,$("form.wizard"))});
2523}
2524
2525var initSearchLabels = function(ctr){
2526	$(".lists").css("height",$(".lists").css("height"));
2527	$("input[name='searchlist']",ctr).on("keyup",function(e){
2528		var searchval = $(this).val();
2529		$(".lists div",ctr).each(function(){
2530			if($("span",$(this)).text().toLowerCase().includes(searchval.toLowerCase())){
2531				$(this).removeClass("d-none");
2532			}else{
2533				$(this).addClass("d-none");
2534			}
2535		});
2536	});
2537}
2538
2539var initWindowSize = function(){
2540		
2541		var ww	   = $(window).outerWidth();
2542    	var cl = "body-xs";
2543    	if(ww <= 576){
2544			cl = "body-xs";
2545		}else if(ww > 576 && ww <= 768){
2546			cl = "body-sm";
2547    	}else if(ww > 768 && ww <= 992) {
2548    		cl = "body-md";
2549    	}else if(ww > 992 && ww <= 1200){
2550    		cl = "body-lg";
2551      	}else if(ww > 1200 && ww <= 1600){
2552      		cl = "body-xl";
2553      	}else{
2554      		cl = "body-xxl";
2555      	}
2556
2557		$("body").removeClass("body-xs body-sm body-md body-lg body-xl body-xxl").addClass(cl);
2558		
2559		if($("body").hasClass("explorer")){
2560			$(".svg > svg").each(function(){
2561				
2562				var box = $(this).attr("viewBox").split(" ");
2563				$(this).attr("width",ww);
2564				$(this).attr("height",(box[3]/box[2])*ww);
2565				
2566			});
2567		}
2568		
2569}
2570
2571
2572/*$("document").ready(function(){
2573	
2574	if($(".input-tag-container").length > 0){
2575		$(".input-tag-container").each(function(){
2576			initTagger($(this));
2577		});
2578	}
2579});*/
2580
2581$(document).ready(function() {
2582	
2583	initWindowSize();
2584	$(window).on("resize",initWindowSize);
2585	$("body").addClass("ready");
2586	if($('.lazy').length > 0)
2587		$('.lazy').Lazy();
2588	
2589	
2590	initContextMenu($("body"));
2591	
2592	initDataTables($("body"));
2593	initForms($("body"));
2594	initAjaxLinks($("body"));
2595	initFncLinks($("body"));
2596	
2597	initFileDrop($("body"));
2598	initToggleFields();
2599	initContentLoaders($("body"));
2600	
2601	if($(".confirm-link, .confirmlink").length > 0){
2602		
2603		initConfirmLinks($("body"));
2604	}
2605	
2606	if(!are_cookies_enabled()){
2607		$("body").addClass("nocookies");
2608	}
2609	
2610	if($('#mailpreview').length > 0){
2611		initMailPreview();
2612	}
2613	if($("#listview").length > 0){
2614		$("#listview").on("change",function(){
2615			$(".grid").masonry( 'layout');
2616		});
2617	}
2618	
2619	if($(".shop-detail").length > 0){
2620		initSticky($(".shop-detail"));
2621	}
2622	
2623	if($(".ltd-grid .grid").length > 0){
2624		initLists();
2625	}
2626	$(".scrollto").click(function(){
2627		scrollTo($(this).attr("href"));
2628		return false;
2629	});
2630	
2631	initLinkaLikes($("body"));
2632	
2633	if($(".morris-plot").length > 0){
2634		initCharts();
2635	}
2636	
2637	if($("#dashboard").length > 0){
2638		$("a.close-add").click(function(){
2639			$(this).parent(0).fadeOut(250,function(){
2640				$.get("/ltd/home/add/"+$(this).attr("id"));
2641				$(this).remove();
2642			});
2643			return false;
2644		});
2645	}
2646	
2647		
2648		if($(".fixable").length > 0){
2649			
2650			$(".fixable").each(function(){
2651				
2652				
2653				var scrolling = false;
2654				var fixel 	  = $(this);
2655				var fromtop   = fixel.offset().top;
2656			    
2657				var oWidth    = fixel.width();
2658				var oleft     = fixel.offset().left;
2659				var fixed 	  = 0;
2660				var setWidth  = fixel.hasClass("fix-width")?true:false;
2661				var scrolctr  = $(this).data("ctr")?$($(this).data("ctr")):$(document);
2662				var ghost	  = false;
2663				
2664				scrolctr.bind('scroll', function(e){
2665					
2666					if(fixed > 0 && scrolctr.scrollTop() > fixed)
2667						return;
2668					
2669					var screenwidth = $(window).outerWidth();
2670					
2671					if(screenwidth < 1200 && fixel.hasClass("fixable-xl")){
2672						return;
2673					}
2674					if(screenwidth < 992 && fixel.hasClass("fixable-lg")){
2675						return;
2676					}
2677					if(screenwidth > 576 && fixel.hasClass("fixable-mobile")){
2678						return;
2679					}
2680					if(screenwidth < 576 && fixel.hasClass("fixable-sm")){
2681						return;
2682					}
2683					if(screenwidth < 768 && fixel.hasClass("fixable-md")){
2684						return;
2685					}
2686					
2687					
2688					var w = "";
2689					if(fixel.height() > scrolctr.height()){
2690						if(scrolctr.scrollTop() + scrolctr.height() > (fixel.height() + fromtop)){
2691							if(!fixel.hasClass("fixed-bottom")){
2692								ghost = fixel.clone();
2693								ghost.css("visibility","hidden");
2694								fixel.addClass("fixed-bottom");
2695								fixel.after(ghost);
2696								if(setWidth)
2697									fixel.css("width",ghost.width());
2698							}
2699						}else{
2700							if(fixel.hasClass("fixed-bottom")){
2701								if(ghost){
2702									ghost.remove();
2703									ghost = false;
2704								}
2705								fixel.removeClass("fixed-bottom");
2706								if(setWidth)
2707									fixel.css("width",'');
2708								
2709							}
2710						}
2711						return;
2712						
2713					}
2714					
2715					if(scrolctr.scrollTop() > fromtop){
2716						if(!fixel.hasClass("fixed")){
2717							ghost = fixel.clone();
2718							ghost.css("visibility","hidden");
2719							fixel.addClass("fixed");
2720							fixel.after(ghost);
2721							if(setWidth)
2722								fixel.css("width",ghost.width());
2723						}
2724							
2725					}else{
2726						if(fixel.hasClass("fixed")){
2727							if(ghost){
2728								ghost.remove();
2729								ghost = false;
2730							}
2731							
2732							fixel.removeClass("fixed");
2733							if(setWidth)
2734								fixel.css("width",'100%');
2735						}
2736					}
2737				});
2738			});
2739			
2740		}
2741		
2742		if($(".clipboard").length > 0){
2743			var clipboard = new Clipboard('.clipboard',{
2744					text: function(trigger) {
2745						
2746						if($(trigger).data("clipboard-text")){
2747							return $(trigger).data("clipboard-text");
2748						}else if($(trigger).data("clipboard-target")){
2749							return $($(trigger).data("clipboard-target")).html();
2750						}
2751						
2752				        return "";
2753					}
2754			});
2755			
2756			clipboard.on('success', function(e) {
2757				if($(e.trigger).data("feedback")){
2758					showToast($(e.trigger).data("feedback"),2500,-1,null);
2759				}
2760			    e.clearSelection();
2761			    return false;
2762			});
2763			clipboard.on('error', function(e) {
2764			    console.error('Action:', e.action);
2765			    console.error('Trigger:', e.trigger);
2766			});
2767		}
2768		if($("form.notifications").length > 0){
2769			initNotifications();
2770		}
2771		/*if($("form.reservations").length > 0){
2772			initReservations();
2773		}*/
2774		
2775		
2776		$("form.alt-table").each(function(){
2777			initAltTables($(this));
2778		});
2779		$('div[class*="message-"]').each(function(){
2780			initMessage($(this));
2781		});
2782		if($(".dialog-link.init").length > 0){
2783			$(".dialog-link.init").trigger("click");
2784		}
2785		
2786		$("video.video").each(function(){
2787			video = $(this);
2788			if($(this).parent(0).attr("defaultPlaybackRate")){
2789				video.get(0).defaultPlaybackRate  = 0.5;
2790				video.get(0).playbackRate  = 0.5;
2791			}
2792		});
2793		$("a.video-link").click(function(){
2794			var target = $(this).data("target")?$("#"+$(this).data("target")):$("#preview-helper");
2795			
2796			var old = $("video,img",target);
2797			old.addClass("position-absolute");
2798			old.css("opacity",0);
2799			
2800			var video = $('<video id="video" controls></video>');
2801			
2802			video.get(0).src = $(this).data("src")?$(this).data("src"):$(this).attr("href");
2803			
2804			/**PLAY AT HALF SPEED **/
2805			//video.get(0).defaultPlaybackRate  = 0.5;
2806			//video.get(0).playbackRate  = 0.5;
2807			
2808			target.append(video);
2809			
2810			video.get(0).play();
2811			old.remove();
2812			
2813			return false;
2814		});
2815		
2816		if($('.owl-carousel, .carousel-multi').length > 0){
2817			initCarousel($("body"));
2818		}
2819		$(function () {
2820			  $('[data-toggle="popover"]').popover()
2821		});
2822		
2823
2824});

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.