PageSourceSearch

https://www.alessandriaoggi.info/sito/wp-content/themes/weeklynews/assets/js/functions.js?ver=3.4.2

js alessandriaoggi.info collected 2026-10-03 17:34:48 UTC 20,001 bytes, 567 lines download raw bytes

1"use strict";
2function setVideoHeights() {
3
4    // youtube
5    jQuery(document).find('iframe[src*="youtube.com"]').each(function() {
6        jQuery(this).css('height', jQuery(this).attr('width', '100%').width() * 0.56, 'important');
7    })
8
9    // vimeo
10    jQuery(document).find('iframe[src*="vimeo.com"]').each(function() {
11        jQuery(this).css('height', jQuery(this).attr('width', '100%').width() * 0.56, 'important');
12    })
13
14    // youtube
15    jQuery(document).find('iframe[src*="dailymotion.com"]').each(function() {
16        jQuery(this).css('height', jQuery(this).attr('width', '100%').width() * 0.56, 'important');
17    })
18
19}
20
21"use strict";
22// Ajax Post Views Counter
23var miptheme_ajax_post_views = {
24
25    get_post_views : function get_post_views (post_array_ids) {
26        jQuery.ajax({
27            type: 'POST',
28            url: miptheme_ajax_url.ajaxurl,
29            cache: true,
30            data: {
31                action: "miptheme_ajax_update_views",
32                post_ids: post_array_ids
33            },
34            success: function(data, textStatus, XMLHttpRequest){
35                var ajax_post_counts = jQuery.parseJSON(data);//get the return dara
36
37                if (ajax_post_counts instanceof Object) {
38                    jQuery.each(ajax_post_counts, function(id_post, value) {
39                        var current_post_count = ".post-view-counter-" + id_post;
40                        jQuery(current_post_count).html(value);
41                    });
42                }
43            },
44            error: function(MLHttpRequest, textStatus, errorThrown){
45            }
46        });
47    }
48
49};
50
51"use strict";
52(function($) {
53
54    $(window).load(function() {
55        $('[data-retina]').each(function() {
56
57            var img = new Image();
58            img.src = $(this).attr('data-retina');
59
60            if(window.devicePixelRatio >= 2) {
61                $(this).attr('src', img.src);
62            }
63
64        });
65    });
66
67
68    // Navigation Menu Expander
69    $(function() {
70        $('nav#mobile-menu').mmenu({
71            offCanvas: {
72                position: "left",
73                zposition : "front"
74            },
75            searchfield: false
76        });
77    });
78
79    $("#mobile-search-expander").click(function(e){
80        e.preventDefault();
81        $('.mobile-search-dropdown').toggleClass('active');
82        $('.mobile-search-dropdown input').focus();
83    });
84
85
86    // Navigation slide down
87    $("#menu .nav li").hover(function(){
88        $(this).stop(true, true).find('.dropnav-container, .subnav-container').slideDown(100);
89    },function(){
90        $(this).stop(true, true).find('.dropnav-container, .subnav-container').hide();
91    });
92
93    // Subnav article loader
94    $('#menu .subnav-menu li:first-child').addClass('current');
95
96    $('#menu .subnav-menu li').hover(function() {
97        $(this).parent().find('li').removeClass('current');
98        $(this).addClass('current');
99    });
100
101
102    $('#search-nav-button').click(function(){
103        $(this).delay(200).queue(function(){
104            document.getElementById("nav-search").focus();
105            $(this).dequeue();
106        });
107    });
108
109    $('.dropdown-menu').find('form').click(function (e) {
110        e.stopPropagation();
111    });
112
113
114    // Sticky Navigation
115    $('#sticky-header.sticky').attr('data-offset-top', $('#header-branding').height() + $('#top-navigation').height() );
116    $('.sticky-header-wrapper').height($("#sticky-header.sticky").height());
117    $('#sticky-header.sticky').affix({
118        offset: { top: $('#sticky-header').offset().top }
119    });
120
121    $('#side-banners.sticky').affix({
122        offset: {
123            top: 49
124        }
125    });
126
127
128    // Weather Data
129    if ( !(typeof(weather_widget) === 'undefined') && weather_widget) {
130        if (weather_location == '') {
131            if (getCookie('weeklynews_weather') === null) {
132                $.getJSON('https://freegeoip.net/json/')
133                 .done (function(location)
134                 {
135                     weather_location = location.city +', '+ location.country_name;
136                     setCookie('weeklynews_weather', weather_location);
137                     GetWeatherData(weather_lang, weather_location, weather_unit, openweathermapapikey)
138                 });
139            } else {
140                GetWeatherData(weather_lang, getCookie('weeklynews_weather'), weather_unit, openweathermapapikey)
141            }
142        } else {
143            GetWeatherData(weather_lang, weather_location, weather_unit, openweathermapapikey)
144        }
145    }
146
147
148    function GetWeatherData(sLang, sLocation, sUnit, sApiKey) {
149        $('#weather .temp').customOpenWeather({
150            key: ''+ sApiKey +'',
151            lang: ''+ sLang +'',
152            city: ''+ sLocation +'',
153            placeTarget: '#weather .location',
154            units: ''+ sUnit +'',
155            descriptionTarget: '#weather .desc',
156            iconTarget: '#weather i.icon',
157            success: function() {
158                $('#weather').show();
159            },
160            error: function(message) {
161                console.log(message);
162            }
163        });
164    }
165
166
167    if ( !(typeof(initCarouFredSel) === 'undefined') && initCarouFredSel) {
168        $('#slider-carousel').carouFredSel({
169            width: '100%',
170            height: 'variable',
171            prev: '#slider-prev',
172            next: '#slider-next',
173            responsive: true,
174            transition: true,
175            items: {
176                height: 'variable',
177            },
178            swipe: {
179                onMouse: true,
180                onTouch: true
181            },
182            scroll : {
183                items           : 1,
184                easing          : "quadratic",
185                duration        : 1000,
186                pauseOnHover    : true
187            },
188            auto : {
189                play            : carouselStart,
190                delay           : carouselDelay,
191            },
192            onCreate: function () {
193                setTimeout(function() {
194                    $('#page-slider .bttrlazyloading').trigger('bttrlazyloading.load');
195                }, 1000);
196                $(window).on('resize', function () {
197                    var carousel = $('#slider-carousel');
198                    carousel.parent().add(carousel).height(carousel.children().first().height()+'px');
199                }).trigger('resize');
200            }
201        }).trigger('resize');
202
203        $('#slider-carousel').swipe({
204            tap:function (event, target) {
205                $(target).click();
206            },
207            swipe:function(event, direction, distance, duration, fingerCount) {
208            },
209            threshold:50
210        });
211    }
212
213
214    if ( !(typeof(initModuleCarousel) === 'undefined') && initModuleCarousel) {
215        $('.module-carousel .wrapper').carouFredSel({
216            width: '100%',
217            height: ''+ modCarHeight +'px',
218            prev    : {
219                button  : function(){
220                    return $(this).parents('.module-carousel').find('.prev');
221                }
222            },
223            next    : {
224                button  : function(){
225                    return $(this).parents('.module-carousel').find('.next');
226                }
227            },
228            responsive: true,
229            transition: true,
230            swipe: {
231                onMouse: true,
232                onTouch: true
233            },
234            auto : {
235                play            : modCarAutoStart
236            },
237            scroll : {
238                items           : 1,
239                easing          : "quadratic",
240                duration        : 600,
241                pauseOnHover    : true,
242                onAfter: function( data ) {
243                    var pos = $(".module-carousel .wrapper").triggerHandler("currentPosition") + 1;
244                    $(".module-carousel figure .index").text( pos );
245                }
246            }
247        });
248
249        $('.module-carousel .wrapper').swipe({
250            tap:function (event, target) {
251                $(target).click();
252            },
253            swipe:function(event, direction, distance, duration, fingerCount) {
254            },
255            threshold:50
256        });
257
258        $('.module-carousel figcaption a.pix').click(function(e){
259            e.preventDefault();
260            $(this).closest("figure").children('a.pix').click();
261        });
262    }
263
264
265    if ( !(typeof(initWidgetSliderCarousel) === 'undefined') && initWidgetSliderCarousel) {
266        $('.module-slider .article-container').carouFredSel({
267            width: '100%',
268            height: ''+ widgetSliderCarHeight +'px',
269            prev    : {
270                button  : function(){
271                    return $(this).parents('.module-slider').find('.prev');
272                }
273            },
274            next    : {
275                button  : function(){
276                    return $(this).parents('.module-slider').find('.next');
277                }
278            },
279            responsive: true,
280            transition: true,
281            auto: widgetSliderCarAutoStart,
282            swipe: {
283                onMouse: true,
284                onTouch: true
285            },
286            scroll : {
287                fx : "crossfade",
288                items           : 1,
289                easing          : "linear",
290                duration        : 600,
291                pauseOnHover    : true
292            }
293        });
294
295        $('.module-slider .article-container').swipe({
296            tap:function (event, target) {
297                $(target).click();
298            },
299            swipe:function(event, direction, distance, duration, fingerCount) {
300            },
301            threshold:50
302        });
303    }
304
305
306    if ( !(typeof(initBreakingNews) === 'undefined') && initBreakingNews) {
307        $('#breaking-news-carousel').carouFredSel({
308            width: '100%',
309            height: 'auto',
310            direction: 'up',
311            items: 1,
312            scroll: {
313                duration: 1000,
314                onBefore: function( data ) {
315                    data.items.visible.children().css( 'opacity', 0 ).delay( 200 ).fadeTo( 400, 1 );
316                    data.items.old.children().fadeTo( 400, 0 );
317                }
318            }
319        });
320    }
321
322    // Init photobox
323    $('.weekly-gallery').photobox('a',{ time:0 });
324    $('.module-carousel').photobox('figure > a.pix',{ time:0 });
325    $('#article-gallery').photobox('a',{ time:0 });
326    $('.zoom-photo').photobox('a',{ time:0 });
327    $('#main').photobox('a.photobox',{ time:0 });
328
329    // Init Reading Time
330    var $articleForReading = $('article.article-post');
331    var $articleForReadingPrepend = $('article.article-post .eta').attr('rel')+' ';
332    $articleForReading.readingTime({
333        wordsPerMinute: 250,
334        prependTimeString: $articleForReadingPrepend,
335        error: function(message) {
336            $articleForReading.find('.eta').remove();
337        }
338    });
339
340    // Init datepicker for archive page
341    $('#archive-date-picker').datepicker({
342        format: 'mm/yyyy',
343        viewMode: 'months',
344        minViewMode: 'months'
345    }).on('changeDate', function(ev){
346        var nYear = ev.date.getFullYear();
347        var nMonth = ( ev.date.getMonth() < 8 ) ? '0' + (ev.date.getMonth()+1) : (ev.date.getMonth()+1);
348        window.location.href = '/?m='+ nYear +''+ nMonth;
349    });
350
351    //Click event to scroll to top
352    $('.scrollToTop').click(function(){
353        $('html, body').animate({scrollTop : 0},800);
354        return false;
355    });
356
357    // Set page header height
358    if ($('#page-header').height() > 0) $('#page-header').height($("#page-header").height());
359
360    // Set Parallax header
361    // Set Reading Progress Bar
362    var top_header      = $('.head-image-parallax');
363    var lastScrollTop   = 0;
364    $(window).scroll(function () {
365        // Parallax header
366        var st = $(window).scrollTop();
367        top_header.css({'background-position':"center -"+(st*.3)+"px"});
368
369        var nHeaderHeight   = $('#wpadminbar').height() + $('#top-navigation').height() + $('#header-branding').height();
370        if (($(this).scrollTop() >= nHeaderHeight)&&(st > lastScrollTop)) {
371            $('#post-info-bar').addClass('scroll');
372        } else {
373            $('#post-info-bar').removeClass('scroll');
374        }
375        lastScrollTop = st;
376
377        // Reading Progress Bar
378        if( $('.article-post-reading-area').length )
379        {
380            var stickyHeaderHeight = ( $('#sticky-header.affix').height() > 0 ) ? $('#sticky-header.affix').height() + 30 : 0;
381            var readingBarPercent = 100 * ($(window).scrollTop() + stickyHeaderHeight - $('.article-post-reading-area').offset().top) / $('.article-post-reading-area').height();
382            $('.reading-bar-progress').css('width', readingBarPercent +"%"  );
383        }
384    });
385
386    // Resize video iframes
387    setVideoHeights();
388
389
390    // Placeholder for non supportive
391    $('input, textarea').placeholder();
392
393    // Get social shares
394    if ( !(typeof(smStats) === 'undefined') && smStats) {
395        smStats = new SocialMediaStats( smStats );
396        if (smStatsFacebook) smStats.facebookCount('smFacebook');
397        if (smStatsTwitter) smStats.twitterCount('smTwitter');
398        //if (smStatsGoogle) smStats.facebookCount('smGoogle
399        if (smStatsLinkedIn) smStats.linkedinCount('smLinkedin');
400    }
401
402
403    // Lazy Loading
404    $('.bttrlazyloading').bttrlazyloading({
405        backgroundcolor: '#fff',
406        animation: 'fadeIn'
407    });
408
409
410    // Smooth Scrolling
411    if ( !(typeof(miptheme_smooth_scrolling) === 'undefined') && miptheme_smooth_scrolling) {
412        smooth_scroll();
413    }
414
415
416    // Ajax paging
417    $('.mip-ajax-nav a').click(function(e){
418        e.preventDefault();
419        var element             = this;
420        var nIndex              = parseInt( $(this).attr('data-index') );
421        var sContainer          = '#'+ $(this).attr('data-container');
422        var nMaxPages           = parseInt( $(sContainer).attr('data-max-pages') );
423
424        if ( (nIndex == 0) || (nIndex == nMaxPages )) { return; }
425
426        //search the cache
427        var currentContainerObj = JSON.stringify(sContainer +'-'+ $(this).attr('data-index'));
428        if ( mipthemeLocalCache.exist(currentContainerObj) ) {
429            processResponse( mipthemeLocalCache.get(currentContainerObj), element, sContainer );
430            return;
431        }
432
433        var sContainerArticles  = sContainer + ' .articles';
434        var sArticles           = sContainerArticles + ' article';
435
436
437        $.ajax({
438            url: miptheme_ajax_url.ajaxurl,
439            type: 'post',
440            data: {
441                action: 'miptheme_ajax_blocks',
442                data_block: $(sContainer).attr('data-block'),
443                data_index: $(this).attr('data-index'),
444                data_cat: $(sContainer).attr('data-cat'),
445                data_count: $(sContainer).attr('data-count'),
446                data_offset: $(sContainer).attr('data-offset'),
447                data_tag: $(sContainer).attr('data-tag'),
448                data_sort: $(sContainer).attr('data-sort'),
449                data_display: $(sContainer).attr('data-display'),
450                data_posttype: $(sContainer).attr('data-posttype'),
451                data_img_format_1: $(sContainer).attr('data-img-format-1'),
452                data_img_format_2: $(sContainer).attr('data-img-format-2'),
453                data_img_width_1: $(sContainer).attr('data-img-width-1'),
454                data_img_width_2: $(sContainer).attr('data-img-width-2'),
455                data_img_height_1: $(sContainer).attr('data-img-height-1'),
456                data_img_height_2: $(sContainer).attr('data-img-height-2'),
457                data_text: $(sContainer).attr('data-text'),
458                data_columns: $(this).attr('data-columns'),
459                data_layout: $(this).attr('data-layout')
460            },
461            beforeSend: function() {
462                $(sArticles).addClass('ajax-opacity');
463                $(sContainerArticles).append('<span class="ajax-loading"><div class="loader">Loading...</div></span>');
464                $(sContainerArticles).wrapInner( $( '<aside class="clearfix"></aside>' ) );
465                $(sContainerArticles).css( 'height', ''+ $('aside:first',sContainerArticles).height() +'px' )
466            },
467            complete: function( xhr, status ) {
468                $(sContainerArticles + ' .ajax-loading').remove();
469            },
470            success: function( data ) {
471                mipthemeLocalCache.set(currentContainerObj, data);
472                processResponse( data, element, sContainer );
473            }
474        })
475    });
476
477
478    function processResponse( data, element, sContainer ) {
479        var sContainerArticles  = sContainer + ' .articles';
480        var sArticles           = sContainerArticles + ' article';
481
482        $(sContainerArticles).removeClass('animated fadeIn');
483        $(sArticles).fadeOut(700, function() {
484            $(sArticles).remove();
485            $(sContainerArticles).html( data ).addClass('animated fadeIn');
486            $(sContainerArticles).wrapInner( $( '<aside class="clearfix"></aside>' ) );
487
488        });
489
490        if ( $(element).hasClass('prev') ) {
491            setPrevIndex( sContainer );
492        } else {
493            setNextIndex( sContainer );
494        }
495
496        setTimeout(function() {
497            var newheight = $('aside:first',$(sContainerArticles)).height();
498            $(sContainerArticles).animate( {height: newheight} );
499            if (newheight > $(window).height()) {
500                $("html, body").stop().animate({ scrollTop: $( sContainer ).offset().top - 30 }, 1000);
501            }
502        }, miptheme_ajaxpagination_timer);
503    }
504
505
506    function setNextIndex( sContainer ) {
507        $(sContainer + ' .mip-ajax-nav a').removeClass('disabled');
508        var sPrev   = sContainer + ' .mip-ajax-nav a.prev';
509        var sNext   = sContainer + ' .mip-ajax-nav a.next';
510        $(sPrev).attr('data-index', parseInt($(sPrev).attr('data-index'))+1);
511        $(sNext).attr('data-index', parseInt($(sNext).attr('data-index'))+1);
512        if ( $(sNext).attr('data-index') == $(sContainer).attr('data-max-pages') ) {
513            $(sNext).addClass('disabled');
514        }
515    }
516
517    function setPrevIndex( sContainer ) {
518        $(sContainer + ' .mip-ajax-nav a').removeClass('disabled');
519        var sPrev   = sContainer + ' .mip-ajax-nav a.prev';
520        var sNext   = sContainer + ' .mip-ajax-nav a.next';
521        $(sPrev).attr('data-index', parseInt($(sPrev).attr('data-index'))-1);
522        $(sNext).attr('data-index', parseInt($(sNext).attr('data-index'))-1);
523        if ( $(sPrev).attr('data-index') == 0 ) {
524            $(sPrev).addClass('disabled');
525        }
526    }
527
528    // Post Info Bar
529    $('#post-info-bar-sharing').click(function() {
530        $('#soc-sharing-fullscreen-overlay').addClass('active');
531    });
532    $('#soc-sharing-fullscreen-overlay').click(function() {
533        $('#soc-sharing-fullscreen-overlay').removeClass('active');
534    });
535
536    $('.user_rating_range').each(function() {
537        $(this).noUiSlider({
538    		range: {
539    			  'min': 0,
540    			  'max': 10
541    			},
542    		step: 1,
543    		start: 0,
544    		connect: "lower",
545    	});
546    	$(this).on({
547    		set: function(){
548    			var score_criteria = 0;
549    			var count_criterias = 0;
550                var nIndex = 0;
551    			$('.user_rating_range').each(function(i) {
552    				score_criteria += parseInt($(this).val());
553    				count_criterias ++;
554    			});
555    			var average_criteria = Math.round(score_criteria / count_criterias) ;
556    			$('.user_total_score span').html(average_criteria);
557                $(".raty_criteria_score_"+$(this).attr('data-index')).attr("data-score", parseInt($(this).val()));
558    		}
559    	});
560    });
561
562    $("#comment-user-reviews").find(".user_rating_range").each(function(i) {
563        $(this).Link('lower').to($(".user_criteria_hidden_"+(i+1)), null, wNumb({decimals: 0}));
564    	$(this).Link('lower').to($(".raty_criteria_score_"+(i+1)), null, wNumb({decimals: 0}));
565    });
566
567})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.