PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.5.1
Yatra – Travel Booking & Tour Operator Software v3.0.5.1
3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 2.0.10 All 83 releases
yatra / assets / js / trip-shortcode.js

trip-shortcode.js in Yatra – Travel Booking & Tour Operator Software 3.0.5.1, at assets/js/trip-shortcode.js

75 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 jQuery(document).ready(function($) {
2 'use strict';
3
4 // Handle pagination clicks for regular trip shortcode (not discount)
5 $(document).on('click', '.yatra-tour-shortcode:not(.yatra-discount-trip-shortcode) .yatra-tour-pagination a', function(e) {
6 e.preventDefault();
7
8 var $link = $(this);
9 var $container = $link.closest('.yatra-tour-shortcode');
10 var page = $link.data('page');
11 var atts = $container.data('atts');
12
13 if (!page || !atts) {
14 return;
15 }
16
17 // Add loading state
18 $container.addClass('yatra-loading');
19
20
21 // AJAX request
22 $.post(yatraTripShortcode.ajaxurl, {
23 action: 'yatra_trip_shortcode_load',
24 nonce: yatraTripShortcode.nonce,
25 page: page,
26 atts: atts
27 }, function(response) {
28 if (response.success) {
29 // Update only the inner content, not the entire container to prevent nesting
30 // The response should contain only the inner content (header, grid, pagination)
31 var $innerContent = $('<div>').html(response.data.html);
32 var newShortcodeElement = $innerContent.find('.yatra-tour-shortcode');
33
34 if (newShortcodeElement.length) {
35 // Extract the inner content from the new shortcode element
36 var newInnerContent = newShortcodeElement.html();
37 var newAtts = newShortcodeElement.data('atts');
38
39 // Update the existing container's inner content
40 $container.html(newInnerContent);
41
42 // Update container data attributes
43 if (newAtts) {
44 $container.data('atts', newAtts);
45 }
46 } else {
47 // Fallback: if no shortcode element found, replace directly
48 $container.html(response.data.html);
49 }
50
51 // Scroll to top of container
52 $('html, body').animate({
53 scrollTop: $container.offset().top - 100
54 }, 300);
55
56 // Trigger custom event
57 $(document).trigger('yatraTripShortcodeUpdated', [response.data]);
58 } else {
59 // Error loading trips
60 }
61 }).fail(function(xhr, status, error) {
62 }).always(function() {
63 // Remove loading state
64 $container.removeClass('yatra-loading');
65 });
66 });
67
68 // Initialize shortcode data
69 $('.yatra-tour-shortcode').each(function() {
70 var $container = $(this);
71 var atts = $container.data('atts');
72
73 });
74 });
75