PluginProbe ʕ •ᴥ•ʔ
Reviews Feed – Add Testimonials and Customer Reviews From Google Reviews, Yelp, TripAdvisor, and More / 2.9.0
Reviews Feed – Add Testimonials and Customer Reviews From Google Reviews, Yelp, TripAdvisor, and More v2.9.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
296 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 var href = $(this).attr('href');
45 if (href && href.indexOf('dismiss=') > -1 ) {
46 $(this).addClass('button-dismiss');
47 }
48 })
49
50 $( app.ready );
51 },
52
53 /**
54 * Document ready.
55 *
56 * @since 2.18
57 */
58 ready: function() {
59
60 app.updateNavigation();
61 app.events();
62 },
63
64 /**
65 * Register JS events.
66 *
67 * @since 2.18
68 */
69 events: function() {
70
71 el.$notifications
72 .on( 'click', '.dismiss', app.dismiss )
73 .on( 'click', '.button-dismiss', app.buttonDismiss )
74 .on( 'click', '.next', app.navNext )
75 .on( 'click', '.prev', app.navPrev );
76 },
77
78 /**
79 * Click on a dismiss button.
80 *
81 * @since 2.18
82 */
83 buttonDismiss: function( event ) {
84 event.preventDefault();
85 app.dismiss();
86 },
87
88 /**
89 * Click on the Dismiss notification button.
90 *
91 * @since 2.18
92 *
93 * @param {object} event Event object.
94 */
95 dismiss: function( event ) {
96
97 if ( el.$currentMessage.length === 0 ) {
98 return;
99 }
100
101 // Update counter.
102 var count = parseInt( el.$adminBarCounter.text(), 10 );
103 if ( count > 1 ) {
104 --count;
105 el.$adminBarCounter.html( '<span>' + count + '</span>' );
106 } else {
107 el.$adminBarCounter.remove();
108 el.$adminBarMenuItem.remove();
109 }
110
111 // Remove notification.
112 var $nextMessage = el.$nextMessage.length < 1 ? el.$prevMessage : el.$nextMessage,
113 messageId = el.$currentMessage.data( 'message-id' );
114
115 if ( $nextMessage.length === 0 ) {
116 el.$notifications.remove();
117 } else {
118 el.$currentMessage.remove();
119 $nextMessage.addClass( 'current' );
120 app.updateNavigation();
121 }
122
123 // AJAX call - update option.
124 var data = {
125 action: 'sbr_dashboard_notification_dismiss',
126 nonce: sbrA.sbr_nonce,
127 id: messageId,
128 };
129
130 $.post( sbrA.ajax_url, data, function( res ) {
131
132 if ( ! res.success ) {
133 //SBRAdmin.debug( res );
134 }
135 } ).fail( function( xhr, textStatus, e ) {
136
137 //SBRAdmin.debug( xhr.responseText );
138 } );
139 },
140
141 /**
142 * Click on the Next notification button.
143 *
144 * @since 2.18
145 *
146 * @param {object} event Event object.
147 */
148 navNext: function( event ) {
149
150 if ( el.$nextButton.hasClass( 'disabled' ) ) {
151 return;
152 }
153
154
155 el.$currentMessage.removeClass( 'current' );
156 el.$nextMessage.addClass( 'current' );
157 if( !$('.message[data-message-id="review"]').hasClass('current') ){
158 $('.sbr_review_step1_notice').hide()
159 }
160
161 app.updateNavigation();
162 },
163
164 /**
165 * Click on the Previous notification button.
166 *
167 * @since 2.18
168 *
169 * @param {object} event Event object.
170 */
171 navPrev: function( event ) {
172
173 if ( el.$prevButton.hasClass( 'disabled' ) ) {
174 return;
175 }
176
177 el.$currentMessage.removeClass( 'current' );
178 el.$prevMessage.addClass( 'current' );
179 if( $('.message[data-message-id="review"]').hasClass('current') && $('.message[data-message-id="review"]').is(":hidden")){
180 $('.sbr_review_step1_notice').show()
181 }
182 app.updateNavigation();
183 },
184
185 /**
186 * Update navigation buttons.
187 *
188 * @since 2.18
189 */
190 updateNavigation: function() {
191
192 el.$currentMessage = el.$notifications.find( '.message.current' );
193 el.$nextMessage = el.$currentMessage.next( '.message' );
194 el.$prevMessage = el.$currentMessage.prev( '.message' );
195
196 app.setNavState( el.$nextButton, el.$nextMessage.length === 0 );
197 app.setNavState( el.$prevButton, el.$prevMessage.length === 0 );
198 },
199
200 /**
201 * Sync a nav button's disabled class with its native disabled state.
202 *
203 * The nav controls are real <button> elements, so toggling the native
204 * `disabled` property keeps them out of the tab order and conveys the
205 * disabled state to assistive tech. The `disabled` class is kept for CSS.
206 *
207 * @param {object} $btn jQuery-wrapped nav button.
208 * @param {boolean} isDisabled Whether the button should be disabled.
209 */
210 setNavState: function( $btn, isDisabled ) {
211 $btn.toggleClass( 'disabled', isDisabled ).prop( 'disabled', isDisabled );
212 },
213 };
214
215 return app;
216
217 }( document, window, jQuery ) );
218
219 // Initialize.
220 SBRAdminNotifications.init();
221
222 jQuery(document).ready(function($) {
223 /**
224 * Dismiss the renewed license notice
225 *
226 * @since 4.0
227 */
228 $(document).on('click', "#sbr-hide-notice", function() {
229 let sbrLicenseNotice = $('#sbr-license-notice');
230 let sbrLicenseModal = $('.sbr-sb-modal');
231 sbrLicenseNotice.remove();
232 sbrLicenseModal.remove();
233 });
234
235 /**
236 * Dismiss the license notice on dashboard page
237 *
238 * @since 4.0
239 */
240 $(document).on('click', "#sb-dismiss-notice", function() {
241 let sbrLicenseNotice = $('#sbr-license-notice');
242 let sbrLicenseModal = $('.sbr-sb-modal');
243 sbrLicenseNotice.remove();
244 sbrLicenseModal.remove();
245 $.ajax({
246 url: ajaxurl,
247 data: {
248 action: 'sbr_dismiss_license_notice',
249 sbr_nonce: sbrA.sbr_nonce
250
251 },
252 success: function(result){
253 // Notice dismissed successfully
254 }
255 });
256 });
257
258 jQuery('body').on('click', '#sbr_review_consent_yes', function(e) {
259 let reviewStep1 = jQuery('.sbr_review_notice_step_1, .sbr_review_step1_notice');
260 let reviewStep2 = jQuery('.sbr_notice.sbr_review_notice, .rn_step_2');
261
262 reviewStep1.hide();
263 reviewStep2.show();
264
265 $.ajax({
266 url : sbrA.ajax_url,
267 type : 'post',
268 data : {
269 action : 'sbr_review_notice_consent_update',
270 consent : 'yes',
271 sbr_nonce: sbrA.sbr_nonce
272 },
273 success : function(data) {
274 }
275 }); // ajax call
276
277 });
278
279 jQuery('body').on('click', '#sbr_review_consent_no', function(e) {
280 let reviewStep1 = jQuery('.sbr_review_notice_step_1, #sbr-notifications');
281 reviewStep1.hide();
282
283 $.ajax({
284 url : sbrA.ajax_url,
285 type : 'post',
286 data : {
287 action : 'sbr_review_notice_consent_update',
288 consent : 'no',
289 sbr_nonce: sbrA.sbr_nonce
290 },
291 success : function(data) {
292 }
293 }); // ajax call
294
295 });
296 });