PluginProbe ʕ •ᴥ•ʔ
Reviews Feed – Add Testimonials and Customer Reviews From Google Reviews, Yelp, TripAdvisor, and More / 2.7.0
Reviews Feed – Add Testimonials and Customer Reviews From Google Reviews, Yelp, TripAdvisor, and More v2.7.0
2.11.0 2.10.0 2.9.0 2.8.0 2.7.0 2.6.7 2.6.8 2.6.5 2.6.4 2.6.3 2.6.2 2.6.0 2.5.5 2.5.4 2.5.3 2.5.2 trunk 1.0 1.0.1 1.0.2 1.0.3 1.1 1.1.1 1.1.2 1.2.0 2.0 2.1.0 2.1.1 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.5.0 2.5.1
reviews-feed / assets / js / admin-notifications.js
reviews-feed / assets / js Last commit date
admin-notifications.js 1 month ago sbr-blocks.js 1 month ago sbr-feed.js 1 month ago sbr-feed.min.js 1 month ago sbr-review-alerts.js 1 month ago
admin-notifications.js
290 lines
1 /**
2 * SBR Admin Notifications.
3 *
4 * @since 2.18
5 */
6
7 'use strict';
8
9 var SBRAdminNotifications = window.SBRAdminNotifications || ( function( document, window, $ ) {
10
11 /**
12 * Elements holder.
13 *
14 * @since 2.18
15 *
16 * @type {object}
17 */
18 var el = {
19
20 $notifications: $( '#sbr-notifications' ),
21 $nextButton: $( '#sbr-notifications .navigation .next' ),
22 $prevButton: $( '#sbr-notifications .navigation .prev' ),
23 $adminBarCounter: $( '#wp-admin-bar-wpforms-menu .sbr-menu-notification-counter' ),
24 $adminBarMenuItem: $( '#wp-admin-bar-sbr-notifications' ),
25
26 };
27
28 /**
29 * Public functions and properties.
30 *
31 * @since 2.18
32 *
33 * @type {object}
34 */
35 var app = {
36
37 /**
38 * Start the engine.
39 *
40 * @since 2.18
41 */
42 init: function() {
43 el.$notifications.find( '.messages a').each(function() {
44 if ($(this).attr('href').indexOf('dismiss=') > -1 ) {
45 $(this).addClass('button-dismiss');
46 }
47 })
48
49 $( app.ready );
50 },
51
52 /**
53 * Document ready.
54 *
55 * @since 2.18
56 */
57 ready: function() {
58
59 app.updateNavigation();
60 app.events();
61 },
62
63 /**
64 * Register JS events.
65 *
66 * @since 2.18
67 */
68 events: function() {
69
70 el.$notifications
71 .on( 'click', '.dismiss', app.dismiss )
72 .on( 'click', '.button-dismiss', app.buttonDismiss )
73 .on( 'click', '.next', app.navNext )
74 .on( 'click', '.prev', app.navPrev );
75 },
76
77 /**
78 * Click on a dismiss button.
79 *
80 * @since 2.18
81 */
82 buttonDismiss: function( event ) {
83 event.preventDefault();
84 app.dismiss();
85 },
86
87 /**
88 * Click on the Dismiss notification button.
89 *
90 * @since 2.18
91 *
92 * @param {object} event Event object.
93 */
94 dismiss: function( event ) {
95
96 if ( el.$currentMessage.length === 0 ) {
97 return;
98 }
99
100 // Update counter.
101 var count = parseInt( el.$adminBarCounter.text(), 10 );
102 if ( count > 1 ) {
103 --count;
104 el.$adminBarCounter.html( '<span>' + count + '</span>' );
105 } else {
106 el.$adminBarCounter.remove();
107 el.$adminBarMenuItem.remove();
108 }
109
110 // Remove notification.
111 var $nextMessage = el.$nextMessage.length < 1 ? el.$prevMessage : el.$nextMessage,
112 messageId = el.$currentMessage.data( 'message-id' );
113
114 if ( $nextMessage.length === 0 ) {
115 el.$notifications.remove();
116 } else {
117 el.$currentMessage.remove();
118 $nextMessage.addClass( 'current' );
119 app.updateNavigation();
120 }
121
122 // AJAX call - update option.
123 var data = {
124 action: 'sbr_dashboard_notification_dismiss',
125 nonce: sbrA.sbr_nonce,
126 id: messageId,
127 };
128
129 $.post( sbrA.ajax_url, data, function( res ) {
130
131 if ( ! res.success ) {
132 //SBRAdmin.debug( res );
133 }
134 } ).fail( function( xhr, textStatus, e ) {
135
136 //SBRAdmin.debug( xhr.responseText );
137 } );
138 },
139
140 /**
141 * Click on the Next notification button.
142 *
143 * @since 2.18
144 *
145 * @param {object} event Event object.
146 */
147 navNext: function( event ) {
148
149 if ( el.$nextButton.hasClass( 'disabled' ) ) {
150 return;
151 }
152
153
154 el.$currentMessage.removeClass( 'current' );
155 el.$nextMessage.addClass( 'current' );
156 if( !$('.message[data-message-id="review"]').hasClass('current') ){
157 $('.sbr_review_step1_notice').hide()
158 }
159
160 app.updateNavigation();
161 },
162
163 /**
164 * Click on the Previous notification button.
165 *
166 * @since 2.18
167 *
168 * @param {object} event Event object.
169 */
170 navPrev: function( event ) {
171
172 if ( el.$prevButton.hasClass( 'disabled' ) ) {
173 return;
174 }
175
176 el.$currentMessage.removeClass( 'current' );
177 el.$prevMessage.addClass( 'current' );
178 if( $('.message[data-message-id="review"]').hasClass('current') && $('.message[data-message-id="review"]').is(":hidden")){
179 $('.sbr_review_step1_notice').show()
180 }
181 app.updateNavigation();
182 },
183
184 /**
185 * Update navigation buttons.
186 *
187 * @since 2.18
188 */
189 updateNavigation: function() {
190
191 el.$currentMessage = el.$notifications.find( '.message.current' );
192 el.$nextMessage = el.$currentMessage.next( '.message' );
193 el.$prevMessage = el.$currentMessage.prev( '.message' );
194
195 if ( el.$nextMessage.length === 0 ) {
196 el.$nextButton.addClass( 'disabled' );
197 } else {
198 el.$nextButton.removeClass( 'disabled' );
199 }
200
201 if ( el.$prevMessage.length === 0 ) {
202 el.$prevButton.addClass( 'disabled' );
203 } else {
204 el.$prevButton.removeClass( 'disabled' );
205 }
206 },
207 };
208
209 return app;
210
211 }( document, window, jQuery ) );
212
213 // Initialize.
214 SBRAdminNotifications.init();
215
216 jQuery(document).ready(function($) {
217 /**
218 * Dismiss the renewed license notice
219 *
220 * @since 4.0
221 */
222 $(document).on('click', "#sbr-hide-notice", function() {
223 let sbrLicenseNotice = $('#sbr-license-notice');
224 let sbrLicenseModal = $('.sbr-sb-modal');
225 sbrLicenseNotice.remove();
226 sbrLicenseModal.remove();
227 });
228
229 /**
230 * Dismiss the license notice on dashboard page
231 *
232 * @since 4.0
233 */
234 $(document).on('click', "#sb-dismiss-notice", function() {
235 let sbrLicenseNotice = $('#sbr-license-notice');
236 let sbrLicenseModal = $('.sbr-sb-modal');
237 sbrLicenseNotice.remove();
238 sbrLicenseModal.remove();
239 $.ajax({
240 url: ajaxurl,
241 data: {
242 action: 'sbr_dismiss_license_notice',
243 sbr_nonce: sbrA.sbr_nonce
244
245 },
246 success: function(result){
247 // Notice dismissed successfully
248 }
249 });
250 });
251
252 jQuery('body').on('click', '#sbr_review_consent_yes', function(e) {
253 let reviewStep1 = jQuery('.sbr_review_notice_step_1, .sbr_review_step1_notice');
254 let reviewStep2 = jQuery('.sbr_notice.sbr_review_notice, .rn_step_2');
255
256 reviewStep1.hide();
257 reviewStep2.show();
258
259 $.ajax({
260 url : sbrA.ajax_url,
261 type : 'post',
262 data : {
263 action : 'sbr_review_notice_consent_update',
264 consent : 'yes',
265 sbr_nonce: sbrA.sbr_nonce
266 },
267 success : function(data) {
268 }
269 }); // ajax call
270
271 });
272
273 jQuery('body').on('click', '#sbr_review_consent_no', function(e) {
274 let reviewStep1 = jQuery('.sbr_review_notice_step_1, #sbr-notifications');
275 reviewStep1.hide();
276
277 $.ajax({
278 url : sbrA.ajax_url,
279 type : 'post',
280 data : {
281 action : 'sbr_review_notice_consent_update',
282 consent : 'no',
283 sbr_nonce: sbrA.sbr_nonce
284 },
285 success : function(data) {
286 }
287 }); // ajax call
288
289 });
290 });