PageSourceSearch

https://www.granadatapastours.com/wp-content/plugins/easy-booked/assets/js/frontend.js?ver=2.4.11.251110171828

js granadatapastours.com collected 2026-10-04 13:28:53 UTC 21,734 bytes, 562 lines download raw bytes

1;
2(function ( $ ) {
3    /* Book calendar */
4    function abs_booked_calendar() {
5        $( '.abs-page-calendar-button' ).on( 'click', function ( event ) {
6            event.preventDefault();
7            var calendar_id = $( this ).attr( 'data-calendar-id' );
8            $( '.abs-booked-calendar-' + calendar_id + ' .abs-month-name' ).hide();
9            $( '.abs-booked-calendar-' + calendar_id + ' .abs-load-time' ).show();
10            var date = $( this ).attr( 'data-goto' );
11            abs_book_calendar_load( date, calendar_id );
12        } );
13    }
14
15    abs_booked_calendar();
16
17    /* Calendar Load */
18    function abs_book_calendar_load( date, calendar_id ) {
19        $.ajax( {
20            type: 'POST',
21            url: abs_data.ajax_url,
22            data: {
23                action: 'book_calendar_load',
24                date: date,
25                calendar_id: calendar_id
26            },
27            success: function ( html ) {
28                $( '.abs-booked-calendar-' + calendar_id ).parent().html( html );
29                $( '.abs-month-name' ).show();
30                abs_booked_calendar();
31                window.abs_adjust_calendar_boxes();
32                abs_disable_enable_button();
33                abs_date_appointments();
34                abs_tooltip();
35            }
36        } );
37    }
38
39    //Disable and Enable date click
40    function abs_disable_enable_button() {
41        $( '.abs-date' ).on( 'click', function () {
42            if ( $( this ).hasClass( 'abs-time-slots-active' ) ) {
43                return true;
44            } else {
45                return false;
46            }
47        } );
48    }
49
50    abs_disable_enable_button();
51
52    // Function to adjust calendar sizing
53    window.abs_adjust_calendar_boxes = function () {
54        $( '.abs-booked-calendar' ).each( function () {
55            var table_width = $( this ).find( 'tbody' ).width();
56            var windowWidth = $( window ).width();
57            var boxesWidth = $( this ).find( 'tbody tr.abs-week td' ).width();
58            var width = boxesWidth * 7;
59            abs_responsive_css( width, table_width );
60            var calendarHeight = $( this ).height();
61            boxesHeight = boxesWidth * 1;
62            $( this ).find( 'tbody tr.abs-week td' ).height( boxesHeight );
63            $( this ).find( 'tbody tr.abs-week td .abs-date' ).css( 'line-height', boxesHeight + 'px' );
64            $( this ).find( 'tbody tr.abs-week td .abs-date .number' ).css( 'line-height', boxesHeight + 'px' );
65
66        } );
67    }
68
69    window.abs_adjust_calendar_boxes();
70
71    $( window ).on( 'resize', function () {
72        window.abs_adjust_calendar_boxes();
73    } );
74
75    // Tooltip Control area
76    function abs_tooltip() {
77        $( '.abs-tooltip' ).tooltipster( {
78            theme: 'tooltipster-light',
79            animation: 'grow',
80            speed: 200,
81            delay: 50,
82            offsetY: 5
83        } );
84    }
85
86    abs_tooltip();
87
88    // Custom responsive
89    function abs_responsive_css( width, boxes_box ) {
90        if ( width > 1 ) {
91            if ( width <= 579 ) {
92                $( ".abs-time-solat-list h2" ).css( "font-size", "22px" );
93                $( ".abs-time-solat-list strong" ).css( "display", "block" );
94            } else if ( width >= 579 ) {
95                $( ".abs-time-solat-list h2" ).css( "font-size", "27px" );
96                $( ".abs-time-solat-list strong" ).css( "display", "" );
97            }
98
99            if ( width <= 470 ) {
100                $( ".abs-bookme-timeslot-left" ).css( "width", "100%" );
101                $( ".abs-bookme-timeslot-right" ).css( {"width": "100%", "text-align": "center"} );
102            } else if ( width >= 470 ) {
103                $( ".abs-bookme-timeslot-left" ).css( "width", "" );
104                $( ".abs-bookme-timeslot-right" ).css( {"width": "", "text-align": ""} );
105            }
106
107
108        }
109    }
110
111    /* Date appointments */
112    function abs_date_appointments() {
113        // Booking date select
114        var abs_date = '';
115        $( '.abs-data' ).on( 'click', function () {
116            if ( $( '.abs-active' ).length ) {
117                $( '.abs-active' ).removeClass( 'abs-active' );
118                $( '.abs-booked-area' ).remove();
119            }
120
121            if ( ! $( this ).hasClass( "abs-active" ) ) {
122                if ( $( this ).attr( 'data-date' ) != abs_date ) {
123                    abs_date = $( this ).attr( 'data-date' );
124                    $( this ).addClass( 'abs-active' );
125                    $( this ).parent().after( "<tr class='abs-booked-area abs-booked-area-loading'><td colspan='7'><img src='" + abs_data.plugin_images_url + "loading.gif' alt='Loading'></td></tr>" );
126                    var date = $( this ).attr( 'data-date' );
127                    var calendar_id = $( this ).attr( 'data-calendar-id' );
128                    abs_get_appointments( date, calendar_id );
129                } else {
130                    abs_date = '';
131                }
132            }
133        } );
134    }
135
136    abs_date_appointments();
137
138    // Get all Appointments
139    function abs_get_appointments( date, calendar_id ) {
140        $.ajax( {
141            type: 'POST',
142            url: abs_data.ajax_url,
143            data: {
144                action: 'abs_get_appointments',
145                date: date,
146                calendar_id: calendar_id,
147            },
148            success: function ( html ) {
149                $( '.abs-booked-area td' ).html( html );
150                $( '.abs-booked-area-loading' ).removeClass( 'abs-booked-area-loading' );
151                window.abs_adjust_calendar_boxes();
152                abs_pop_booked_form();
153            }
154        } );
155    }
156    
157    function abs_update_appointments( ) {
158        let isListUpdated = false;
159        const activeWrapper = $('.abs-list-wrapper-active');
160        if( ! activeWrapper.length ) return false;
161        
162        const activeDate = activeWrapper.attr('data-date');
163        const calendarId = activeWrapper.attr('data-calendar-id');
164        if (!activeDate || !calendarId) return false;
165
166        $.ajax( {
167            type: 'POST',
168            url: abs_data.ajax_url,
169            data: {
170                action: 'abs_get_appointments',
171                date: activeDate,
172                calendar_id: calendarId,
173            },
174            success: function ( html ) {
175                activeWrapper.html( html );
176                const absModalMarkup = getTheCalendarModal(calendarId);
177                activeWrapper.append(absModalMarkup);
178                isListUpdated = true;
179            }
180        } );
181        return isListUpdated;
182    }
183    
184    function getTheCalendarModal(calendarId) {
185        const pluginUrl = abs_data.abs_plugin_url;
186        const loadingGifUrl = `${pluginUrl}assets/images/loading.gif`;
187        const altText = "Loading Booking Form";
188    
189        return `
190        <!-- The Modal -->
191        <div class="prio---1 abs-booked-modal abs-loading-book-form abs-book-form-${calendarId}">
192            <img src="${loadingGifUrl}" alt="${altText}">
193            <!-- Modal content -->
194            <div class="abs-booked-modal-content"></div>
195        </div>
196        `;
197    }
198
199    // Update the list after booking
200    $(document).on('click', '.abs-bookme-timeslot-button', function () {
201        const parentWrap = $(this).closest('.abs-booking-list-wrap');
202        $('.abs-booking-list-wrap').removeClass('abs-list-wrapper-active');
203        parentWrap.addClass('abs-list-wrapper-active');
204        
205        $('.abs-bookme-timeslot-button').removeClass('abs-book-now-btn-active');
206        $(this).addClass('abs-book-now-btn-active');
207    });
208    
209    
210    abs_pop_booked_form();
211    // Show pop up booked form
212    function abs_pop_booked_form() {
213        // Use event delegation for dynamically generated buttons
214        $(document).on('click', '.abs-bookme-timeslot-button', function (event) {
215            event.preventDefault();
216    
217            var calendar_id = $(this).attr('data-calendar-id');
218            var selector_pop_up = $(this)
219                .closest('.abs-booked-calendar-area')
220                .find('.abs-book-form-' + calendar_id + '.abs-booked-modal');
221            
222            // Show the modal popup and add a loading class
223            $(selector_pop_up).show();
224            $(selector_pop_up).addClass('abs-loading-book-form');
225    
226            // Get data attributes from the clicked button
227            var slot_id = $(this).attr('data-slot-id');
228            var slot_type = $(this).attr('data-slot-type');
229            var date = $(this).attr('data-slot-date');
230    
231            // Call the function to get the booking form content
232            get_booked_form_contain(slot_id, slot_type, date, calendar_id, this);
233        });
234    
235        // Call modal close function
236        abs_modal_pop_up_close();
237    }
238    
239    
240    // Pop up modal close
241    function abs_modal_pop_up_close() {
242        $( '.abs-modal-close' ).on( 'click', function () {
243            $( '.abs-booked-modal' ).hide();
244        } );
245
246        $( '.abs-book-form-cancel-btn' ).on( 'click', function ( event ) {
247            event.preventDefault();
248            $( '.abs-booked-modal' ).hide();
249        } );
250
251        $( window ).click( function ( event ) {
252            if ( $( event.target ).hasClass( 'abs-booked-modal' ) ) {
253                $( '.abs-booked-modal' ).hide();
254            }
255        } );
256    }
257
258    // get booking form modal contain
259    function get_booked_form_contain( slot_id, slot_type, date, calendar_id, book_button = '' ) {
260        var selector = $( book_button ).closest( '.abs-booked-calendar-area' ).find( '.abs-book-form-' + calendar_id + ' .abs-booked-modal-content' );
261        
262        $.ajax( {
263            type: 'POST',
264            url: abs_data.ajax_url,
265            data: {
266                action: 'booked_form_contain',
267                slot_id: slot_id,
268                slot_type: slot_type,
269                date: date,
270            },
271            success: function ( html ) {
272                $( '.abs-booked-modal-content' ).html( '' );
273                $( selector ).html( html );
274                $( '.abs-loading-book-form' ).removeClass( 'abs-loading-book-form' );
275                abs_book_login();
276                abs_book_form_phone();
277                abs_book_form_submit()
278            }
279        } );
280
281    }
282
283    // Login for Appointment Booking
284    function abs_book_login() {
285        $( '.abs-book-login-area' ).on( 'submit', function ( event ) {
286            event.preventDefault();
287            abs_book_form_spinner();
288            var email = $( '.abs-book-email' ).val();
289            var password = $( '.abs-book-password' ).val();
290
291            $.ajax( {
292                type: 'POST',
293                url: abs_data.ajax_url,
294                data: {
295                    action: 'abs_user_login',
296                    email: email,
297                    password: password,
298                    rememberme: 'yes',
299                    nonce: abs_data.abs_user_login
300                },
301                success: function ( data ) {
302                    if ( data.status == 'error' ) {
303                        $( '.abs-book-success-massage' ).html( '<p class="abs-book-error"> ' + data.massage + ' </p>' );
304                        $( '.abs-ladda-button' ).removeAttr( 'data-loading' );
305                    }
306
307                    if ( data.status == 'success' ) {
308                        var calendar_id = $( '.abs-book-login-button' ).attr( 'data-calendar-id' );
309                        var slot_id = $( '.abs-book-login-button' ).attr( 'data-slot-id' );
310                        var slot_type = $( '.abs-book-login-button' ).attr( 'data-slot-type' );
311                        var date = $( '.abs-book-login-button' ).attr( 'data-slot-date' );
312                        get_booked_form_contain( slot_id, slot_type, date, calendar_id );
313                    }
314                }
315
316            } );
317        } );
318    }
319
320    // Book Form phone number filed
321    function abs_book_form_phone() {
322        abs_modal_pop_up_close();
323        var input = document.querySelector( ".abs-book-phone" );
324
325        if ( input !== null ) {
326            window.intlTelInput( input, {
327                initialCountry: "auto",
328                hiddenInput: "abs_book_phone",
329                geoIpLookup: function ( callback ) {
330                    $.get( 'https://ipinfo.io', function () {
331                    }, "jsonp" ).always( function ( resp ) {
332                        var countryCode = (resp && resp.country) ? resp.country : "us";
333                        callback( countryCode );
334                    } );
335                },
336                utilsScript: abs_data.abs_plugin_url + "assets/js/wc-utils.js",
337            } );
338        }
339    }
340
341    // Book Form submit
342    function abs_book_form_submit() {
343        $( '.abs-book-form-area' ).on( 'submit', function ( event ) {
344            event.preventDefault();
345            abs_book_form_spinner();
346            var book_name = $( '.abs_book_name' ).val()
347            var phone = $( 'input[name=abs_book_phone]' ).val()
348            var book_email = $( '.abs-book-email' ).val()
349            var slot_type = $( '.abs-book-form-btn-success' ).attr( 'data-slot-type' );
350            var slots_id = $( '.abs-book-form-btn-success' ).attr( 'data-slot-id' );
351            var date = $( '.abs-book-form-btn-success' ).attr( 'data-slot-date' );
352            var custom_filed = $( '.abs-custom-field' ).serializeArray();
353
354            $.ajax( {
355                type: 'POST',
356                url: abs_data.ajax_url,
357                data: {
358                    action: 'abs_booked_appointment',
359                    book_name: book_name,
360                    phone: phone,
361                    book_email: book_email,
362                    slot_type: slot_type,
363                    slots_id: slots_id,
364                    date: date,
365                    custom_filed: custom_filed,
366                },
367                success: function ( data ) {
368                    if ( data.status === 'success' ) {
369                        var date = $( '.abs-booked-calendar' ).attr( 'data-date' );
370                        $( '.abs-ladda-button' ).removeAttr( 'data-loading' );
371                        $( '.abs-book-form-area' ).remove();
372                        $( '.abs-booked-form-time-solat' ).after( data.html );
373                        $( '.abs-booked-form-time-solat' ).remove();
374
375                        abs_add_to_calendar();
376                        $( '.abs-modal-close' ).on( 'click', function () {
377                            abs_update_appointments();
378                            if(date){
379                                abs_book_calendar_load( date, data.calendar_id );
380                            }
381                        } );
382
383                        $( window ).click( function ( event ) {
384                            if ( $( event.target ).hasClass( 'abs-booked-modal' ) ) {
385                                abs_update_appointments();
386                                if(date){
387                                    abs_book_calendar_load( date, data.calendar_id );
388                                }
389                            }
390                        } );
391
392                    }
393
394                    if ( data.status === 'failed' ) {
395                        $( '.abs-book-success-massage' ).html( '<p class="abs-book-error"> ' + data.massage + ' </p>' );
396                        $( '.abs-ladda-button' ).removeAttr( 'data-loading' );
397                    }
398
399                    if ( data.status === 'redirect' ) {
400                        window.location = data.url;
401                    }
402                }
403            } );
404
405        } );
406    }
407
408    // Book from spinner
409    function abs_book_form_spinner() {
410        if ( $( '.abs-ladda-button' ).attr( 'data-loading' ) === 'string' ) {
411            $( '.abs-ladda-button' ).removeAttr( 'data-loading' );
412        } else {
413            $( '.abs-ladda-button' ).attr( 'data-loading', '' );
414        }
415    }
416
417    // Register user phone number
418    var selection = document.querySelector( ".abs-user-phone-number" ) !== null;
419    if ( selection ) {
420        var input = document.querySelector( ".abs-user-phone-number" );
421        window.intlTelInput( input, {
422            initialCountry: "auto",
423            hiddenInput: "abs_phone_number",
424            geoIpLookup: function ( callback ) {
425                $.get( 'https://ipinfo.io', function () {
426                }, "jsonp" ).always( function ( resp ) {
427                    var countryCode = (resp && resp.country) ? resp.country : "us";
428                    callback( countryCode );
429                } );
430            },
431            utilsScript: abs_data.abs_plugin_url + "assets/js/wc-utils.js",
432        } );
433    }
434
435    /**
436     * Register User
437     */
438    $( '.abs-register-form' ).on( 'submit', function () {
439        event.preventDefault();
440        $( '.abs-register-button' ).prop( "disabled", true );
441
442        if ( $( '.abs-register-button' ).attr( 'data-loading' ) === 'string' ) {
443            $( '.abs-register-button' ).removeAttr( 'data-loading' );
444        } else {
445            $( '.abs-register-button' ).attr( 'data-loading', '' );
446        }
447
448        var first_name = $( '.abs-input-first-name' ).val();
449        var last_name = $( '.abs-input-last-name' ).val();
450        var username = $( '.abs-input-username' ).val();
451        var email = $( '.abs-input-email' ).val();
452        var phone = $( 'input[name=abs_phone_number]' ).val();
453        var password = $( '.abs-input-password' ).val();
454
455        $.ajax( {
456            type: 'POST',
457            url: abs_data.ajax_url,
458            data: {
459                action: 'abs_registration_user',
460                first_name: first_name,
461                last_name: last_name,
462                username: username,
463                email: email,
464                phone_number: phone,
465                password: password,
466                nonce: abs_data.abs_user_register,
467            },
468            success: function ( data ) {
469                if ( data.status === 'error' ) {
470                    $( '.abs-error' ).show();
471                    $( '.abs-error' ).html( data.massage );
472                    $( '.abs-register-button' ).removeAttr( 'data-loading' );
473                    $( '.abs-register-button' ).removeAttr( "disabled" );
474                } else if ( data.status === 'redirect' ) {
475                    window.location = data.location;
476                }
477            }
478        } );
479    } )
480
481    /**
482     * Login user
483     */
484    $( '.abs-login-form' ).on( 'submit', function () {
485        event.preventDefault();
486
487        var rememberme = '';
488        if ( $( '.abs-rememberme' ).prop( "checked" ) == true ) {
489            rememberme = $( '.abs-rememberme' ).val();
490        }
491
492        var email = $( '.abs-login-input-email' ).val();
493        var password = $( '.abs-login-input-password' ).val();
494
495        $.ajax( {
496            type: 'POST',
497            url: abs_data.ajax_url,
498            data: {
499                action: 'abs_user_login',
500                email: email,
501                password: password,
502                rememberme: rememberme,
503                nonce: abs_data.abs_user_login,
504            },
505            success: function ( data ) {
506                if ( data.status === 'error' ) {
507                    $( '.abs-login-error' ).show();
508                    $( '.abs-login-error' ).html( data.massage );
509                    $( '.abs-register-button' ).removeAttr( 'data-loading' );
510                    $( '.abs-register-button' ).removeAttr( "disabled" );
511                } else if ( data.status === 'success' ) {
512                    window.location = data.location;
513                }
514            }
515        } );
516
517    } );
518
519    // Pop up modal close
520    function abs_pop_up_close() {
521        $( '.abs-pop-up-close' ).on( 'click', function () {
522            $( '.abs-pop-up' ).hide();
523        } );
524
525        $( window ).click( function ( event ) {
526            if ( $( event.target ).hasClass( 'abs-pop-up' ) ) {
527                $( '.abs-pop-up' ).hide();
528            }
529        } );
530    }
531
532    abs_pop_up_close();
533
534    // Open pop up
535    $( '.abs-pop-up-button' ).on( 'click', function () {
536        $( '.abs-pop-up' ).show();
537        window.abs_adjust_calendar_boxes();
538    } );
539
540    
541    // Toggle the visibility when the "view more" button is clicked
542    const custom_info_view_full = $( '.abs_info_view_more' );
543    custom_info_view_full.on( 'click', function (e) {
544        e.preventDefault();
545        e.stopPropagation();  // Prevent the click from propagating to the document
546
547        const wrapper = $(this).closest('.abs_custom_info_wrap');  // Find the closest wrapper
548        const custom_info_full = wrapper.find('.abs_large_info_full');  // Get the full info inside the current wrapper
549
550        // Hide all other .abs_large_info_full elements except the current one
551        $('.abs_large_info_full').not(custom_info_full).hide();
552
553        // Toggle the visibility of the info in the current wrapper
554        custom_info_full.toggle();
555    });
556
557    // Hide the full info when clicking anywhere on the page
558    $(document).on('click', function () {
559        $('.abs_large_info_full').hide();  // Hide all full info elements
560    });
561    
562})( 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.