PageSourceSearch

https://elagamestudio.com/js/main.js

js elagamestudio.com collected 2026-10-08 13:00:44 UTC 14,055 bytes, 472 lines download raw bytes

1/* ===================================================================
2 * Glint - Main JS
3 *
4 * ------------------------------------------------------------------- */
5
6(function($) {
7
8    "use strict";
9    
10    var cfg = {
11        scrollDuration : 800, // smoothscroll duration
12        mailChimpURL   : 'https://facebook.us8.list-manage.com/subscribe/post?u=cdb7b577e41181934ed6a6a44&id=e6957d85dc'   // mailchimp url
13    },
14
15    $WIN = $(window);
16
17    // Add the User Agent to the <html>
18    // will be used for IE10 detection (Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0))
19    var doc = document.documentElement;
20    doc.setAttribute('data-useragent', navigator.userAgent);
21
22
23   /* Preloader
24    * -------------------------------------------------- */
25    var clPreloader = function() {
26        
27        $("html").addClass('cl-preload');
28
29        $WIN.on('load', function() {
30
31            //force page scroll position to top at page refresh
32            // $('html, body').animate({ scrollTop: 0 }, 'normal');
33
34            // will first fade out the loading animation 
35            $("#loader").fadeOut("slow", function() {
36                // will fade out the whole DIV that covers the website.
37                $("#preloader").delay(300).fadeOut("slow");
38            }); 
39            
40            // for hero content animations 
41            $("html").removeClass('cl-preload');
42            $("html").addClass('cl-loaded');
43        
44        });
45    };
46
47
48   /* Menu on Scrolldown
49    * ------------------------------------------------------ */
50    var clMenuOnScrolldown = function() {
51        
52        var menuTrigger = $('.header-menu-toggle');
53
54        $WIN.on('scroll', function() {
55
56            if ($WIN.scrollTop() > 150) {
57                menuTrigger.addClass('opaque');
58            }
59            else {
60                menuTrigger.removeClass('opaque');
61            }
62
63        });
64    };
65
66
67   /* OffCanvas Menu
68    * ------------------------------------------------------ */
69    var clOffCanvas = function() {
70
71        var menuTrigger     = $('.header-menu-toggle'),
72            nav             = $('.header-nav'),
73            closeButton     = nav.find('.header-nav__close'),
74            siteBody        = $('body'),
75            mainContents    = $('section, footer');
76
77        // open-close menu by clicking on the menu icon
78        menuTrigger.on('click', function(e){
79            e.preventDefault();
80            // menuTrigger.toggleClass('is-clicked');
81            siteBody.toggleClass('menu-is-open');
82        });
83
84        // close menu by clicking the close button
85        closeButton.on('click', function(e){
86            e.preventDefault();
87            menuTrigger.trigger('click');	
88        });
89
90        // close menu clicking outside the menu itself
91        siteBody.on('click', function(e){
92            if( !$(e.target).is('.header-nav, .header-nav__content, .header-menu-toggle, .header-menu-toggle span') ) {
93                // menuTrigger.removeClass('is-clicked');
94                siteBody.removeClass('menu-is-open');
95            }
96        });
97
98    };
99
100
101   /* photoswipe
102    * ----------------------------------------------------- */
103    var clPhotoswipe = function() {
104        var items = [],
105            $pswp = $('.pswp')[0],
106            $folioItems = $('.item-folio');
107
108            // get items
109            $folioItems.each( function(i) {
110
111                var $folio = $(this),
112                    $thumbLink =  $folio.find('.thumb-link'),
113                    $title = $folio.find('.item-folio__title'),
114                    $caption = $folio.find('.item-folio__caption'),
115                    $titleText = '<h4>' + $.trim($title.html()) + '</h4>',
116                    $captionText = $.trim($caption.html()),
117                    $href = $thumbLink.attr('href'),
118                    $size = $thumbLink.data('size').split('x'),
119                    $width  = $size[0],
120                    $height = $size[1];
121         
122                var item = {
123                    src  : $href,
124                    w    : $width,
125                    h    : $height
126                }
127
128                if ($caption.length > 0) {
129                    item.title = $.trim($titleText + $captionText);
130                }
131
132                items.push(item);
133            });
134
135            // bind click event
136            $folioItems.each(function(i) {
137
138                $(this).on('click', function(e) {
139                    e.preventDefault();
140                    var options = {
141                        index: i,
142                        showHideOpacity: true
143                    }
144
145                    // initialize PhotoSwipe
146                    var lightBox = new PhotoSwipe($pswp, PhotoSwipeUI_Default, items, options);
147                    lightBox.init();
148                });
149
150            });
151
152    };
153    
154
155   /* Stat Counter
156    * ------------------------------------------------------ */
157    var clStatCount = function() {
158        
159        var statSection = $(".about-stats"),
160            stats = $(".stats__count");
161
162        statSection.waypoint({
163
164            handler: function(direction) {
165
166                if (direction === "down") {
167
168                    stats.each(function () {
169                        var $this = $(this);
170
171                        $({ Counter: 0 }).animate({ Counter: $this.text() }, {
172                            duration: 4000,
173                            easing: 'swing',
174                            step: function (curValue) {
175                                $this.text(Math.ceil(curValue));
176                            }
177                        });
178                    });
179
180                } 
181
182                // trigger once only
183                this.destroy();
184
185            },
186
187            offset: "90%"
188
189        });
190    };
191
192
193   /* Masonry
194    * ---------------------------------------------------- */ 
195    var clMasonryFolio = function () {
196        
197        var containerBricks = $('.masonry');
198
199        containerBricks.imagesLoaded(function () {
200            containerBricks.masonry({
201                itemSelector: '.masonry__brick',
202                resize: true
203            });
204        });
205    };
206
207
208   /* slick slider
209    * ------------------------------------------------------ */
210    var clSlickSlider = function() {
211
212        $('.clients').slick({
213            arrows: false,
214            dots: true,
215            infinite: true,
216            slidesToShow: 6,
217            slidesToScroll: 2,
218            //autoplay: true,
219            pauseOnFocus: false,
220            autoplaySpeed: 1000,
221            responsive: [
222                {
223                    breakpoint: 1200,
224                    settings: {
225                        slidesToShow: 5
226                    }
227                },
228                {
229                    breakpoint: 1000,
230                    settings: {
231                        slidesToShow: 4
232                    }
233                },
234                {
235                    breakpoint: 800,
236                    settings: {
237                        slidesToShow: 3,
238                        slidesToScroll: 2
239                    }
240                },
241                {
242                    breakpoint: 500,
243                    settings: {
244                        slidesToShow: 2,
245                        slidesToScroll: 2
246                    }
247                }
248
249            ]
250        });
251
252        $('.testimonials').slick({
253            arrows: true,
254            dots: false,
255            infinite: true,
256            slidesToShow: 1,
257            slidesToScroll: 1,
258            adaptiveHeight: true,
259            pauseOnFocus: false,
260            autoplaySpeed: 1500,
261            responsive: [
262                {
263                    breakpoint: 900,
264                    settings: {
265                        slidesToShow: 1,
266                        slidesToScroll: 1
267                    }
268                },
269                {
270                    breakpoint: 800,
271                    settings: {
272                        arrows: false,
273                        dots: true
274                    }
275                }
276            ]
277        });
278    
279    };
280
281   /* Smooth Scrolling
282    * ------------------------------------------------------ */
283    var clSmoothScroll = function() {
284        
285        $('.smoothscroll').on('click', function (e) {
286            var target = this.hash,
287            $target    = $(target);
288            
289                e.preventDefault();
290                e.stopPropagation();
291
292            $('html, body').stop().animate({
293                'scrollTop': $target.offset().top
294            }, cfg.scrollDuration, 'swing').promise().done(function () {
295
296                // check if menu is open
297                if ($('body').hasClass('menu-is-open')) {
298                    $('.header-menu-toggle').trigger('click');
299                }
300
301                window.location.hash = target;
302            });
303        });
304
305    };
306
307
308   /* Placeholder Plugin Settings
309    * ------------------------------------------------------ */
310    var clPlaceholder = function() {
311        $('input, textarea, select').placeholder();  
312    };
313
314
315   /* Alert Boxes
316    * ------------------------------------------------------ */
317    var clAlertBoxes = function() {
318
319        $('.alert-box').on('click', '.alert-box__close', function() {
320            $(this).parent().fadeOut(500);
321        }); 
322
323    };
324
325
326   /* Contact Form
327    * ------------------------------------------------------ */
328    var clContactForm = function() {
329        
330        /* local validation */
331        $('#contactForm').validate({
332        
333            /* submit via ajax */
334            submitHandler: function(form) {
335    
336                var sLoader = $('.submit-loader');
337    
338                $.ajax({
339    
340                    type: "POST",
341                    url: "inc/sendEmail.php",
342                    data: $(form).serialize(),
343                    beforeSend: function() { 
344    
345                        sLoader.slideDown("slow");
346    
347                    },
348                    success: function(msg) {
349    
350                        // Message was sent
351                        if (msg == 'OK') {
352                            sLoader.slideUp("slow"); 
353                            $('.message-warning').fadeOut();
354                            $('#contactForm').fadeOut();
355                            $('.message-success').fadeIn();
356                        }
357                        // There was an error
358                        else {
359                            sLoader.slideUp("slow"); 
360                            $('.message-warning').html(msg);
361                            $('.message-warning').slideDown("slow");
362                        }
363    
364                    },
365                    error: function() {
366    
367                        sLoader.slideUp("slow"); 
368                        $('.message-warning').html("Something went wrong. Please try again.");
369                        $('.message-warning').slideDown("slow");
370    
371                    }
372    
373                });
374            }
375    
376        });
377    };
378
379
380   /* Animate On Scroll
381    * ------------------------------------------------------ */
382    var clAOS = function() {
383        
384        AOS.init( {
385            offset: 200,
386            duration: 600,
387            easing: 'ease-in-sine',
388            delay: 300,
389            once: true,
390            disable: 'mobile'
391        });
392
393    };
394
395
396   /* AjaxChimp
397    * ------------------------------------------------------ */
398    var clAjaxChimp = function() {
399        
400        $('#mc-form').ajaxChimp({
401            language: 'es',
402            url: cfg.mailChimpURL
403        });
404
405        // Mailchimp translation
406        //
407        //  Defaults:
408        //	 'submit': 'Submitting...',
409        //  0: 'We have sent you a confirmation email',
410        //  1: 'Please enter a value',
411        //  2: 'An email address must contain a single @',
412        //  3: 'The domain portion of the email address is invalid (the portion after the @: )',
413        //  4: 'The username portion of the email address is invalid (the portion before the @: )',
414        //  5: 'This email address looks fake or invalid. Please enter a real email address'
415
416        $.ajaxChimp.translations.es = {
417            'submit': 'Submitting...',
418            0: '<i class="fa fa-check"></i> We have sent you a confirmation email',
419            1: '<i class="fa fa-warning"></i> You must enter a valid e-mail address.',
420            2: '<i class="fa fa-warning"></i> E-mail address is not valid.',
421            3: '<i class="fa fa-warning"></i> E-mail address is not valid.',
422            4: '<i class="fa fa-warning"></i> E-mail address is not valid.',
423            5: '<i class="fa fa-warning"></i> E-mail address is not valid.'
424        } 
425
426    };
427
428
429   /* Back to Top
430    * ------------------------------------------------------ */
431    var clBackToTop = function() {
432        
433        var pxShow  = 500,         // height on which the button will show
434        fadeInTime  = 400,         // how slow/fast you want the button to show
435        fadeOutTime = 400,         // how slow/fast you want the button to hide
436        scrollSpeed = 300,         // how slow/fast you want the button to scroll to top. can be a value, 'slow', 'normal' or 'fast'
437        goTopButton = $(".go-top")
438        
439        // Show or hide the sticky footer button
440        $(window).on('scroll', function() {
441            if ($(window).scrollTop() >= pxShow) {
442                goTopButton.fadeIn(fadeInTime);
443            } else {
444                goTopButton.fadeOut(fadeOutTime);
445            }
446        });
447    };
448
449
450   /* Initialize
451    * ------------------------------------------------------ */
452    (function ssInit() {
453        
454        clPreloader();
455        clMenuOnScrolldown();
456        clOffCanvas();
457        clPhotoswipe();
458        clStatCount();
459        clMasonryFolio();
460        clSlickSlider();
461        clSmoothScroll();
462        clPlaceholder();
463        clAlertBoxes();
464        clContactForm();
465        clAOS();
466        clAjaxChimp();
467        clBackToTop();
468
469    })();
470        
471        
472})(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.