PageSourceSearch

https://costabrava.org/wp-content/themes/costabrava/resources/v1/js/common.js?ver=20260924110905

js costabrava.org collected 2026-09-24 19:35:14 UTC 13,486 bytes, 470 lines download raw bytes

1
2// Input Box Placeholder
3function fnremove(arg,val)	{
4	if (arg.value == '') {arg.value = val}
5}	
6function fnshow(arg,val)	{
7	if (arg.value == val) {arg.value = ''}
8}
9
10
11$(document).ready(function () {	
12	// Sticky Header		
13	$("header").sticky({topSpacing:0});
14
15	// Nice select js	
16	$('.select_box_input').niceSelect();
17
18	// megamenu
19	$(function() {
20		cbpHorizontalMenu.init();
21	});	
22	
23	//Search Form
24	$('.search-form').removeClass('open-form'); 
25	$('.srch-ico').click(function(){
26		$('.search-form').toggleClass('open-form'); 
27	});	
28
29	$('.m-menu').on('click',function(){
30		$('.search-form').removeClass('open-form');	
31	});
32
33	//Mobile Menu Show and Hide
34	$(".m-menu").click(function(){ 	
35		$(this).toggleClass('open');
36		$(".mobile-menu").toggleClass('slow');
37		$('body').toggleClass('over');
38		$(".mobile-search").removeClass('slow');
39	}); 
40
41	//Search Form
42	$(".search").click(function(){ 
43		$(".mobile-search").toggleClass('slow');
44		$(".mobile-menu").removeClass('slow');
45		$(".m-menu").removeClass('open');
46		$('body').removeClass('over');
47
48	});
49	
50	$(".mobile-search a.close").click(function(){ 
51		$(".mobile-search").removeClass('slow');
52		$('body').removeClass('over');
53	});
54
55	// menu hover dark bg
56	$(".cbp-hrmenu li.arrow > a, .cbp-hrmenu li.arrow .cbp-hrsub").mouseover(function(){
57		$("header").addClass("dark-bg");
58	});
59	$(".cbp-hrmenu li.arrow > a, .cbp-hrmenu li.arrow .cbp-hrsub").mouseout(function(){
60		$("header").removeClass("dark-bg");
61	});
62	 
63	//desktop search Show and Hide
64	$(".menu-search").click(function(){ 	
65		$(this).toggleClass('open');
66		$(".fixed-header-search").toggleClass('open');
67		$('body').toggleClass('hide');		
68	}); 
69
70	$(".site-header-search .close-menu").click(function(){ 
71		$(".fixed-header-search").removeClass('open');
72		$('body').removeClass('hide');						
73	});
74
75	$('.blog-lnk ul li.cercar').click(function(){ 
76		$(".mobile-search").toggleClass('slow');
77		$(".mobile-menu").removeClass('slow');
78		$(".m-menu").removeClass('open');
79		$('body').removeClass('over');
80	});
81
82
83
84	//search Show and Hide
85	$(".srch-ico").click(function(){ 	
86		$(this).toggleClass('open');
87		$(".fixed-header-top").toggleClass('open');
88		$('body').toggleClass('hide');		
89	}); 
90
91	$(".site-header-search-inn .close-menu").click(function(){ 
92		$(".fixed-header-top").removeClass('open');
93		$('body').removeClass('hide');						
94	});
95
96});
97
98
99$(document).ready(function () {	
100	txtResize();	
101	jsUpdateSize(); 
102	jsUpdateSize1();
103	jsUpdateSize3();
104	jsUpdateSize4();
105	footermenu();
106});
107
108$(window).resize(function(){
109	jsUpdateSize();
110	jsUpdateSize1();
111	jsUpdateSize3();
112	jsUpdateSize4();
113	txtResize();
114	//footermenu();
115});
116
117
118// function txtResize()
119//   {
120// 	var width = $(window).width();
121// 	//var height = $(window).height();
122	
123// 	var content = $('.my-message').html();
124// 	var charQty = 250;
125// 	var moreText = "<b>...</b> Llegir més";
126// 	var lessText= "Llegeix less";
127
128// 	if(width>1)
129// 	{	
130// 		$('.my-message').addClass("hide-txt");
131// 		if ($(".my-message").hasClass("hide-txt")) {
132// 			if(content.length > charQty) {
133// 				var visibleText = content.substr(0, charQty);
134// 				var hiddenText  = content.substr(charQty, content.length - charQty);
135// 				//alert(hiddenText);
136// 				var html = visibleText+ '<span class="morecontent"><span>' + hiddenText+ '</span> <a href="javascript:void(0);" class="morelink"><label>' +moreText+ '</label></div><div></div></div>' + '</a></span>';
137				
138// 				if (!$(".my-message").hasClass("show")) {
139// 					$('.my-message').html(html);
140// 					$('.morecontent span').hide();
141// 					$('.my-message').addClass("show");
142// 				}
143// 			}
144// 		}
145// 	}else{ 
146// 		var hiddenText  = $('.morecontent span').html();
147// 		//alert(hiddenText);
148// 		if(hiddenText===undefined){
149// 			var hiddenText  = '';
150// 		}
151// 		var html = content+hiddenText;
152// 		$('.my-message').removeClass("hide-txt");
153// 		$('.my-message').html(html);
154// 		$('.morecontent').detach();
155// 		$('.my-message').removeClass("show");
156// 	}	
157// }
158
159
160$(document).on('click','.morelink',function () {
161	$(this).toggleClass('active');
162   if ($(".my-message").hasClass("hide-txt")) {
163	   $('.morecontent span').fadeIn(300);
164	   $('.my-message').removeClass("hide-txt");
165	   $('.morecontent a label').html('Llegeix menys');
166   }else{
167	   $('.my-message').addClass("hide-txt");
168	   $('.morecontent a label').html('<b>...</b> Llegeix més');
169	   $('.morecontent span').fadeOut(100);
170   }
171});
172
173
174function txtResize()
175{
176   var width = $(window).width();
177   var height = $(window).height();
178   var content = $('.my-message').html();
179   var charQty = 235;
180   var moreText = "<b>...</b> Llegeix més";
181   var lessText= "Llegeix menys";
182
183   if(width>=1)
184   {	
185	   $('.my-message').addClass("hide-txt");
186	   if ($(".my-message").hasClass("hide-txt")) {
187		   if(content.length > charQty) {
188			   //Tallem la cadena a la mida que volem charQty
189			   var visibleText = content.substr(0, charQty);
190			   if(visibleText.lastIndexOf("<") >= charQty - 10){ //detectem si hem tallat a l'inici d'une etiqueta en mig de <strong>
191					//si tallem en mig de strong modifiquem el tall a l'inici de l'etiqueta 
192				   charQty = visibleText.lastIndexOf("<");
193				   visibleText = content.substr(0, charQty);					
194			   
195			   }
196			   var regex = /(<+[^>]*?>)/g; // mirem si hi ha alguna etiqueta sense tancar
197			   var aux = visibleText.match(regex).length // si n'hi ha alguna afegim l'etiqueta <strong>
198			   if(aux > 0 && aux % 2 !== 0 ){
199					visibleText += '</strong>';
200			   }
201
202			   var hiddenText  = content.substr(charQty, content.length - charQty);
203			//    alert(hiddenText);
204			   var html = visibleText+ '<span class="morecontent"><span>' + hiddenText+ '</span> <a href="javascript:void(0);" class="morelink"><label>' +moreText+ '</label><div class="arrow-link"><div></div><div></div></div>' + '</a></span>';
205			//    alert(html);
206			   if (!$(".my-message").hasClass("show")) {
207				   $('.my-message').html(html);
208				   $('.morecontent span').hide();
209				   $('.my-message').addClass("show");
210			   }
211		   }
212	   }
213   }else{ 
214	   var hiddenText  = $('.morecontent span').html();
215	   //alert(hiddenText);
216	   if(hiddenText===undefined){
217		  var hiddenText  = '';
218	   }
219	   var html = content+hiddenText;
220	   $('.my-message').removeClass("hide-txt");
221	   $('.my-message').html(html);
222	   $('.morecontent').detach();
223	   $('.my-message').removeClass("show");
224   }	
225}	
226
227function footermenu()
228{ 
229	//var width = $(window).width();
230   // var height = $(window).height();	
231	
232	$('h2.toggle').click(function(e) {
233	
234	if( width = $(window).width() <= 767)
235	{
236		// footer accordion script
237		//$('.f-nav h2').addClass('toggle');
238		
239		e.preventDefault();  
240		var $this = $(this);			
241	  
242		if ($this.next().hasClass('show')) {
243			$this.next().removeClass('show');
244			$this.next().slideUp(350);	  
245			$this.removeClass('act');			
246		} else { //alert();
247			$('.f-nav ul').removeClass('show');
248			$('.f-nav ul').slideUp(350);				
249			$('.toggle').removeClass('act'); // active 				
250			$this.next().toggleClass('show');
251			$this.next().slideToggle(350);					
252			$this.toggleClass('act')
253		}		
254	}		
255  })
256  
257  
258}
259
260
261function jsUpdateSize()
262{ 
263	var width = $(window).width();
264    var height = $(window).height();	
265	
266	$('.inner-img-banner').each(function()
267		{
268			$(this).css('background-image','');
269		});	
270		
271	/*	
272	if(width<=767)
273	{
274		$('.inner-img-banner').each(function()
275		{ 
276			var img = $('img', this).attr('src');
277			$(this).css('background-image','url(' + img + ')');		
278		});
279	}
280	else{
281			$('.inner-img-banner').each(function()
282		{
283			$(this).css('background-image','');
284		});	
285	}*/
286	
287	//Blog Append Text
288	if(width<=767)
289	{
290		$("#mob-lnks").appendTo("#mob-lnks-div");
291		$("#mob-lnks-div").show();
292	}
293	else
294	{
295		$("#mob-lnks").appendTo("#mob-lnks-desk");
296		$("#mob-lnks-desk").show();
297	}
298
299	//wikiloc Append Text
300	if(width<=1023)
301	{
302		$("#mob-lnks1").appendTo("#mob-lnks-div1");
303		$("#mob-lnks-div1").show();
304	}
305	else
306	{
307		$("#mob-lnks1").appendTo("#mob-lnks-desk1");
308		$("#mob-lnks-desk1").show();
309	}
310}
311
312
313function jsUpdateSize1()
314{ 
315	var width = $(window).width();
316    var height = $(window).height();	
317	if(width<=1023)
318	{
319			$('.wikiloc-img').each(function()
320		{ 
321			var img = $('img', this).attr('src');
322			$(this).css('background-image','url(' + img + ')');		
323		});
324	}
325	else{
326			$('.wikiloc-img').each(function()
327		{
328			$(this).css('background-image','');
329		});	
330	}
331}
332
333
334function jsUpdateSize3()
335{ 
336	var width = $(window).width();
337    var height = $(window).height();	
338	
339	$('#main-slider .main-slide .main-ban-img').each(function()
340		{
341			$(this).css('background-image','');
342		});	
343	/*	
344	if(width<=1023)
345	{
346			$('#main-slider .main-slide .main-ban-img').each(function()
347		{ 
348			var img = $('img', this).attr('src');
349			$(this).css('background-image','url(' + img + ')');		
350		});
351	}
352	else{
353			$('#main-slider .main-slide .main-ban-img').each(function()
354		{
355			$(this).css('background-image','');
356		});	
357	}*/
358}
359
360function jsUpdateSize4()
361{
362  var width = $(window).width();
363  var height = $(window).height();
364  var row_W = $(".row").width();    
365  var lft_pad= (width-row_W)/2;
366  var rgt_pad= (width-row_W)/2;
367  var rgt_pad1= (width-row_W)/5.5;
368  
369  if(width>=767)
370  {
371    $("#coneix-slider .slider-for-home.slick-slider .slick-slide .banner-txt").css('padding-right', rgt_pad);		
372    $('#coneix-slider .slider-nav-ban').css('padding-right', rgt_pad);		
373    $('#main-slider .main-slider-controls').css('margin-right', rgt_pad1);	
374	$('#main-slider.main-banner2 .main-ban-img .caption-inner').css('margin-left', lft_pad);	
375  }
376  else{
377    $("#coneix-slider .slider-for-home.slick-slider .slick-slide .banner-txt").css('padding-right','');				
378    $('#main-slider .main-slider-controls').css('margin-right', '');	
379	$('#main-slider.main-banner2 .main-ban-img .caption-inner').css('margin-left', '');		
380  }
381}
382
383
384
385// Nice select js	
386//$('.select_box_input').niceSelect();
387
388$(document).ready(function () {
389	
390	$("#momentsque-lst .item").hover(function () {
391		$("#momentsque-lst .item").addClass('overlay')
392		//$(this).addClass("sdfsd");
393		$("#momentsque-lst .item").not($(this)).addClass("overlay");
394		$(this).toggleClass("no-overlay");
395	});
396
397	$("#momentsque-lst .item").mouseout(function () {
398		$("#momentsque-lst .item").removeClass('overlay')
399		//$(this).addClass("sdfsd");
400		$("#momentsque-lst .item").not($(this)).removeClass("overlay");
401		$(this).removeClass("no-overlay");
402	});
403
404});
405
406
407
408// poster frame click event
409$(document).on('click','.js-videoPoster',function(ev) {
410	ev.preventDefault();
411	var $poster = $(this);
412	var $wrapper = $poster.closest('.js-videoWrapper');
413	
414	if (($wrapper).hasClass("videoWrapperActive")) {
415		videoStop($wrapper);
416	} else {
417		videoPlay($wrapper);
418	}
419});
420// play the targeted video (and hide the poster frame)
421function videoPlay($wrapper) 
422{ 
423	var $iframe = $wrapper.find('.js-videoIframe');
424	var src = $iframe.data('src');
425	
426	// hide poster
427	$wrapper.toggleClass('videoWrapperActive');
428	
429	// add iframe src in, starting the video
430	$iframe.attr('src',src);
431}
432
433// stop the targeted/all videos (and re-instate the poster frames)
434function videoStop($wrapper) 
435{ 
436	// if we're stopping all videos on page
437	if (!$wrapper) {
438		var $wrapper = $('.js-videoWrapper');
439		var $iframe = $('.js-videoIframe');
440	// if we're stopping a particular video
441	} else {
442		var $iframe = $wrapper.find('.js-videoIframe');
443	}
444	// reveal poster
445	$wrapper.removeClass('videoWrapperActive');
446	// remove youtube link, stopping the video from playing in the background
447	$iframe.attr('src','');
448} 
449
450
451ddaccordion.init({
452	headerclass: "silverheader", //Shared CSS class name of headers group
453	contentclass: "submenu1", //Shared CSS class name of contents group
454	revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
455	mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
456	collapseprev: true, //Collapse previous content (so only one open at any time)? true/false
457	defaultexpanded: [""], //index of content(s) open by default [index1, index2, etc] [] denotes no content
458	onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
459	animatedefault: false, //Should contents open by default be animated into view?
460	persiststate: true, //persist state of opened contents within browser session?
461	toggleclass: ["", "selected"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
462	togglehtml: ["", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
463	animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
464	oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
465		//do nothing
466	},
467	onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
468		//do nothing
469	}
470})

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.