PageSourceSearch

https://vilassar.cat/estil2/js/common-web.js

js vilassar.cat collected 2026-10-02 22:03:32 UTC 10,539 bytes, 445 lines download raw bytes

1var map;
2var is_sticky = false;
3
4$(document).ready(function() {
5
6    $('#boto_cercar').on("click",function() {
7        $(this).parents('form').submit();
8    });
9
10
11    if($("#img-cap").length>0)
12    {
13        $('#cercador_menu').addClass("te-imatge-cap");
14    }
15
16
17    activa_sticky();
18    
19if($('.fancybox').length>0) {
20        $(".fancybox")
21            .attr('rel', 'zoom_foto')
22            .fancybox({
23                openEffect: 'fade',
24                closeEffect: 'fade',
25                prevEffect: 'elastic',
26                nextEffect: 'elastic',
27                arrows: true,
28                helpers: {
29                    media: {},
30                    title: {type: 'inside'},
31                    buttons: {},
32                    thumbs: {
33                        width: 50,
34                        height: 50
35                    }
36                }
37            });
38
39    }
40
41    if($('.fancybox-galeria').length>0)
42    {
43        $(".fancybox-galeria")
44            .attr('rel', 'zoom_galeria')
45            .fancybox({
46                openEffect : 'fade',
47                closeEffect : 'fade',
48                prevEffect : 'elastic',
49                nextEffect : 'elastic',
50                arrows : true,
51                helpers : {
52                    title   : { type : 'inside' },
53                    media : {},
54                    buttons : {}
55                }
56            });
57
58    }
59
60    // Desplega el menú de la tablet
61    $("#mostra_menu_tablet").click(function(e){
62        $("#menu_tablet").slideToggle();
63    });
64
65
66    if($('#mapa_localitzacio').length>0)
67        defineix_mapa("#mapa_localitzacio");
68
69
70    if($("#galeria_just").length>0)
71    {
72        $("#galeria_just").justifiedGallery({
73            rowHeight : 70,
74            margins : 5,
75            captions:true,
76            captionSettings : { //ignored with css animations
77                animationDuration : 100,
78                visibleOpacity : 1,
79                nonVisibleOpacity : 0.90
80            }
81        });
82    }
83
84//    if($('.banner-scroll').length>0) {
85 //       $('.banner-scroll').bxSlider({
86//            slideWidth: 190,
87//            minSlides: 3,
88//            maxSlides: 6,
89//            pager: false,
90//            auto:true,
91//            nextText: '<i class="fa fa-chevron-right"></i>',
92//            prevText: '<i class="fa fa-chevron-left"></i>'
93//        });
94//    }
95
96    $('.banner-scroll').bxSlider({
97        minSlides: 2,
98        maxSlides: 6,
99        slideWidth: 180,
100        speed: 1000,
101	pause: 8000,
102        pager: false,
103        auto:true,
104        responsive: true,
105        adaptiveHeight: true,
106        nextText: '<i class="fa fa-chevron-right"></i>',
107        prevText: '<i class="fa fa-chevron-left"></i>',
108        touchEnabled: false
109    });
110
111    /////////////////////////////////////////////////////////////////////////////
112    // Scroll ---------------------------------------------------------
113    $(window).on("scroll",function() {
114        activa_sticky();
115        menu_deplegable_close();
116    });
117
118    $("#icona_cerca_mini").on("click", function() {
119        $("html, body").animate({ scrollTop: 0 }, "slow",function() { $("#paraula").focus(); });
120    });
121
122
123    $(".n1_desplegable").on("click", function() {
124
125
126        $('.fa-select-1').removeClass('fa-select-1');
127        tmp = $(this).parent().find('.tablet_n2');
128
129        tmp.slideToggle();
130
131        if(tmp.hasClass('slided'))
132        {
133            tmp.removeClass('slided');
134        }
135        else
136        {
137            $(this).parent().find('.marca_n1').addClass('fa-select-1');
138            $(".tablet_n1").find(".slided").slideToggle();
139            $(".tablet_n1").find(".slided").removeClass('slided');
140            tmp.addClass('slided')
141        }
142    });
143
144    $(".n2_desplegable").on("click", function() {
145
146
147
148        $('.fa-select-2').removeClass('fa-select-2');
149        tmp = $(this).parent().find('.tablet_n3');
150
151        tmp.slideToggle();
152
153        if(tmp.hasClass('slided_n2'))
154        {
155
156            tmp.removeClass('slided_n2');
157        }
158        else
159        {
160            $(this).parent().find('.marca_n2').addClass('fa-select-2');
161            $(".tablet_n2").find(".slided_n2").slideToggle();
162            $(".tablet_n2").find(".slided_n2").removeClass('slided_n2');
163            tmp.addClass('slided_n2')
164        }
165    });
166
167
168    if($('.datepicker').length>0) {
169        $( ".datepicker" ).datepicker();
170    }
171
172    if($('.acordio').length>0) {
173        $(".acordio").accordion({
174            heightStyle: "content"
175        });
176    }
177
178});
179
180
181function menu_deplegable_close()
182{
183    //$(".slided").fadeOut(10,function(){});
184    //$( "div" ).removeClass( "slided");
185    //$('#menu_deplegable li a').removeClass('menu_seleccionat_tmp');
186}
187
188/**
189 * Carrega scripr de google maps per dibuixar mapa
190 *
191 * @param nom_element
192 */
193function defineix_mapa(nom_element)
194{
195
196    var zoom = parseInt($(nom_element).attr('data-zoom'));
197    var nom_entitat = $(nom_element).data('nom_entitat');
198
199    // arreglar per adressa i mapa
200
201
202
203    if($(nom_element).data('lat')!='')
204    {
205
206        map = new GMaps({
207            el: nom_element,
208            lat: $(nom_element).attr('data-lat'),
209            lng: $(nom_element).attr('data-lon'),
210            zoom: zoom,
211            zoomControl : true,
212            panControl : false,
213            streetViewControl : false,
214            mapTypeControl: true,
215            overviewMapControl: false,
216            scrollwheel: false
217        });
218
219        map.addMarker({
220            lat: $(nom_element).attr('data-lat'),
221            lng: $(nom_element).attr('data-lon'),
222            title: $(nom_element).attr('data-title')});
223    }
224    else
225    {
226
227        map = new GMaps({
228            el: nom_element,
229            lat: 1.4,
230            lng: 42,
231            zoom: zoom,
232            zoomControl : true,
233            panControl : false,
234            streetViewControl : false,
235            mapTypeControl: true,
236            overviewMapControl: false,
237            scrollwheel: false
238        });
239
240        adressa = $(nom_element).data('adressa');
241        GMaps.geocode({
242            address: adressa,
243            callback: function(results, status) {
244                if (status == 'OK') {
245                    var latlng = results[0].geometry.location;
246                    map.setCenter(latlng.lat(), latlng.lng());
247                    map.addMarker({
248                        lat: latlng.lat(),
249                        lng: latlng.lng()
250                    });
251                }
252            }
253        });
254
255    }
256
257
258}
259
260
261function activa_sticky()
262{
263
264    mida_canvi = 100;
265
266    if($(".te-imatge-cap").length>0)
267    {
268        mida_canvi = 400;
269    }
270
271
272    if ($(this).scrollTop() > mida_canvi){
273        $('header').addClass("sticky");
274        $("#seccio_cos").css("margin-top",mida_canvi+10);
275
276    }
277    else{
278        $('header').removeClass("sticky");
279        $("#seccio_cos").css("margin-top",0);
280    }
281
282}
283
284
285
286
287
288////////////////////////////////////////////////////////////////////////////
289// Menú principal desplegable
290
291var timeout    = 500;  
292var closetimer = 0;
293var ddmenuitem = null;
294
295function menu_deplegable_open(id_sumenu)
296{
297    menu_deplegable_canceltimer();
298    menu_deplegable_close();
299
300    ddmenuitem = $("#" + id_sumenu);
301
302    ddmenuitem.removeClass('amagat'); // fem que es vegi
303    ddmenuitem.css('z-index', '99'); // Posicionem a sobre de tot
304}
305
306function menu_deplegable_close()
307{
308    if(ddmenuitem!=null)
309    {
310        ddmenuitem.addClass('amagat');
311    }
312}
313
314function menu_deplegable_timer()
315{
316    closetimer = window.setTimeout(menu_deplegable_close, timeout);
317}
318
319function menu_deplegable_canceltimer()
320{
321    if(closetimer)
322    {
323        window.clearTimeout(closetimer);
324        closetimer = null;
325    }
326}
327
328$(document).ready(function() {
329    $('.item_desplegable').on('mouseover', function(e) {
330        id_submenu = $(this).data('id-submenu');
331        menu_deplegable_open(id_submenu);
332    });
333
334    $('.item_desplegable').on('mouseout',  function(e) {
335        menu_deplegable_timer();
336    });
337});
338
339document.onclick = menu_deplegable_close;
340////////////////////////////////////////////////////////////////////////
341
342
343////////////////////////////////////////////////////////////////////////
344// Avisos de portada - Animació
345
346var avis_actual = -1;
347var num_avisos = 0;
348var avis_temps_canvi = 7500;
349var avis_temps_efecte = 600;
350
351$(document).ready(function(){
352
353    if($("#llista_avisos").length>0)
354    {
355    //    num_avisos = $("#llista_avisos").data('num-avisos');
356        num_avisos = $(".avis_item").length;
357    //    alert(num_avisos);
358    //    alert($(".avis_item").length);
359    //    num_avisos = 3;
360        $(".avis_item").hide();
361        canvia_avis();
362    }
363
364});
365
366
367function canvia_avis()
368{
369    if(avis_actual!=-1)
370        $(".avis-" + avis_actual).hide(avis_temps_efecte,function(){});
371
372    avis_actual++;
373    if(avis_actual>=num_avisos)
374    {
375        avis_actual = 0;
376    }
377
378    $(".avis-" + avis_actual).show(avis_temps_efecte,function(){});
379    setTimeout( "canvia_avis();",avis_temps_canvi);
380}
381
382
383////////////////////////////////////////////////////////////////////////
384////////////////////////////////////////////////////////////////////////
385// Temps de portada - Animació
386
387var meteo_actual = -1;
388var num_meteo = 0;
389var meteo_temps_canvi = 7500;
390var meteo_temps_efecte = 600;
391
392$(document).ready(function(){
393
394    if($("#llista_meteocat").length>0)
395    {
396        num_meteo = $("#llista_meteocat").data('num-meteo');
397        num_meteo = 2;
398        $(".meteo_item").hide();
399        canvia_meteo();
400    }
401
402});
403
404
405function canvia_meteo()
406{
407    if(meteo_actual!=-1)
408        $(".meteo-" + meteo_actual).hide(meteo_temps_efecte,function(){});
409
410    meteo_actual++;
411    if(meteo_actual>=num_meteo)
412    {
413        meteo_actual = 0;
414    }
415    $(".meteo-" + meteo_actual).show(meteo_temps_efecte,function(){});
416    setTimeout( "canvia_meteo();",meteo_temps_canvi);
417}
418
419
420
421////////////////////////////////////////////////////////////////////////
422
423
424////////////////////////////////////////////////////////////////////////
425////////////////////////////////////////////////////////////////////////
426// Aplicar Masonry
427
428
429$(document).ready(function(){
430
431var grid = document.querySelector('.grid-masonry');
432var msnry = new Masonry( grid, {
433  itemSelector: '.grid-item-masonry'
434});
435
436});
437
438var $container = $('.grid-masonry');
439// initialize Masonry after all images have loaded  
440$container.imagesLoaded( function() {
441    var grid = document.querySelector('.grid-masonry');
442    var msnry = new Masonry( grid, {
443      itemSelector: '.grid-item-masonry'
444    });
445});

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.