PageSourceSearch

https://tudorondonia.com/javascript/main.js?700

js tudorondonia.com collected 2026-10-02 11:22:21 UTC 23,882 bytes, 622 lines download raw bytes

1
2/**
3  * Tap Mobile Device
4  * Animation
5  * Go Top Button
6  * Lastest Tweets
7  * Tabs
8  * Toggles
9  * Galleries
10  * Dropdown List
11  * Simple Slider
12  * Slider
13  * Handle Search Form
14  * Handle Panel Toggle
15  * Mega Menu
16  * Detect Viewport
17  * Hide Navigation
18  * Scroll Bar
19  * Login Popup
20  * Google Map
21  * Ajax Contact Form
22  * Responsive Menu
23  * Mailchimp Subscribe
24*/
25
26;(function($) {
27
28   'use strict'
29
30    var tapMobile = function() {
31        $('.mainnav li:has(ul)').doubleTapToGo();
32    };
33
34    var gnAnimation = function() {
35        $('.gn-animation').each( function() {
36            var gnElement = $(this),
37            gnAnimationClass = gnElement.data('animation'),
38            gnAnimationDelay = gnElement.data('animation-delay'),
39            gnAnimationOffset = gnElement.data('animation-offset');
40
41            gnElement.css({
42                '-webkit-animation-delay':  gnAnimationDelay,
43                '-moz-animation-delay':     gnAnimationDelay,
44                'animation-delay':          gnAnimationDelay
45            });
46
47            gnElement.waypoint(function() {
48                gnElement.addClass('animated').addClass(gnAnimationClass);
49            },{ triggerOnce: true, offset: gnAnimationOffset });
50        });
51    };
52
53    var goTop = function() {
54        $(window).scroll(function() {
55            if ( $(this).scrollTop() > 800 ) {
56                $('.go-top').addClass('show');
57            } else {
58                $('.go-top').removeClass('show');
59            }
60        }); 
61
62        $('.go-top').on('click', function() {
63            $("html, body").animate({ scrollTop: 0 }, 1000 , 'easeInOutExpo');
64            return false;
65        });
66    };
67
68    var lastestTweets = function() {
69        if ( $().tweet ) {
70            $('.latest-tweets').each(function() {
71                var $this = $(this);
72
73                $this.tweet({
74                    username: $this.data('username'),
75                    join_text: "auto",
76                    avatar_size: null,
77                    count: $this.data('number'),
78                    template: "{text}{time}",
79                    loading_text: "loading tweets...",
80                    modpath: $this.data('modpath')      
81                }); // tweet
82            }); // lastest-tweets each
83        }
84    };
85
86    var tabs = function() {
87        $('.tabs').each(function() {
88            $(this).children('.content-tab').children().hide();
89            $(this).children('.content-tab').children().first().show();
90            $(this).find('.menu-tab').children('li').on('click', function(e) {  
91                var liActive = $(this).index(),
92                	contentActive = $(this).siblings().removeClass('active').parents('.tabs').children('.content-tab').children().eq(liActive);
93
94                contentActive.addClass('active').fadeIn('slow');
95                contentActive.siblings().removeClass('active');
96                $(this).addClass('active').parents('.tabs').children('.content-tab').children().eq(liActive).siblings().hide();
97                e.preventDefault();
98            });
99        });
100    };
101
102    var toggles = function() {
103        var args = {duration: 400};
104
105        $('.toggle .toggle-title.active').siblings('.toggle-content').show();
106        $('.toggle.toggle-enable .toggle-title').on('click', function() {
107            $(this).closest('.toggle').find('.toggle-content').slideToggle(args);
108            $(this).toggleClass('active');
109        }); // toggle 
110
111        $('.accordion .toggle-title').on('click', function () {
112            if( !$(this).is('.active') ) {
113                $(this).closest('.accordion').find('.toggle-title.active').toggleClass('active').next().slideToggle(args);
114                $(this).toggleClass('active');
115                $(this).next().slideToggle(args);
116            } else {
117                $(this).toggleClass('active');
118                $(this).next().slideToggle(args);
119            }     
120        }); // accordion
121    };
122
123    var gnGallery = function() {
124        $('.gn-gallery').each(function(){
125            $(this).children('#gn-carousel').flexslider({
126                animation: "slide",
127                controlNav: false,
128                animationLoop: false,
129                slideshow: false,
130                itemWidth: 92,
131                itemMargin: 5,
132                asNavFor: $(this).children('#gn-slider'),
133                prevText: '<i class="fa fa-caret-left"></i>',
134                nextText: '<i class="fa fa-caret-right"></i>'
135            });
136            $(this).children('#gn-slider').flexslider({
137                animation: "slide",
138                controlNav: false,
139                animationLoop: false,
140                slideshow: false,
141                sync: $(this).children('#gn-carousel'),
142                prevText: '<i class="fa fa-angle-left"></i>',
143                nextText: '<i class="fa fa-angle-right"></i>'
144            });
145        });
146    };
147
148    var dropList = function() {
149        $('.drop-list').each(function() {
150            var menuDrop = $(this).children('.nav-dropdown'),
151                activeDrop = $(this).find('.drop-wrap');
152
153            menuDrop.on('click', function () {
154                var drop = $(this).children('.dropdown');
155
156                if ( drop.is(".show") ) {
157                    drop.removeClass('show');
158                    activeDrop.removeClass('active');
159                } else {
160                    drop.addClass('show');
161                    activeDrop.addClass('active');
162                }
163                return false;
164            });
165
166            $(document).on('click', function() {
167                menuDrop.children('.dropdown').removeClass('show');
168                activeDrop.removeClass('active');
169            });
170        });
171    };
172
173   var gnSimpleSlider = function() {
174      if ( $().flexslider ) {
175         $('.simple-slider').each(function() {
176            var $this = $(this);
177            var easing = ( $this.data('effect') == 'fade' ) ? 'linear' : 'easeInOutExpo';
178            $this.find('.flexslider').flexslider({
179               animation      :  $this.data('effect'),
180               direction      :  $this.data('direction'), // vertical
181               pauseOnHover   :  true,
182               useCSS         :  false,
183               easing         :  easing,
184               animationSpeed :  500,
185               slideshowSpeed :  5000,
186               controlNav     :  true,
187               directionNav   :  false,
188               smoothHeight   :  true,
189               slideshow      :  $this.data('auto'),
190               prevText    :  '<i class="fa fa-angle-left"></i>',
191               nextText    :  '<i class="fa fa-angle-right"></i>'
192            }); // flexslider
193         }); // or-slider each
194      }
195   };
196
197    var gnSlider = function() {
198        $('.gnSlider .flexslider').flexslider({
199            animation: 'fade',
200            animationLoop: true,
201            slideshow: true,
202            slideshowSpeed: 8000,
203            animationSpeed: 800,
204            pauseOnHover: true, 
205            pauseOnAction:true,
206            controlNav: true,
207            directionNav: true,
208            prevText: '<i class="fa fa-angle-left"></i>',
209            nextText: '<i class="fa fa-angle-right"></i>',
210            controlsContainer: '.flex-container',
211            start: function(slider) {
212                var bottomtext = $('.gnSlider .flex-active-slide .item').data('bottomtext');
213
214                $('.gnSlider .flex-active-slide').find('.item').css({ bottom: bottomtext });
215                $('.gnSlider .flex-active-slide').find('.item').transition({ left: '0', opacity: '1'}, 1000);
216                // remove class loading after start
217                slider.removeClass('loading');
218            },
219            before: function(slider) {
220                $('.gnSlider .flex-active-slide').find('.item').transition({ left: '-100%', opacity: '0'}, 1000);
221            },
222            after: function(slider) {
223                var bottomtext = $('.gnSlider .flex-active-slide .item').data('bottomtext');
224
225                $('.gnSlider .flex-active-slide').find('.item').css({ bottom: bottomtext});
226                $('.gnSlider .flex-active-slide').find('.item').transition({ left: '0', opacity: '1'}, 1000);
227            }
228        });
229    };
230
231    var searchHandle = function() {
232        $('.hide-navigation .search-icon').on('click', function() {
233            var searchForm = $(this).parent().find('.search-form'),
234                searchField = $(this).parent().find('.search-field');
235
236            searchForm.stop(true, true).fadeToggle(function () {
237                searchField.focus();
238            });
239
240            $('.search-field').on('click', function(e) {
241                e.stopPropagation();
242            })
243        });
244
245        $('.search-wrap .search-icon').on('click', function() {
246            var searchForm = $(this).parent().find('.search-form'),
247                searchField = $(this).parent().find('.search-field');
248
249            searchForm.fadeIn(function () {
250                searchForm.find('.search-field').focus();
251            });
252        });
253
254        $('.search-wrap .search-close').on('click', function() {
255            $(this).parent().fadeOut();
256        });
257
258        $(window).resize(function() {
259            if ( $('.search-wrap .search-form').is(':hidden') ) {
260                $('.search-wrap .search-form').removeAttr('style');
261            }
262        });
263
264        $(document).on('click', function(e) {
265            var clickID = e.target.id;
266
267            if ( clickID != 'search-text-menu' ) {
268                $(".search-text-menu").animate({
269                    width:'1px',
270                    },200,function(){
271                        $(this).css( 'paddingLeft','41px');
272                    });
273            } else {
274				$(".search-text-menu").animate({
275	                width:'282px',
276	                },200,function(){
277	                    $(this).css( 'paddingLeft','55px');
278	                });
279            }
280        });
281    };
282
283    var changePanel = function() {
284        (function() {
285            function handlePanel() {
286                var typePanel = "normal";
287
288                if ( matchMedia('only screen and (max-width: 991px)').matches ) {
289                    typePanel = "float";
290                }
291                if ( $('body').hasClass('change-panel') ) {
292                    
293                    if ( typePanel === "float" ) {
294                        var $mobilePanel = $('#sidebar2').hide();
295
296                        $('body').addClass('floatPanel').append($mobilePanel);
297                        $('#sidebar2, .toggle-panel').removeAttr('style');
298                        $('.toggle-panel').css({
299                            'top': $(window).height() / 2,
300                            'marginTop' : '-46px'
301                        });
302                    } else {
303                        var $normalPanel = $('#sidebar2');
304
305                        $('.article-endless').find('.col-md-4').append($normalPanel);
306                        $('body').removeClass('floatPanel');
307                        $('.toggle-panel').hide();
308                    }
309                }
310            }
311            $(window).on("resize", handlePanel);
312            $(document).on("ready", handlePanel);
313        })();
314        (function(){
315            $('.toggle-panel').on('click', function(e) {
316                if ( $("#sidebar2").css("left") === "-300px" ) {
317                    $("#sidebar2").animate({ left: "0" }, 300, 'easeInOutExpo')
318                } else {
319                    $("#sidebar2").animate({ left: "-300px" }, 300, 'easeInOutExpo')
320                }
321                e.preventDefault();
322            });
323        })();
324    };
325
326    var megaMenu = function(winWidth) {
327        if ( $('.gn-mega-menu').size() != 0 ) {
328            var item = $('.gn-mega-menu'),
329                megaMenuLeft = item.offset().left;
330
331            item.children('.sub-menu').css({
332                'width' : $(window).width(),
333                'margin-left' : - megaMenuLeft
334            });
335        }
336    };
337
338    var detectViewport = function() {
339        $('[data-waypoint-active="yes"]').waypoint(function() {
340            $(this).trigger('on-appear');
341        }, { offset: '90%' });
342
343        $(window).on('load', function() {
344            setTimeout(function() {
345                $.waypoints('refresh');
346            }, 100);
347        });
348    };
349
350    var hideMenu = function() {
351        $('#hide-menu').on('click', function(e) {
352            if ( $("#navigation-panel").css("left") === "-215px" ) {
353                $("#navigation-panel").animate({ left: "0" }, 300, 'easeInOutExpo')
354            } else {
355                $("#navigation-panel").animate({ left: "-215px" }, 300, 'easeInOutExpo')
356            }
357            e.preventDefault();
358        });
359
360        $('.close-nav').on('click', function() {
361            $("#navigation-panel").animate({ left: "-215px" }, 200, 'easeInOutExpo');
362        });
363    };
364
365    var scrollBar = function() {
366        if ( $().mCustomScrollbar ) {
367           $(".tabs.style2 .content-tab.scroll .content").mCustomScrollbar();
368        }
369    };
370
371    var popupForm = function() {
372        if ( $().leanModal ) {
373            $('.login-popup > a, .signup-popup > a').leanModal({
374                top: 110,
375                overlay: 0.5,
376                closeButton: ".close-modal"
377            });
378            $('#login-modal').submit(function(e) {
379                return false;
380            });
381        }
382    };
383
384    var googleMap = function() {
385        if ( $().gmap3 ) {
386            $("#map").gmap3({
387                map:{
388                    options:{
389                        zoom: 17,
390                        mapTypeId: 'goodnews_style',
391                        mapTypeControlOptions: {
392                            mapTypeIds: ['goodnews_style', google.maps.MapTypeId.SATELLITE, google.maps.MapTypeId.HYBRID]
393                        },
394                        scrollwheel: false
395                    }
396                },
397                getlatlng:{
398                    address:  "3 London Rd London SE1 6JZ United Kingdom",
399                    callback: function(results) {
400                        if ( !results ) return;
401                        $(this).gmap3('get').setCenter(new google.maps.LatLng(results[0].geometry.location.lat(), results[0].geometry.location.lng()));
402                        $(this).gmap3({
403                            marker:{
404                                latLng:results[0].geometry.location
405                            }
406                        });
407                    }
408                },
409                styledmaptype:{
410                    id: "goodnews_style",
411                    options:{
412                        name: "Good News Map"
413                    },
414                },
415            });
416        }
417    };
418
419    var ajaxContactForm = function() {
420        $('.contact-form').each(function() {
421            var $this = $(this);
422
423            $this.submit(function() {
424                var str = $this.serialize();
425                $.ajax({
426                    type: "POST",
427                    url:  $this.attr('action'),
428                    data: str,
429                    success: function(msg) {
430                        var result;
431
432                        if ( msg == 'OK' ) {
433                            result = '<div class="alert alert-success">Thank you! Your message has been successfully sent.</div>';
434                        } else {
435                            result = msg;
436                        }
437                        result = '<div class="result">' + result + '</div>';
438                        $this.find('.note').hide().html(result).fadeIn('slow');
439                    }
440                });
441                return false;
442            });
443        });
444    };
445
446    var responsiveMenu = {
447
448        menuType: 'desktop',
449
450        initial: function(winWidth) {
451            responsiveMenu.menuWidthDetect(winWidth);
452            responsiveMenu.menuBtnClick();
453            responsiveMenu.parentMenuClick();
454        },
455
456        menuWidthDetect: function(winWidth) {
457            var currMenuType = 'desktop';
458
459            if ( matchMedia('only screen and (max-width: 767px)').matches ) {
460                currMenuType = 'mobile';
461            } // change menu type
462
463            if ( currMenuType !== responsiveMenu.menuType ) {
464                responsiveMenu.menuType = currMenuType;
465
466                if ( currMenuType === 'mobile' ) {
467                    var $mobileMenu = $('#mainnav').attr('id', 'mainnav-mobi').hide();
468                    var hasChildMenu = $('#mainnav-mobi').find('li.has-children'),
469                        hasChildMenuMega = $('#mainnav-mobi').find('li.gn-mega-menu');
470
471                    $('#header').find('.header-wrap').after($mobileMenu);
472                    $('.header-wrap').hide();
473                    hasChildMenu.children('ul').hide();
474                    hasChildMenuMega.children('.sub-menu').hide();
475                    hasChildMenu.children('a').after('<span class="btn-submenu"></span>');
476                    hasChildMenuMega.children('a').after('<span class="btn-submenu"></span>');
477                    /*$('#mainnav-mobi').children('.menu').prepend('<li class="added menu-addon"><span class="signup-link"><a href="login.html">Become a member</a></span><span class="login-link"><a href="login.html">Login</a></span></li>');*/
478                    $('#mainnav-mobi').children('.menu').append('<li class="added"><div id="search-form-menu"><form action="/buscar" method="get"><input type="text" class="search-text-menu" id="s" name="s"></form></div><div class="social-mobi"><a href="https://www.facebook.com/jornaltudorondonia/" target="_blank"><i class="fa fa-facebook"></i></a><a href="https://twitter.com/tudorondoniacom" target="_blank"><i class="fa fa-twitter"></i></a><a href="https://plus.google.com/105982566970719380039" target="_blank"><i class="fa fa-google-plus"></i></a></div></li>');
479                    $('.btn-menu').removeClass('active');
480                 } else {
481                    var $desktopMenu = $('#mainnav-mobi').attr('id', 'mainnav').removeAttr('style');
482
483                    $desktopMenu.find('.sub-menu').removeAttr('style');
484                    $('.header-wrap').removeAttr('style');
485                    $('#header').find('.col-md-9').append($desktopMenu);
486                    $('.btn-submenu').remove()
487                    $('.added').remove();
488                }
489            } // clone and insert menu
490        },
491
492        menuBtnClick: function() {
493            $('.btn-menu').on('click', function() {
494                $('#mainnav-mobi').slideToggle(300);
495                $(this).toggleClass('active');
496            });
497        }, // click on moblie button
498
499        parentMenuClick: function() {
500            $(document).on('click', '#mainnav-mobi li .btn-submenu', function(e) {
501                if ( $(this).has('.sub-menu') ) {
502                    e.stopImmediatePropagation()
503                    $(this).next('.sub-menu').slideToggle(300);
504                    $(this).toggleClass('active');
505                    $(this).parent('.has-children, .gn-mega-menu').toggleClass('active');
506                }
507            });
508        } // click on sub-menu button
509    };
510
511    var ajaxSubscribe = {
512        obj: {
513            subscribeEmail    : $('#subscribe-email'),
514            subscribeButton   : $('#subscribe-button'),
515            subscribeMsg      : $('#subscribe-msg'),
516            subscribeContent  : $("#subscribe-content"),
517            dataMailchimp     : $('#subscribe-form').attr('data-mailchimp'),
518            success_message   : '<div class="notification_ok">Thank you for joining our mailing list! Please check your email for a confirmation link.</div>',
519            failure_message   : '<div class="notification_error">Error! <strong>There was a problem processing your submission.</strong></div>',
520            noticeError       : '<div class="notification_error">{msg}</div>',
521            noticeInfo        : '<div class="notification_error">{msg}</div>',
522            basicAction       : 'mail/subscribe.php',
523            mailChimpAction   : 'mail/subscribe-mailchimp.php'
524        },
525
526        eventLoad: function() {
527            var objUse = ajaxSubscribe.obj;
528
529            $(objUse.subscribeButton).on('click', function() {
530                if ( window.ajaxCalling ) return;
531                var isMailchimp = objUse.dataMailchimp === 'true';
532
533                if ( isMailchimp ) {
534                    ajaxSubscribe.ajaxCall(objUse.mailChimpAction);
535                } else {
536                    ajaxSubscribe.ajaxCall(objUse.basicAction);
537                }
538            });
539        },
540
541        ajaxCall: function (action) {
542            window.ajaxCalling = true;
543            var objUse = ajaxSubscribe.obj;
544            var messageDiv = objUse.subscribeMsg.html('').hide();
545            $.ajax({
546                url: action,
547                type: 'POST',
548                dataType: 'json',
549                data: {
550                   subscribeEmail: objUse.subscribeEmail.val()
551                },
552                success: function (responseData, textStatus, jqXHR) {
553                    if ( responseData.status ) {
554                        objUse.subscribeContent.fadeOut(500, function () {
555                            messageDiv.html(objUse.success_message).fadeIn(500);
556                        });
557                    } else {
558                        switch (responseData.msg) {
559                            case "email-required":
560                                messageDiv.html(objUse.noticeError.replace('{msg}
560','Error! <strong>Email is required.</strong>'));
561                                break;
562                            case "email-err":
563                                messageDiv.html(objUse.noticeError.replace('{msg}','Error! <strong>Email invalid.</strong>'));
564                                break;
565                            case "duplicate":
566                                messageDiv.html(objUse.noticeError.replace('{msg}','Error! <strong>Email is duplicate.</strong>'));
567                                break;
568                            case "filewrite":
569                                messageDiv.html(objUse.noticeInfo.replace('{msg}','Error! <strong>Mail list file is open.</strong>'));
570                                break;
571                            case "undefined":
572                                messageDiv.html(objUse.noticeInfo.replace('{msg}','Error! <strong>undefined error.</strong>'));
573                                break;
574                            case "api-error":
575                                objUse.subscribeContent.fadeOut(500, function () {
576                                    messageDiv.html(objUse.failure_message);
577                                });
578                        }
579                        messageDiv.fadeIn(500);
580                    }
581                },
582                error: function (jqXHR, textStatus, errorThrown) {
583                    alert('Connection error');
584                },
585                complete: function (data) {
586                    window.ajaxCalling = false;
587                }
588            });
589        }
590    };
591
592    // Dom Ready
593    $(function() {
594        tapMobile();
595        detectViewport();
596        gnSimpleSlider();
597        gnSlider();
598        gnGallery();
599        hideMenu();
600        scrollBar();
601        dropList();
602        tabs();
603        changePanel();
604        toggles();
605        searchHandle();
606        popupForm();
607        gnAnimation();
608        goTop()
609        googleMap();
610        ajaxContactForm();
611        ajaxSubscribe.eventLoad();
612        // Initialize responsive and mega menu
613        responsiveMenu.initial($(window).width());
614        megaMenu($(window).width());
615        $(window).resize(function() {
616            responsiveMenu.menuWidthDetect($(this).width());
617            megaMenu($(window).width());
618        });
619        lastestTweets();
620   });
621
622})(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.