PageSourceSearch

https://www.traversiers.com/_assets/26dcebd1710e5fe9e47e5c1f9979e512/js/modules/login_box.js?1789147798

js traversiers.com collected 2026-09-24 20:00:23 UTC 3,809 bytes, 123 lines download raw bytes

1$(function(){
2    // Ouvrir/fermer le menu
3    var userMenu = $('.js--user-menu');
4    var userMenuBtn = $('.js--user-menu-btn');
5
6    var recaptchaLoaded = false;
7
8    userMenuBtn.on('click', function(e) {
9        var gardes = $('.login-box .login-garde');
10
11        e.stopPropagation();
12        if (userMenu.hasClass('open')) {
13            closeLoginBox();
14        } else {
15            userMenuBtn.attr('aria-expanded', 'true');
16            userMenu.addClass('open');
17            var focusables = $('.login-box a:not(".login-garde"), .login-box input');
18            focusables[0].focus();
19
20            if(!recaptchaLoaded){
21                recaptchaLoaded = true;
22                userMenu.find('[type=submit]').on('click', function(e){
23                    e.preventDefault();
24                    grecaptcha.ready(function(){
25                        grecaptcha.execute(grecaptcha_publickey, {action: 'submit'}).then(function (token) {
26                            userMenu.find("[name='login[recaptcha_value]']").val(token);
27                            userMenu.find('form')[0].submit();
28                        });
29                    })
30                })
31            }
32        }
33
34        gardes.on('focus', function() {
35            closeLoginBox();
36        });
37    });
38
39    userMenu.on('click', function(e) {
40        e.stopPropagation();
41    });
42
43
44    $('body').on('click', function(e){
45        if(userMenu.hasClass('open') && $(e.target).parents('.js--user-menu').length < 1){
46            closeLoginBox();
47        }
48    })
49
50    function closeLoginBox() {
51        userMenuBtn.attr('aria-expanded', 'false');
52        userMenu.removeClass('open');
53        userMenuBtn.focus();
54    }
55
56    var login_box_template = $("#template--header-login-box");
57    var guest_box_template = $("#template--header-guest-box");
58
59    if(login_box_template.length < 1){
60        return;
61    }
62    var parent_of_box = $(".js--user-menu-btn");
63    var login_box = $(login_box_template.html());
64    var guest_box = $(guest_box_template.html());
65
66    // Remove boxes templates from DOM
67    //login_box_template.detach();
68    //guest_box_template.detach();
69
70    // Afficher les noms de l'usager.
71    // Pourra prendre de la cache.
72    function refreshNames() {
73        STQ.eaProxy.getUserNames(function (data) {
74            if (data) {
75                var $header = login_box.find('.login-user-name').empty().text(data.firstname + " " + data.lastname);
76            }
77        });
78    }
79    refreshNames();
80
81    STQ.eaProxy.getConnected(function (connected) {
82        // Check if Google Analytics is loaded
83        if (window.ga && typeof _gaq !== "undefined") {
84            _gaq.push([
85                '_setCustomVar',
86                1,
87                'Connecté',
88                connected ? 'Oui' : 'Non',
89                2
90            ]);
91        }
92        if(connected){
93            STQ.eaProxy.getUrl('my_account', function(url){
94                login_box.find('.js--btn-my-account').attr("href", url);
95            });
96
97            STQ.eaProxy.getUrl('logout', function(url){
98                login_box.find('.js--btn-logout').attr("href", url);
99            });
100
101            parent_of_box.after(login_box);
102
103            refreshNames();
104
105        }else{
106            STQ.eaProxy.getUrl('signup', function(url){
107                guest_box.find('.js--btn-signup').attr("href", url);
108            });
109
110            STQ.eaProxy.getUrl('login_post', function(url){
111                var $form = guest_box.find('.js--form-login');
112                $form.attr('action', url);
113            });
114
115            STQ.eaProxy.getUrl('password_reset', function(url){
116                guest_box.find('.js--btn-password-lost').attr("href", url);
117            });
118            parent_of_box.after(guest_box);
119        }
120        STQ.resizeLoginBox();
121    });
122});
123

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.