PageSourceSearch

https://backyou.app/app/public/js/front_office/common/utils.js?v=2.00402

js backyou.app collected 2026-09-29 22:38:10 UTC 7,156 bytes, 233 lines download raw bytes

1/**
2 * DISPLAY TOGGLES
3 */
4
5$('.js-toggle-display').each(function () {
6    if(!$('[data-toggle-id="' + $(this).attr('data-target') + '"]').length) {
7        $(this).removeClass('js-toggle-display').find('.fas').remove();
8    }
9});
10
11$('body').on('click.toggleDisplay', '.js-toggle-display', function () {
12    $('[data-toggle-id="' + $(this).attr('data-target') + '"]').toggleClass('d-none');
13    $(this).find('.fas').toggleClass('fa-plus').toggleClass('fa-minus');
14});
15
16copy2clipboard = function(textToCopy) {
17    if (navigator.clipboard && window.isSecureContext) {
18        return new Promise((res, rej) => {
19            // navigator clipboard api method'
20            navigator.clipboard.writeText(textToCopy)
21            res();
22        })
23        .then(nav.infos('success_copy_text'.trad()));
24    } else {
25        // text area method
26        let textArea = document.createElement("textarea");
27        textArea.value = textToCopy;
28        // make the textarea out of viewport
29        textArea.style.position = "fixed";
30        textArea.style.left = "-999999px";
31        textArea.style.top = "-999999px";
32        document.body.appendChild(textArea);
33        textArea.focus();
34        textArea.select();
35        return new Promise((res, rej) => {
36            // here the magic happens
37            document.execCommand('copy') ? res() : rej();
38            textArea.remove();
39            $('.js-infos-container').remove();
40        })
41        .then(nav.infos('success_copy_text'.trad()));
42    }
43}
44
45
46/**
47 * Smooth scroll anchor links
48 */
49var speed = 1000;
50
51// Find links that are #anchors and scroll to them
52/*$('a[href^="#"]')
53    .not('.lp-pom-form .lp-pom-button')
54    .unbind('click.smoothScroll')
55    .bind('click.smoothScroll', function(event) {
56        event.preventDefault();
57        var href = $(this).attr('href').split('#');
58        console.log(href.length)
59        if($.trim(href[1])=="")return false;
60        $('html, body').animate({ scrollTop: $('#' + href[1]).offset().top - $(window).height()*1/3}, speed);
61    });*/
62
63$('.js-go-top').click(function() { $('html,body').animate({scrollTop: 0}, speed); })
64
65
66var browser = (function (agent) {
67        switch (true) {
68            case agent.indexOf("edge") > -1: return "edge";
69            case agent.indexOf("edg") > -1: return "chromium based edge (dev or canary)";
70            case agent.indexOf("opr") > -1 && !!window.opr: return "opera";
71            case agent.indexOf("chrome") > -1 && !!window.chrome: return "chrome";
72            case agent.indexOf("trident") > -1: return "ie";
73            case agent.indexOf("firefox") > -1: return "firefox";
74            case agent.indexOf("safari") > -1: return "safari";
75            default: return "other";
76        }
77})(window.navigator.userAgent.toLowerCase());
78
79function diagonal(){
80    var die=false;
81    var W=$(window).width();
82    if(browser=='edge' || browser=='ie' ){
83        H=0;
84        die=true;
85    }else{
86         var tan=Math.tan( 3* Math.PI / 180);
87        var h=tan*W;
88        var delta=13;
89        var H=Math.round(2*delta+h);
90    }
91   if(die)return;
92
93     var shapes={
94        'diagonal_bar_after':[
95            [
96                [0,1],
97                [1,1],
98                [1,(1-(h/H))],
99                [0,1]
100            ],
101            [
102                [0,(1-(delta/H))],
103                [1,(delta/H)],
104                [1,0],
105                [0,(1-(2*delta/H))]
106            ]
107        ],
108        'diagonal_bar_before':[
109            [
110                [0,0],
111                [0,h/H],
112                [1,0],
113                [0,0]
114            ],
115            [
116                [0,(h+delta)/H],
117                [0,(h+2*delta)/H],
118                [1,(2*delta)/H],
119                [1,delta/H]
120            ]
121        ],
122        'diagonal_inverse_after':[
123            [
124                [0,(H-h)/H],
125                [1,1],
126                [1,1]
127            ]
128        ],
129        'diagonal_inverse_before':[
130            [
131                [0,0],
132                [1,h/H],
133                [1,0],
134                [0,0]
135            ]
136        ]
137
138     }
139    shapes.diagonal_after=[ shapes.diagonal_bar_after[0]];
140    shapes.diagonal_before=[ shapes.diagonal_bar_before[0]];
141
142    var render={};
143    // construction des shapes
144    for(var i in shapes){
145        render[i]={svg:[],path:[]};
146        for(var points in shapes[i]){
147             render[i].path[points]=[];
148             render[i].svg[points]=[];
149            for(var point in shapes[i][points]){
150                render[i].svg[points][point]=[];
151                render[i].path[points][point]=[];
152                for(var p in shapes[i][points][point]){
153                    render[i].svg[points][point][p]=shapes[i][points][point][p];
154                    var L=point==0 ?'M':'L';
155                    render[i].path[points][point][p]=(p==0?L:'')+Math.round((p==0? W :H)*shapes[i][points][point][p]*100)/100;
156                    //shapes[i][points][point][p]= shapes[i][points][point][p]*100+'%';
157                }
158                render[i].svg[points][point]=render[i].svg[points][point].join(',');
159                render[i].path[points][point]=render[i].path[points][point].join(',');
160            }
161            render[i].svg[points]=render[i].svg[points].join(' ');
162            render[i].path[points]=render[i].path[points].join(' ')+' Z';
163        }
164        render[i].path="'"+render[i].path.join(' ')+"'";
165    
166    }
167
168    //url for safari
169    var url={};
170    for(var i in render){
171        url['--'+i]= 'path('+render[i].path+')';
172       var $poly=$('#'+i).find('polygon');
173       $poly.each(function(index, el) {
174            $(this).attr('points', render[i].svg[index]);
175       });
176    }
177
178        //ajout des variables
179    $('.diagonal').each(function(index, el) {
180        var el=$(this).get(0);
181        el.style.setProperty('--height',H+'px'); 
182        el.style.setProperty('--padding',(H*2/3)+'px');
183        if(browser=='safari'){
184            for(var i in url)el.style.setProperty(i,url[i]); 
185        }      
186   });
187}
188
189
190var last_scroll =0;
191$(window).on('scroll', function () {
192    var scrollTop = $(window).scrollTop();
193    $('.js-animated-background').css({'background-position-y': scrollTop / 3});
194    $('.js-go-top').toggleClass('d-none', $(window).scrollTop() < 500);
195    last_scroll = scrollTop;
196
197});
198
199$( window ).resize(function() {
200   diagonal();
201   $(window).trigger('scroll');
202});
203diagonal();
204
205  
206/**
207 * Affihchage PDF sdans un nouvel onglet
208 * @param string url URL de la génération du PDF, cette URL doit retourner le PDF en base64
209 */
210function download_pdf(url) {
211	$.ajax({
212		'url':  url,
213		'dataType': 'text',
214		'method': 'POST',
215		'beforeSend': function () {
216			nav.wait(true);
217		},
218		complete: function(xhr, textStatus) {
219			nav.wait(false);
220		},
221		'success': function( pdf ) {		
222			var blank = window.open("","");
223			$(blank.document.body).append('<embed width="100%" height="100%" type="application/pdf" src="data:application/pdf;base64,'+pdf+'" />');
224		}
225	});
226    return false;
227}
228
229$.initialize("[data-download_pdf]", function(){
230    $(this).off('click.download_pdf').on('click.download_pdf', function(){
231        return download_pdf($(this).data('download_pdf'));
232    });
233});

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.