PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 4.8.2
WpStream – Live Streaming, Video on Demand, Pay Per View v4.8.2
4.14.1 4.14.0 4.13.2 4.13.1 4.13 4.12.5 4.12.4 4.12.3 4.12.2 4.12.1 4.12 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5 4.5.1 4.5.11 4.5.11.1 4.5.11.2 4.5.11.4 4.5.11.5 4.5.11.6 All 181 releases
← All changes | hello-wpstream/js/wpstream-plugin-script.js +1 -46 4.14.14.8.2 View file →
@@ -1,15 +1,6 @@
1 1 "use strict";
2 2
3 -/*
4 - * wpstream-plugin-script.js
5 - *
6 - * Public-facing plugin behaviour for the theme: submitting the Elementor
7 - * contact form via AJAX, and the "watch later" add/remove actions. All requests
8 - * go through admin-ajax using the localized `wpstreamPluginScriptsVars`.
9 - */
10 -
11 -// Bind the watch-later handlers once the DOM is ready.
12 3 jQuery(document).ready(function () {
13 4 wpstream_watch_later();
14 5 wpstream_watch_later_video_remove();
15 6 });
@@ -14,15 +5,12 @@
14 5 wpstream_watch_later_video_remove();
15 6 });
16 7
17 8 /**
18 - * Bind submit handling to the Elementor contact form and delegate processing.
19 9 *
20 - * @return {void}
21 10 */
22 11 function wpstream_elementor_submit_form() {
23 12 jQuery('.wpstream_elementor_form').on('submit', function (event) {
24 - // Prevent the default page reload and process via AJAX.
25 13 event.preventDefault();
26 14 var form_submit = jQuery('.wpstream_elementor_form').find('.agent_submit_class_elementor');
27 15 wpstream_elementor_contact_process_form(form_submit);
28 16 });
@@ -27,30 +15,20 @@
27 15 wpstream_elementor_contact_process_form(form_submit);
28 16 });
29 17 }
30 18
31 -/**
32 - * Validate and submit the Elementor contact form over AJAX: disable the button,
33 - * enforce the GDPR checkbox, serialize all fields, and post the message.
34 - *
35 - * @param {jQuery} form_submit The submit button element inside the form.
36 - * @return {void}
37 - */
38 19 function wpstream_elementor_contact_process_form(form_submit) {
39 20 var parent, button,message_area, ajaxurl, contact_u_email, contact_u_name, subject, booking_from_date, booking_to_date, booking_guest_no, message, nonce, agent_property_id, is_elementor;
40 21
41 22
42 - // Cache the form, submit button, and message output area.
43 23 parent = form_submit.parent();
44 24 button = jQuery('.wpstream_elementor_form').find('.agent_submit_class_elementor');
45 25 message_area = jQuery('.wpstream_elementor_form').find('.wpstream-contact-form-message');
46 26
47 27
48 - // Put the button into its "processing" (disabled) state.
49 28 button.val(wpstreamPluginScriptsVars.processing);
50 29 button.text(wpstreamPluginScriptsVars.processing);
51 30 button.prop('disabled', true);
52 - // Read the endpoint, standard contact fields, and nonce.
53 31 ajaxurl = wpstreamPluginScriptsVars.ajaxurl;
54 32 message = jQuery("#form-field-message").val();
55 33 contact_u_email = jQuery("#rentals_contact_builder_email").val();
56 34 contact_u_name = jQuery("#rentals_contact_builder_name").val();
@@ -57,13 +35,11 @@
57 35 nonce = jQuery('#agent_property_ajax_nonce').val();
58 36
59 37
60 38
61 - // Flag that this is an Elementor form and read its subject line.
62 39 is_elementor = parent.find('#contact_form_elementor').val();
63 40 var elementor_email_subject = jQuery('#elementor_email_subject').val();
64 41
65 - // Build the message body by concatenating every Elementor field.
66 42 var temp_details;
67 43 temp_details = '';
68 44 var elementor_form = form_submit.parents('.wpstream_elementor_form');
69 45
@@ -75,10 +51,8 @@
75 51
76 52 message = temp_details;
77 53
78 54
79 - // GDPR gate: if the consent box exists but is unchecked, re-enable the
80 - // button, scroll to the form, show the consent notice, and bail.
81 55 if (jQuery('#wpstream_agree_gdpr').length > 0 && !jQuery('#wpstream_agree_gdpr').is(':checked')) {
82 56 button.val(wpstreamPluginScriptsVars.send_mess);
83 57 button.text(wpstreamPluginScriptsVars.send_mess);
84 58 var aTag = jQuery(".wpstream_elementor_form");
@@ -90,9 +64,8 @@
90 64 }
91 65
92 66
93 67
94 - // Submit the contact message to the server.
95 68 jQuery.ajax({
96 69 type: 'POST',
97 70 dataType: 'json',
98 71 url: ajaxurl,
@@ -105,9 +78,8 @@
105 78 'is_elementor': 1,
106 79 'nonce': nonce
107 80 },
108 81 success: function (data) {
109 - // Scroll the form back into view.
110 82 var aTag = jQuery(".wpstream_elementor_form");
111 83 jQuery('html,body').animate({scrollTop: aTag.offset().top - 120}, 'slow');
112 84
113 85 // reset contact form
@@ -117,9 +89,8 @@
117 89 jQuery(".wpstream_elementor_form .elementor-field").val('');
118 90
119 91 var aTag = jQuery(".wpstream_elementor_form");
120 92 jQuery('html,body').animate({scrollTop: aTag.offset().top - 120}, 'slow');
121 - // Show the server's response message.
122 93 message_area.empty().text(data.response );
123 94
124 95
125 96 },
@@ -133,28 +104,20 @@
133 104
134 105
135 106 /**
136 107 * Add to watch later
137 - *
138 - * Toggle a video's "watch later" state via AJAX and swap in the returned
139 - * button markup.
140 - *
141 - * @return {void}
142 108 */
143 109 function wpstream_watch_later() {
144 110 jQuery(document).on('click', '.wpstream-watch-later-action', function () {
145 - // The clicked control and its button wrapper.
146 111 const item = jQuery(this);
147 112 var parent = jQuery(this).closest('.wpstream-watch-later-btn');
148 113
149 - // Ignore clicks on disabled ("no action") controls.
150 114 if (item.hasClass('wpstream_no_action')) {
151 115 return;
152 116 }
153 117
154 - // Target post id, localized watch-later nonce, and endpoint.
155 118 const postID = item.attr('data-postID');
156 - const nonce = wpstreamPluginScriptsVars.watch_later_nonce;
119 + const nonce = 'nonce';
157 120 const wpstream_admin_ajax_url = wpstreamPluginScriptsVars.ajaxurl;
158 121 jQuery.ajax({
159 122 type: 'POST',
160 123 url: wpstream_admin_ajax_url, // WordPress AJAX URL,
@@ -164,10 +127,8 @@
164 127 postID: postID,
165 128 security: nonce // Include the nonce in the data
166 129 },
167 130 success: function (data) {
168 - // On success, flip the "already watched later" state and
169 - // replace the button markup with the server's version.
170 131 if (data.success === true) {
171 132 if (item.hasClass('wpstream_already_watched_later')) {
172 133 // Class exists, remove it
173 134 item.removeClass('wpstream_already_watched_later');
@@ -189,16 +150,11 @@
189 150 }
190 151
191 152 /**
192 153 * Remove Video in Watch later page
193 - *
194 - * Remove a video from the "watch later" list and drop its card from the DOM.
195 - *
196 - * @return {void}
197 154 */
198 155 function wpstream_watch_later_video_remove() {
199 156 jQuery('.wpstream_watch-later-remove-btn').on('click', function () {
200 - // Post id to remove, endpoint, nonce, and the card element to delete.
201 157 const postIdToRemove = jQuery(this).data('post-id');
202 158 const wpstream_admin_ajax_url = wpstreamPluginScriptsVars.ajaxurl;
203 159 const nonce = jQuery('#wpstream-watch-later-nonce').val();
204 160 const item_to_remove = jQuery(this).closest('.wpstream-dashboard-card');
@@ -212,9 +168,8 @@
212 168 postID: postIdToRemove,
213 169 wpstream_nonce: nonce // Include the nonce in the data
214 170 },
215 171 success: function (response) {
216 - // Remove the card only when the server confirms deletion.
217 172 if (response.success) {
218 173 item_to_remove.remove();
219 174 }
220 175 }