PageSourceSearch

https://rfpeinture.com/wp-content/plugins/adncomm-core/assets/front/adn-share.js?ver=1.0.72

js rfpeinture.com collected 2026-10-09 22:11:29 UTC 4,346 bytes, 144 lines download raw bytes

1/**
2 * Tag dynamique Elementor « Partage ».
3 *
4 * Le tag rend une ancre sentinelle dans le href (#adn-share-native,
5 * #adn-share-copy, #adn-share-print) : on intercepte le clic et on partage
6 * la page courante.
7 */
8( function () {
9    'use strict';
10
11    var i18n = window.ADN_SHARE || {};
12    var toast = null;
13    var toastTimer = null;
14
15    // URL de la page, sans le hash ni les parametres de suivi.
16    function currentUrl() {
17        var url = new URL( window.location.href );
18
19        url.hash = '';
20        Array.from( url.searchParams.keys() ).forEach( function ( key ) {
21            if ( key.indexOf( 'utm_' ) === 0 || key === 'fbclid' || key === 'gclid' ) {
22                url.searchParams.delete( key );
23            }
24        } );
25
26        return url.toString();
27    }
28
29    function copyFallback( text ) {
30        var textarea = document.createElement( 'textarea' );
31        var ok = false;
32
33        textarea.value = text;
34        textarea.setAttribute( 'readonly', '' );
35        textarea.style.position = 'fixed';
36        textarea.style.opacity = '0';
37        document.body.appendChild( textarea );
38        textarea.select();
39
40        try {
41            ok = document.execCommand( 'copy' );
42        } catch ( e ) {
43            ok = false;
44        }
45
46        textarea.remove();
47
48        return ok ? Promise.resolve() : Promise.reject();
49    }
50
51    function copyText( text ) {
52        if ( navigator.clipboard && window.isSecureContext ) {
53            return navigator.clipboard.writeText( text ).catch( function () {
54                return copyFallback( text );
55            } );
56        }
57
58        return copyFallback( text );
59    }
60
61    function showToast( message, event, link ) {
62        if ( ! toast ) {
63            toast = document.createElement( 'div' );
64            toast.className = 'adn-share-toast';
65            toast.setAttribute( 'role', 'status' );
66            toast.setAttribute( 'aria-live', 'polite' );
67            document.body.appendChild( toast );
68        }
69
70        var x = event.clientX;
71        var y = event.clientY;
72
73        // Activation au clavier : pas de coordonnees, on se place au-dessus du lien.
74        if ( ! x && ! y ) {
75            var rect = link.getBoundingClientRect();
76            x = rect.left + rect.width / 2;
77            y = rect.top;
78        }
79
80        toast.textContent = message;
81        toast.classList.remove( 'is-visible' );
82
83        // On garde la bulle dans l'ecran.
84        var half = toast.offsetWidth / 2;
85        x = Math.min( Math.max( x, half + 8 ), window.innerWidth - half - 8 );
86        y = Math.max( y, toast.offsetHeight + 18 );
87
88        toast.style.left = x + 'px';
89        toast.style.top = y + 'px';
90
91        // Force le reflow pour relancer la transition.
92        void toast.offsetWidth;
93        toast.classList.add( 'is-visible' );
94
95        window.clearTimeout( toastTimer );
96        toastTimer = window.setTimeout( function () {
97            toast.classList.remove( 'is-visible' );
98        }, 1800 );
99    }
100
101    function copyLink( event, link ) {
102        copyText( currentUrl() ).then( function () {
103            showToast( i18n.copied || '', event, link );
104        }, function () {
105            showToast( i18n.error || '', event, link );
106        } );
107    }
108
109    function shareLink( event, link ) {
110        if ( ! navigator.share ) {
111            copyLink( event, link );
112            return;
113        }
114
115        navigator.share( { title: document.title, url: currentUrl() } ).catch( function ( error ) {
116            // L'utilisateur a ferme le menu de partage : rien a faire.
117            if ( error && error.name === 'AbortError' ) {
118                return;
119            }
120
121            copyLink( event, link );
122        } );
123    }
124
125    document.addEventListener( 'click', function ( event ) {
126        var link = event.target.closest && event.target.closest( 'a[href$="#adn-share-native"], a[href$="#adn-share-copy"], a[href$="#adn-share-print"]' );
127
128        if ( ! link ) {
129            return;
130        }
131
132        event.preventDefault();
133
134        var action = link.getAttribute( 'href' ).split( '#adn-share-' ).pop();
135
136        if ( action === 'native' ) {
137            shareLink( event, link );
138        } else if ( action === 'copy' ) {
139            copyLink( event, link );
140        } else if ( action === 'print' ) {
141            window.print();
142        }
143    } );
144}() );

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.