PageSourceSearch

https://www.losverdesgc.com/wp-content/plugins/fru-post-modal/js/post_modal.js?ver=7.0.6

js losverdesgc.com collected 2026-10-04 04:47:35 UTC 5,352 bytes, 175 lines download raw bytes

1jQuery(function($) {
2  /* Add a class of "post_modal" to any site link, and it will open in a modal */
3
4  var duration = 500;
5
6  function format_dates(dates) {
7    var formattedDates = "";
8
9    if (dates && Array.isArray(dates)) {
10      formattedDates += '<ul class="event-date-list">';
11      for (var i=0; i<dates.length; i++) {
12        for (var j=0; j<dates[i].length; j++) {
13          var date = dates[i][j];
14          var d = date.split('||');
15          formattedDates += '<li>' + d[0];
16          if (d[1] && d[0] != d[1]) {
17            var t = d[1].split(' ');
18            formattedDates += ' - ' + t[1];
19          }
20
21          formattedDates += '</li>';
22        }
23      }
24      formattedDates += '</ul>';
25    }
26
27    return formattedDates;
28  }
29
30  function format_single_date(start) {
31    var date_string = '';
32    if (start) {
33      // "Wed Jan 01 2020 12:00:00 GMT-0700"
34      var s = moment(start, 'ddd MMM DD YYYY HH:mm:ss');
35      var start_day = (s._isValid) ? s.format('dddd, MMMM Do YYYY') : false;
36      var start_time = (s._isValid) ? s.format('h:mm A') : false;
37      if ( start_day) {
38        date_string = '<ul class="event-date-list"><li>' + start_day;
39
40        if (start_time) {
41          date_string +=  ", " + start_time;
42        }
43        date_string += '</li></ul>';
44      }
45
46    }
47
48    return date_string;
49  }
50
51  // Template
52
53  function modal_template(data) {
54    var temp = '<div id="fru_post_modal"><div class="modal_wrapper';
55    if (data['post_thumbnail']) {
56      temp += ' featured';
57    }
58    temp += '">';
59    temp += '<div class="modal_controls"><button type="button" class="modal_close_button" aria-label="Close Modal"><svg aria-role="presentation" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M14.545 0L16 1.455 9.454 8 16 14.545 14.545 16 8 9.454 1.455 16 0 14.545 6.545 8 0 1.455 1.455 0 8 6.546 14.545 0z"/></svg></button></div>';
60    temp += '<div class="modal_scroll"><div class="modal_content"><article class="event">';
61
62    if (data['post_thumbnail']) {
63      temp += '<aside>' + data['post_thumbnail'] + '</aside>';
64    }
65
66    temp += '<div class="event-content">';
67
68    if (data['post_title']) {
69      temp += '<header><h2>'+ data['post_title'] +'</h2>';
70
71      if (data.start_date) {
72        temp += format_single_date(data.start_date);
73      } else {
74        if (data['post_metadata']['repeating_dates']) {
75          temp += format_dates(data['post_metadata']['repeating_dates']);
76        }
77      }
78
79      if (data['post_metadata']['event_sub_title']) {
80        temp += '<h3>' + data['post_metadata']['event_sub_title'] + '</h3>';
81      }
82
83      temp += '</header>';
84    }
85
86    temp += '<div class="entry-content">';
87
88    if (data['post_content']) {
89      temp += data['post_content'];
90    }
91
92    if (data['post_metadata']['landing_page']) {
93      temp += '<div class="event-button event-rsvp"><a href="' + data['post_metadata']['landing_page'] + '" class="btn">';
94      temp += '<span class="label">Learn More</span><span class="icon right" aria-hidden="true">';
95      temp += '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 34 34" enable-background="new 0 0 34 34"><style type="text/css">.st0{fill-rule:evenodd;clip-rule:evenodd;}</style><path class="st0" d="M19.8 17l-6.4 6.4 2.2 2.1 8.5-8.5-8.5-8.5-2.2 2.1 6.4 6.4zm-2.8-17c-9.4 0-17 7.6-17 17s7.6 17 17 17 17-7.6 17-17-7.6-17-17-17zm0 2.8c7.8 0 14.2 6.4 14.2 14.2 0 7.8-6.4 14.2-14.2 14.2s-14.2-6.4-14.2-14.2c0-7.8 6.4-14.2 14.2-14.2z"/></svg>';
96      temp += '</span></a></div>';
97    }
98
99    temp += '</div></div>';
100    temp += '</article>';
101    temp += '<div></div></div></div>';
102
103    return temp;
104  }
105
106  // Add/Remove Spinner
107
108  function create_spinner() {
109    $('body').append('<div id="fru_post_modal_loading">Loading&#8230;</div>');
110    $('#fru_post_modal_loading').fadeIn(duration);
111  };
112
113  function remove_spinner() {
114    $('#fru_post_modal_loading').fadeOut(duration).remove();
115  }
116
117  // Add/Remove Modal
118
119  function create_modal(data) {
120    if (data) {
121      var template = modal_template(data);
122      $('body').append(template);
123      $('#fru_post_modal').fadeIn(duration);
124    }
125  };
126
127  function remove_modal() {
128    $('#fru_post_modal').fadeOut(duration).remove();
129  };
130
131  function ajax_get_post(url, start, end) {
132    if (url) {
133      create_spinner();
134
135      $.ajax({
136        type: 'POST',
137        url: ajax_vars.ajax_url,
138        dataType: 'json',
139        data: {
140          action : 'get_post',
141          permalink: url,
142          start: start
143        },
144        dates: {
145          start: start,
146          end: end
147        }
148      }).done(function(response) {
149        var data = response;
150        data.start_date = this.dates.start;
151        data.end_date = this.dates.end;
152        create_modal(data);
153      }).fail(function(response) {
154        // open link normally?
155        window.location = url;
156      }).always(function(response) {
157        remove_spinner();
158      });
159    }
160  };
161
162  // Event Listeners
163
164  $(document).on('click', 'a.post_modal', function(e) {
165    e.preventDefault();
166    var start = $(e.target).attr('data-startdate');
167    var end = $(e.target).attr('data-enddate');
168    ajax_get_post(e.currentTarget.href, start, end);
169  });
170
171  $(document).on('click', 'button.modal_close_button', function(e) {
172    e.preventDefault();
173    remove_modal();
174  });
175});

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.