PageSourceSearch

https://dev.publier-un-livre.com/js/extras.js

js publier-un-livre.com collected 2026-09-24 18:45:57 UTC 4,015 bytes, 111 lines download raw bytes

1var sendcloud_initial_options = {
2	apiKey     : '8d75ee99-ef8c-464e-82eb-2067bdd8fee2',
3	country    : 'BE',
4	postalCode : '7100',
5	city       : 'La Louvière',
6	carriers   : 'mondial_relay',
7	language   : 'fr-fr',
8}
9
10
11function sendcloud_success_callback( service_point, post_number ) {
12	$( '#sendcloud-selected-service-point-name' ).text( service_point.name );
13	$( '#sendcloud-selected-service-point-address' ).html( 
14		service_point.street + ', ' + service_point.house_number + '<br>'
15		+ service_point.postal_code + ' ' + service_point.city
16	 );
17
18	if ( typeof( service_point.formattedDistance != 'undefined' ) ) {
19		$( '#sendcloud-selected-service-point-distance' ).text( service_point.formattedDistance );
20		$( '#sendcloud-selected-service-point-distance-wrapper' ).show();
21	} else {
22		$( '#sendcloud-selected-service-point-distance-wrapper' ).hide();
23	}
24
25	// Populate fields
26	$( '#sendcloud-service-point-id' ).val( service_point.id );
27	$( '#sendcloud-service-point-data' ).val( JSON.stringify( service_point ) );
28
29	// Display element
30	$( '#sendcloud-selected-service-point' ).show();
31}
32
33function sendcloud_failure_callback( errors ) {
34	$( '#sendcloud-selected-service-point-distance-wrapper' ).hide();
35	$( '#sendcloud-selected-service-point' ).hide();
36}
37
38// TODO : Disable submit button
39function disable_submit_button( name ) {
40	var $input = $( '[name="' + name + '"]' );
41	$input.prop( 'disabled', true ).addClass( 'disabled' );
42	$input.prop( 'data-reset-value', $input.val() ).prop( 'data-reset-text', $input.text() );
43	$input.val( '&hellip;' ).text( '&hellip;' ).attr( 'onclick','return false;' );
44}
45function reenable_submit_button( name ) {
46	var $input = $( '[name="' + name + '"]' );
47	if ( ! $input.prop( 'data-reset-value' ) ) return;
48
49	$input.prop( 'disabled', false ).removeClass( 'disabled' );
50	$input.val( $input.prop( 'data-reset-value' ) ).text( $input.prop( 'data-reset-text' ) ).removeAttr( 'onclick' );
51	$input.removeProp( 'data-reset-value' ).removeProp( 'data-reset-text' ).removeProp( 'onclick' );
52}
53
54$( document ).ready( function( $ ) {
55	// Back to top button
56	$( 'document' ).on( 'click', '.back-to-top', function() {
57		$( 'html,body' ).animate( { scrollTop:0 },'slow' );
58	} );
59
60	// Modals — same toolbar as Fancybox's own default (Toolbar.display), minus "fullscreen".
61	Fancybox.bind( '[data-modal]', {
62		'mainClass' : 'modal',
63		Toolbar : {
64			display : {
65				left : [ 'counter' ],
66				right : [ 'toggleFull', 'autoplay', 'thumbs', 'close' ]
67			}
68		}
69	} );
70	$( '[data-modal]' ).each( function( index, element ) {
71		if ( $( element ).attr( 'data-force-open' ) ) {
72			$( element ).trigger( 'click' );
73		}
74	} );
75	if ( $( '.form__error--login' ).length ) {
76		$( '#open-login-modal' ).trigger( 'click' );
77	}
78
79	// Conditionnaly display service point picker
80	$( '[name="shipping-method"]' ).on( 'change', function() {
81		$( '.sendcloud-service-point-wrapper' ).hide();
82		$( '[name="shipping-method"]:checked' ).parent().find( '.sendcloud-service-point-wrapper' ).show();
83	} );
84
85	// Open service point picker if available for a shipping method
86	$( document ).on( 'click', '#sendcloud-open-service-point-picker', function( e ) {
87		e.preventDefault();
88		sendcloud.servicePoints.open( sendcloud_local_options ?? sendcloud_initial_options, sendcloud_success_callback, sendcloud_failure_callback );
89		return false;
90	} );
91
92	// Ajax search feature
93    $( '#search-form input, #search-form select' ).on( 'change', ( e ) => {
94        e.stopPropagation();
95        // Perform AJAX search
96        $.ajax( {
97            url: $( '#search-form' ).attr( 'action' ),
98            method: 'GET',
99            data: $( '#search-form' ).serialize(),
100            success: ( response ) => {
101                // Update search results
102                $( '#search-results' ).html( $( response ).find( '#search-results' ) );
103            },
104        } );
105    } );
106
107    // Close dialogs on ESC
108    $(document).on( 'keydown', ( e ) => {
109        if (e.key === 'Escape' ) $( '.js-dialog.open' ).removeClass( 'open' );
110    } );
111} );

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.