PluginProbe ʕ •ᴥ•ʔ
Advanced Ads – Ad Manager & AdSense / 2.0.25
Advanced Ads – Ad Manager & AdSense v2.0.25
2.0.25 2.0.24 2.0.23 2.0.22 2.0.21 1.38.0 1.39.0 1.39.1 1.39.2 1.39.3 1.39.4 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.40.0 1.40.1 1.40.2 1.41.0 1.42.0 1.42.1 1.42.2 1.43.0 1.44.0 1.44.1 1.45.0 1.45.1 1.46.0 1.47.0 1.47.1 1.47.2 1.47.3 1.47.4 1.47.5 1.48.0 1.48.1 1.49.0 1.5.0 1.5.0.1 1.5.1 1.5.2 1.5.2.1 1.5.4 1.5.4.1 1.5.5 1.50.0 1.51.0 1.51.1 1.51.2 1.51.3 1.52.0 1.52.1 1.52.2 1.52.3 1.52.4 1.53.0 1.53.1 1.53.2 1.54.0 1.54.1 1.55.0 1.56.0 1.56.1 1.56.2 1.56.3 1.56.4 1.6 1.6.1 1.6.10 1.6.10.1 1.6.10.2 1.6.11 1.6.11.1 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.17.1 1.6.17.2 1.6.2 1.6.2.1 1.6.3 1.6.4 1.6.4.1 1.6.5 1.6.6 1.6.6.1 1.6.7 1.6.7.1 1.6.8 1.6.8.1 1.6.8.2 1.6.8.3 1.6.9 1.6.9.1 1.6.9.2 1.6.9.3 1.6.9.4 1.7 1.7.0.1 1.7.0.2 1.7.0.3 1.7.1 1.7.1.1 1.7.1.2 1.7.1.3 1.7.1.4 1.7.1.5 1.7.10 trunk 1.7.11 1.0.1 1.7.12 1.0.2 1.7.13 1.0.3 1.7.14 1.1.0 1.7.15 1.1.1 1.7.16 1.1.2 1.7.17 1.1.3 1.7.18 1.10 1.7.19 1.10.1 1.7.2 1.10.10 1.7.2.1 1.10.11 1.7.20 1.10.12 1.7.21 1.10.2 1.7.22 1.10.3 1.7.23 1.10.4 1.7.24 1.10.5 1.7.25 1.10.6 1.7.3 1.10.7 1.7.4 1.10.8 1.7.4.1 1.10.9 1.7.4.2 1.11 1.7.4.3 1.11.1 1.7.4.4 1.11.2 1.7.4.5 1.12 1.7.5 1.13 1.7.5.1 1.13.1 1.7.6 1.13.2 1.7.7 1.13.3 1.7.8 1.13.4 1.7.9 1.13.5 1.7.9.1 1.13.6 1.7.9.2 1.13.7 1.7.9.3 1.13.8 1.8 1.14 1.8.1 1.14.1 1.8.10 1.14.10 1.8.11 1.14.11 1.8.12 1.14.2 1.8.13 1.14.3 1.8.14 1.14.4 1.8.15 1.14.5 1.8.16 1.14.6 1.8.17 1.14.7 1.8.18 1.14.8 1.8.19 1.14.9 1.8.2 1.15 1.8.20 1.16 1.8.21 1.16.1 1.8.22 1.17 1.8.23 1.17.1 1.8.24 1.17.10 1.8.25 1.17.10-rc.1 1.8.26 1.17.11 1.8.27 1.17.12 1.8.28 1.17.12-rc.1 1.8.29 1.17.2 1.8.3 1.17.3 1.8.30 1.17.4 1.8.4 1.17.5 1.8.5 1.17.6 1.8.6 1.17.7 1.8.7 1.17.8 1.8.8 1.17.9 1.8.9 1.17.9-beta.1 1.9 1.18.0 2.0.0 1.19.0 2.0.1 1.19.1 2.0.10 1.2 2.0.11 1.2.1 2.0.12 1.2.2 2.0.13 1.2.3 2.0.14 1.2.4 2.0.15 1.2.5 2.0.16 1.2.6 2.0.17 1.2.7 2.0.18 1.20.0 2.0.19 1.20.0-rc.1 2.0.2 1.20.0-rc.2 2.0.20 1.20.1 2.0.3 1.20.2 2.0.4 1.20.3 2.0.5 1.21.0 2.0.6 1.21.1 2.0.7 1.22.0 2.0.8 1.22.1 2.0.9 1.22.2 1.23.0 1.23.1 1.23.2 1.24.0 1.24.1 1.24.2 1.25.0 1.25.1 1.26.0 1.27.0 1.28.0 1.29.0 1.29.1 1.3 1.3.1 1.3.10 1.3.11 1.3.12 1.3.13 1.3.14 1.3.15 1.3.16 1.3.17 1.3.18 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.30.0 1.30.1 1.30.2 1.30.2-rc.1 1.30.3 1.30.4 1.30.4-rc.1 1.30.5 1.31.0 1.31.1 1.32.0 1.32.0-rc.1 1.33.0 1.33.1 1.33.2 1.34.0 1.35.0 1.35.1 1.36.0 1.36.1 1.36.2 1.36.3 1.37.0 1.37.1 1.37.2
advanced-ads / admin / assets / js / admin-global.js
advanced-ads / admin / assets / js Last commit date
adblocker-image-data.js 1 year ago admin-global.js 1 year ago admin.js 2 days ago advertisement.js 3 months ago conditions.js 1 year ago dialog-advads-modal.js 1 year ago termination.js 1 year ago ui.js 3 years ago
admin-global.js
446 lines
1 /* eslint-disable no-unused-vars */
2 /* eslint-disable camelcase */
3 /*
4 * global js functions for Advanced Ads
5 */
6 jQuery(document).ready(function () {
7 /**
8 * ADMIN NOTICES
9 */
10 // close button
11 // .advads-notice-dismiss class can be used to add a custom close button (e.g., link)
12 jQuery(document).on(
13 'click',
14 '.advads-admin-notice .notice-dismiss, .advads-notice-dismiss',
15 function (event) {
16 event.preventDefault();
17 const messagebox = jQuery(this).parents('.advads-admin-notice');
18 if (messagebox.attr('data-notice') === undefined) return;
19
20 const query = {
21 action: 'advads-close-notice',
22 notice: messagebox.attr('data-notice'),
23 nonce: advadsglobal.ajax_nonce,
24 };
25 // send query
26 jQuery.post(ajaxurl, query, function (r) {
27 messagebox.fadeOut();
28 });
29 }
30 );
31 // hide notice for 7 days
32 jQuery(document).on(
33 'click',
34 '.advads-admin-notice .advads-notice-hide',
35 function () {
36 const messagebox = jQuery(this).parents('.advads-admin-notice');
37 if (messagebox.attr('data-notice') === undefined) return;
38
39 const query = {
40 action: 'advads-hide-notice',
41 notice: messagebox.attr('data-notice'),
42 nonce: advadsglobal.ajax_nonce,
43 };
44 // send query
45 jQuery.post(ajaxurl, query, function (r) {
46 messagebox.fadeOut();
47 });
48 }
49 );
50
51 // autoresponder button
52 jQuery('body').on('click', '.advads-notices-button-subscribe', function () {
53 if (this.dataset.notice === undefined) {
54 return;
55 }
56 const messageboxes = jQuery(this).parents('.advads-admin-notice');
57 if (!messageboxes.length) {
58 return;
59 }
60 const $messagebox = jQuery(messageboxes[0]);
61 jQuery('<span class="spinner advads-spinner"></span>').insertAfter(
62 this
63 );
64
65 const query = {
66 action: 'advads-subscribe-notice',
67 notice: this.dataset.notice,
68 nonce: advadsglobal.ajax_nonce,
69 };
70 // send and replace with server message
71 jQuery
72 .post(ajaxurl, query)
73 .success(function (response) {
74 $messagebox
75 .children('.advads-notice-box_wrapper')
76 .html('<p>' + response.data.message + '</p>');
77 $messagebox.addClass('notice-success notice');
78 })
79 .fail(function (response) {
80 $messagebox
81 .children('.advads-notice-box_wrapper')
82 .html('<p>' + response.responseJSON.data.message + '</p>');
83 $messagebox.addClass('notice-error notice');
84 })
85 .always(function () {
86 $messagebox.removeClass('notice-info');
87 });
88 });
89
90 /**
91 * Functions for Ad Health Notifications in the backend
92 */
93 // hide button (adds item to "ignore" list)
94 jQuery(document).on('click', '.advads-ad-health-notice-hide', function () {
95 const notice = jQuery(this).parents('li');
96 if (notice.attr('data-notice') === undefined) return;
97 // var list = notice.parent( 'ul' );
98 const remove = jQuery(this).hasClass('remove');
99
100 // fix height to prevent the box from going smaller first, then show the "show" link and grow again
101 const notice_box = jQuery('#advads_overview_notices');
102 notice_box.css('height', notice_box.height() + 'px');
103
104 const query = {
105 action: 'advads-ad-health-notice-hide',
106 notice: notice.attr('data-notice'),
107 nonce: advadsglobal.ajax_nonce,
108 };
109 // fade out first or remove, so users can’t click twice
110 if (remove) {
111 notice.remove();
112 } else {
113 notice.hide();
114 }
115 // show loader
116 notice_box.find('.advads-loader').show();
117 advads_ad_health_maybe_remove_list();
118 // send query
119 jQuery.post(ajaxurl, query, function (r) {
120 // update number in menu
121 advads_ad_health_reload_number_in_menu();
122 // update show button
123 advads_ad_health_reload_show_link();
124 // remove the fixed height
125 jQuery('#advads_overview_notices').css('height', '');
126 // remove loader
127 notice_box.find('.advads-loader').hide();
128 });
129 });
130 // show all hidden notices
131 jQuery(document).on(
132 'click',
133 '.advads-ad-health-notices-show-hidden',
134 function () {
135 advads_ad_health_show_hidden();
136 }
137 );
138
139 /**
140 * DEACTIVATION FEEDBACK FORM
141 */
142 // show overlay when clicked on "deactivate"
143 const advads_deactivate_link = jQuery(
144 '.wp-admin.plugins-php tr[data-slug="advanced-ads"] .row-actions .deactivate a'
145 );
146
147 const advads_deactivate_link_url = advads_deactivate_link.attr('href');
148 advads_deactivate_link.on('click', function (e) {
149 e.preventDefault();
150 // only show feedback form once per 30 days
151 const c_value = advads_admin_get_cookie(
152 'advanced_ads_hide_deactivate_feedback'
153 );
154 if (c_value === undefined) {
155 jQuery('#advanced-ads-feedback-overlay').show();
156 } else {
157 // click on the link
158 window.location.href = advads_deactivate_link_url;
159 }
160 });
161 // show text fields
162 jQuery('#advanced-ads-feedback-content input[type="radio"]').on(
163 'click',
164 function () {
165 // show text field if there is one
166 jQuery(this)
167 .parents('li')
168 .next('li')
169 .children('input[type="text"], textarea')
170 .show();
171 }
172 );
173 // handle technical issue feedback in particular
174 jQuery('#advanced-ads-feedback-content .advanced_ads_disable_help_text').on(
175 'focus',
176 function () {
177 // show text field if there is one
178 jQuery(this)
179 .parents('li')
180 .siblings('.advanced_ads_disable_reply')
181 .show();
182 }
183 );
184 // send form or close it
185 jQuery('#advanced-ads-feedback-content .button').on('click', function (e) {
186 e.preventDefault();
187 const self = jQuery(this);
188 // set cookie for 30 days
189 advads_store_feedback_cookie();
190 // save if plugin should be disabled
191 const disable_plugin = self.hasClass(
192 'advanced-ads-feedback-not-deactivate'
193 )
194 ? false
195 : true;
196
197 // hide the content of the feedback form
198 jQuery('#advanced-ads-feedback-content form').hide();
199 if (self.hasClass('advanced-ads-feedback-submit')) {
200 // show feedback message
201 jQuery('#advanced-ads-feedback-after-submit-waiting').show();
202 if (disable_plugin) {
203 jQuery(
204 '#advanced-ads-feedback-after-submit-disabling-plugin'
205 ).show();
206 }
207 jQuery.ajax({
208 type: 'POST',
209 url: ajaxurl,
210 dataType: 'json',
211 data: {
212 action: 'advads_send_feedback',
213 feedback: self.hasClass(
214 'advanced-ads-feedback-not-deactivate'
215 )
216 ? true
217 : false,
218 formdata: jQuery(
219 '#advanced-ads-feedback-content form'
220 ).serialize(),
221 },
222 complete(MLHttpRequest, textStatus, errorThrown) {
223 // deactivate the plugin and close the popup with a timeout
224 setTimeout(function () {
225 jQuery('#advanced-ads-feedback-overlay').remove();
226 }, 2000);
227 if (disable_plugin) {
228 window.location.href = advads_deactivate_link_url;
229 }
230 },
231 });
232 } else {
233 // currently not reachable
234 jQuery('#advanced-ads-feedback-overlay').remove();
235 window.location.href = advads_deactivate_link_url;
236 }
237 });
238 // close form and disable the plugin without doing anything
239 jQuery('.advanced-ads-feedback-only-deactivate').on('click', function () {
240 // hide the content of the feedback form
241 jQuery('#advanced-ads-feedback-content form').hide();
242 // show feedback message
243 jQuery('#advanced-ads-feedback-after-submit-goodbye').show();
244 jQuery('#advanced-ads-feedback-after-submit-disabling-plugin').show();
245 // set cookie for 30 days
246 advads_store_feedback_cookie();
247 // wait one second
248 setTimeout(function () {
249 jQuery('#advanced-ads-feedback-overlay').hide();
250 window.location.href = advads_deactivate_link_url;
251 }, 1000);
252 });
253 // close button for feedback form
254 jQuery('#advanced-ads-feedback-overlay-close-button').on(
255 'click',
256 function () {
257 jQuery('#advanced-ads-feedback-overlay').hide();
258 }
259 );
260
261 jQuery('.advads-help').on('mouseenter', function (event) {
262 const tooltip = jQuery(event.target).children('.advads-tooltip')[0];
263 if (typeof tooltip === 'undefined') {
264 return;
265 }
266
267 // reset inline styles before getting bounding client rect.
268 tooltip.style.position = '';
269 tooltip.style.left = '';
270 tooltip.style.top = '';
271
272 const topParentRect = document
273 .getElementById('wpbody')
274 .getBoundingClientRect(),
275 helpRect = event.target.getBoundingClientRect(),
276 offsets = {
277 left: Math.ceil(helpRect.left) + 13,
278 top: Math.ceil(helpRect.top) + 13,
279 };
280 let tooltipRect = tooltip.getBoundingClientRect();
281
282 tooltip.style.position = 'fixed';
283 tooltip.style.left = offsets.left + 'px';
284 tooltip.style.top = offsets.top + 'px';
285
286 // check element is not overflowing to the right.
287 while (tooltipRect.right > topParentRect.right - 20) {
288 offsets.left -= 10;
289 tooltip.style.left = offsets.left + 'px';
290 tooltipRect = tooltip.getBoundingClientRect();
291 }
292
293 // check element is not overflowing bottom of parent and is within viewport.
294 while (tooltipRect.bottom > Math.min(topParentRect.bottom, jQuery(window).height()) - 20) {
295 offsets.top -= 10;
296 tooltip.style.top = offsets.top + 'px';
297 tooltipRect = tooltip.getBoundingClientRect();
298 }
299 });
300 });
301
302 // remove duplicate close buttons
303 jQuery(window).on('load', function () {
304 jQuery('a.notice-dismiss').next('button.notice-dismiss').remove();
305 });
306
307 function advads_admin_get_cookie(name) {
308 let i, x, y;
309 const ADVcookies = document.cookie.split(';');
310 for (i = 0; i < ADVcookies.length; i++) {
311 x = ADVcookies[i].substr(0, ADVcookies[i].indexOf('='));
312 y = ADVcookies[i].substr(ADVcookies[i].indexOf('=') + 1);
313 x = x.replace(/^\s+|\s+$/g, '');
314 if (x === name) {
315 return unescape(y);
316 }
317 }
318 }
319
320 /**
321 * Store a cookie for 30 days
322 * The cookie prevents the feedback form from showing multiple times
323 */
324 function advads_store_feedback_cookie() {
325 const exdate = new Date();
326 exdate.setSeconds(exdate.getSeconds() + 2592000);
327 document.cookie =
328 'advanced_ads_hide_deactivate_feedback=1; expires=' +
329 exdate.toUTCString() +
330 '; path=/';
331 }
332
333 /**
334 * Ad Health Notices in backend
335 */
336 // display notices list (deprecated because we load it without AJAX now)
337 function advads_display_ad_health_notices() {
338 const query = {
339 action: 'advads-ad-health-notice-display',
340 nonce: advadsglobal.ajax_nonce,
341 };
342
343 const widget = jQuery('#advads_overview_notices .main');
344
345 // add loader icon to the widget
346 widget.html('<span class="advads-loader"></span>');
347 // send query
348 jQuery.post(ajaxurl, query, function (r) {
349 widget.html(r);
350
351 // update number in menu
352 advads_ad_health_reload_number_in_menu();
353 // update list headlines
354 advads_ad_health_maybe_remove_list();
355
356 // remove widget, if return is empty
357 if (r === '') {
358 jQuery('#advads_overview_notices').remove();
359 }
360 });
361 }
362 // push a notice to the queue
363 function advads_push_notice(key, attr = '') {
364 const query = {
365 action: 'advads-ad-health-notice-push-adminui',
366 key,
367 attr,
368 nonce: advadsglobal.ajax_nonce,
369 };
370 // send query
371 jQuery.post(ajaxurl, query, function (r) {});
372 }
373 // show notices of a given type again
374 function advads_ad_health_show_hidden() {
375 const notice_box = jQuery('#advads__overview_notices');
376 const query = {
377 action: 'advads-ad-health-notice-unignore',
378 nonce: advadsglobal.ajax_nonce,
379 };
380 // show all hidden
381 jQuery(document)
382 .find('#advads_overview_notices .advads-ad-health-notices > li:hidden')
383 .show();
384 // show loader
385 notice_box.find('.advads-loader').show();
386 // update the button
387 advads_ad_health_reload_show_link();
388 advads_ad_health_maybe_remove_list();
389 // send query
390 jQuery.post(ajaxurl, query, function (r) {
391 // update issue count
392 advads_ad_health_reload_number_in_menu();
393 // hide loader
394 notice_box.find('.advads-loader').hide();
395 });
396 }
397 // hide list fragments if last item was hidden/removed
398 function advads_ad_health_maybe_remove_list() {
399 // get all lists
400 const lists = jQuery(document).find(
401 '#advads_overview_notices .advads-ad-health-notices'
402 );
403
404 // check each list separately
405 lists.each(function (index) {
406 const list = jQuery(this);
407 // check if there are visible items in the list
408 if (list.find('li:visible').length) {
409 // show parent headline
410 list.prev('h3').show();
411 } else {
412 // hide parent headline
413 list.prev('h3').hide();
414 }
415 });
416 }
417 // reload number of notices shown in the sidebar based on element in the problems list
418 function advads_ad_health_reload_number_in_menu() {
419 // get number of notices
420 const number = jQuery(document).find(
421 '#advads_overview_notices .advads-ad-health-notices > li:visible'
422 ).length;
423 jQuery('#toplevel_page_advanced-ads .update-count').html(number);
424 }
425 // update show X issues link – number and visibility
426 function advads_ad_health_reload_show_link() {
427 // get number of invisible elements
428 const number = jQuery(document).find(
429 '#advads_overview_notices .advads-ad-health-notices > li:hidden'
430 ).length;
431 const show_link = jQuery('.advads-ad-health-notices-show-hidden');
432 // update number in the link
433 jQuery('.advads-ad-health-notices-show-hidden .count').html(number);
434 // hide of show, depending on number
435 if (0 === number) {
436 show_link.hide();
437 } else {
438 show_link.show();
439 }
440 }
441
442 //Radio Toggle visibility
443 function toggle_visibility(currentElement, toggleElement) {
444 jQuery(toggleElement).toggle(jQuery(currentElement).val() === 'on');
445 }
446