PluginProbe ʕ •ᴥ•ʔ
External Links – nofollow, noopener & new window / 2.63
External Links – nofollow, noopener & new window v2.63
2.66 0.31 0.32 0.33 0.34 0.35 1.01 1.02 1.03 1.10 1.20 1.21 1.30 1.31 1.40 1.41 1.50 1.51 1.52 1.53 1.54 1.55 1.56 1.60 1.61 1.62 1.70 1.80 1.81 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.1.0 2.1.1 2.1.2 2.1.3 2.2.0 2.3 2.32 2.35 2.40 2.42 2.43 2.45 2.46 2.47 2.48 2.50 2.51 2.55 2.56 2.57 2.58 2.59 2.60 2.61 2.62 2.63 2.64 2.65 trunk 0.10 0.11 0.12 0.20 0.21 0.30
wp-external-links / public / js / wpel-admin.js
wp-external-links / public / js Last commit date
wpel-admin.js 3 years ago wpel-pointers.js 3 years ago
wpel-admin.js
346 lines
1 /**
2 * WP External Links Plugin
3 * Admin
4 */
5
6 /*global jQuery, window*/
7 jQuery(function ($) {
8 // add custom jQuery show/hide function
9 $.extend($.fn, {
10 wpelShow: function () {
11 var self = this;
12 this.stop({ clearQueue: true, jumpToEnd: true });
13 this.fadeIn({
14 duration: 500,
15 queue: false,
16 complete: function () {
17 self.removeClass('wpel-hidden');
18 },
19 });
20 },
21 wpelHide: function () {
22 var self = this;
23 this.stop({ clearQueue: true, jumpToEnd: true });
24 this.fadeOut({
25 duration: 500,
26 queue: false,
27 complete: function () {
28 self.addClass('wpel-hidden');
29 },
30 });
31 },
32 });
33
34 var $wrapper = $('.wpel-settings-page');
35
36 /**
37 * Apply Sections Settings
38 */
39 $wrapper.on('change', '.js-wpel-apply input', function () {
40 var applyAll = $(this).is(':checked');
41 var $items = $wrapper.find('.js-wpel-apply-child');
42
43 if (applyAll) {
44 $items.wpelHide();
45 } else {
46 $items.wpelShow();
47 }
48 });
49
50 // trigger immediatly
51 $wrapper.find('.js-wpel-apply input[type="checkbox"]').change();
52
53 /**
54 * Link Settings
55 */
56 $wrapper.on('change', '.js-icon-type select', function () {
57 var iconType = $(this).val();
58 var $itemsChild = $wrapper.find('.js-icon-type-child');
59 var $itemsDepend = $wrapper.find('.js-icon-type-depend');
60
61 $itemsChild.hide();
62
63 if (iconType === 'image') {
64 $itemsDepend.wpelShow();
65 $itemsChild.filter('.js-icon-type-image').wpelShow();
66 } else if (iconType === 'dashicon') {
67 $itemsDepend.wpelShow();
68 $itemsChild.filter('.js-icon-type-dashicon').wpelShow();
69 } else if (iconType === 'fontawesome') {
70 $itemsDepend.wpelShow();
71 $itemsChild.filter('.js-icon-type-fontawesome').wpelShow();
72 } else {
73 $itemsDepend.wpelHide();
74 }
75 });
76
77 $wrapper.on('change', '.js-apply-settings input[type="checkbox"]', function () {
78 var $items = $wrapper.find('.form-table tr').not('.js-apply-settings');
79
80 if ($(this).prop('checked')) {
81 $items.wpelShow();
82 $wrapper.find('.js-icon-type select').change();
83 } else {
84 $items.wpelHide();
85 }
86 });
87
88 // trigger immediatly
89 $wrapper.find('.js-apply-settings input[type="checkbox"]').change();
90
91 /**
92 * Support
93 * Copy to clipboard
94 */
95 $wrapper.on('click', '.js-wpel-copy', function (e) {
96 e.preventDefault();
97
98 var node = $wrapper.find('.js-wpel-copy-target').get(0);
99 node.select();
100
101 var range = document.createRange();
102 range.selectNode(node);
103 window.getSelection().addRange(range);
104
105 try {
106 document.execCommand('copy');
107 } catch (err) {}
108 });
109
110 /**
111 * Help documentation links/buttons
112 */
113 $wrapper.on('click', '[data-wpel-help]', function () {
114 var helpKey = $(this).data('wpel-help');
115
116 if (helpKey) {
117 // activate given tab
118 $('#tab-link-' + helpKey + ' a').click();
119 } else {
120 // activate first tab
121 $('.contextual-help-tabs li a').first().click();
122 }
123
124 $('#contextual-help-link[aria-expanded="false"]').click();
125 });
126
127 // show current tab
128 $wrapper.find('form').wpelShow();
129 // for network pages
130 $('.wpel-network-page').find('form').wpelShow();
131
132 // pro dialog
133 $('a.nav-tab-pro').on('click', function (e) {
134 e.preventDefault();
135
136 open_upsell('tab');
137
138 return false;
139 });
140
141 $('#wpwrap').on('click', '.open-pro-dialog', function (e) {
142 e.preventDefault();
143 $(this).blur();
144
145 pro_feature = $(this).data('pro-feature');
146 if (!pro_feature) {
147 pro_feature = $(this).parent('label').attr('for');
148 }
149 open_upsell(pro_feature);
150
151 return false;
152 });
153
154 $('#wpel-pro-dialog').dialog({
155 dialogClass: 'wp-dialog wpel-pro-dialog',
156 modal: true,
157 resizable: false,
158 width: 850,
159 height: 'auto',
160 show: 'fade',
161 hide: 'fade',
162 close: function (event, ui) {},
163 open: function (event, ui) {
164 $(this).siblings().find('span.ui-dialog-title').html('WP Links PRO is here!');
165 wpel_fix_dialog_close(event, ui);
166 },
167 autoOpen: false,
168 closeOnEscape: true,
169 });
170
171 function clean_feature(feature) {
172 feature = feature || 'free-plugin-unknown';
173 feature = feature.toLowerCase();
174 feature = feature.replace(' ', '-');
175
176 return feature;
177 }
178
179 function open_upsell(feature) {
180 feature = clean_feature(feature);
181
182 $('#wpel-pro-dialog').dialog('open');
183
184 $('#wpel-pro-table .button-buy').each(function (ind, el) {
185 tmp = $(el).data('href-org');
186 tmp = tmp.replace('pricing-table', feature);
187 $(el).attr('href', tmp);
188 });
189 } // open_upsell
190
191 if (window.localStorage.getItem('wpel_upsell_shown') != 'true') {
192 open_upsell('welcome');
193
194 window.localStorage.setItem('wpel_upsell_shown', 'true');
195 window.localStorage.setItem('wpel_upsell_shown_timestamp', new Date().getTime());
196 }
197
198 if (window.location.hash == '#open-pro-dialog') {
199 open_upsell('url-hash');
200 window.location.hash = '';
201 }
202
203 $('a.show-link-rules').click(function () {
204 $('#link-rules-new').dialog({
205 height: 'auto',
206 width: 'auto',
207 closeOnEscape: true,
208 dialogClass: 'wp-dialog',
209 modal: true,
210 open: function (event, ui) {
211 wpel_fix_dialog_close(event, ui);
212 },
213 });
214 });
215
216 jQuery(document).ready(function ($) {
217 $('.wpel-colorpicker').wpColorPicker();
218 });
219
220 $('.wpel-exit-confirmation').on('click', function (event) {
221 event.stopPropagation();
222 refresh_exit_confirmaiton_preview();
223 });
224
225 function refresh_exit_confirmaiton_preview() {
226 wp_external_links = {};
227 wp_external_links.background = $('#wpel-exit-confirmation-settings-background').val();
228 wp_external_links.title = $('#wpel-exit-confirmation-settings-title').val();
229 wp_external_links.title_color = $('#wpel-exit-confirmation-settings-title_color').val();
230 wp_external_links.title_background = $('#wpel-exit-confirmation-settings-title_background').val();
231 wp_external_links.title_size = $('#wpel-exit-confirmation-settings-title_size').val();
232 wp_external_links.text = $('#wpel-exit-confirmation-settings-text').val().replace('{siteurl}', wpel.home_url);
233 wp_external_links.text_color = $('#wpel-exit-confirmation-settings-text_color').val();
234 wp_external_links.text_size = $('#wpel-exit-confirmation-settings-text_size').val();
235 wp_external_links.popup_width = $('#wpel-exit-confirmation-settings-popup_width').val();
236 wp_external_links.popup_height = $('#wpel-exit-confirmation-settings-popup_height').val();
237 wp_external_links.overlay = $('#wpel-exit-confirmation-settings-overlay').val();
238 wp_external_links.overlay_color = $('#wpel-exit-confirmation-settings-overlay_color').val();
239 wp_external_links.button_text = $('#wpel-exit-confirmation-settings-button_text').val();
240 wp_external_links.button_size = $('#wpel-exit-confirmation-settings-button_size').val();
241 wp_external_links.button_color = $('#wpel-exit-confirmation-settings-button_color').val();
242 wp_external_links.button_background = $('#wpel-exit-confirmation-settings-button_background').val();
243 wp_external_links.title = $('#wpel-exit-confirmation-settings-title').val();
244
245 wp_external_links.href = 'https://www.google.com';
246
247 exit_confirmation_html = '';
248 if (wp_external_links.overlay == '1') {
249 exit_confirmation_html += '<div id="wpel_exit_confirmation_overlay"></div>';
250 }
251 exit_confirmation_html += '<div id="wpel_exit_confirmation">';
252 if (wp_external_links.title.length > 0) {
253 exit_confirmation_html += '<div id="wpel_exit_confirmation_title">' + wp_external_links.title + '</div>';
254 }
255 exit_confirmation_html +=
256 '<div id="wpel_exit_confirmation_link">' +
257 wp_external_links.text +
258 '<br /><a target="' +
259 wp_external_links.href +
260 '" href="' +
261 wp_external_links.href +
262 '">' +
263 wp_external_links.href +
264 '</a></div>';
265 exit_confirmation_html += '<div id="wpel_exit_confirmation_button_wrapper">';
266 exit_confirmation_html +=
267 '<div id="wpel_exit_confirmation_cancel" onMouseOver="this.style.opacity=\'0.8\'" onMouseOut="this.style.opacity=\'1\'">' +
268 wp_external_links.button_text +
269 '</a></div>';
270 exit_confirmation_html += '</div>';
271 exit_confirmation_html += '</div>';
272
273 exit_confirmation_html += '<style>';
274 exit_confirmation_html +=
275 '#wpel_exit_confirmation_overlay{width:100%;height:100%;position:fixed;top:0px;left:0px;opacity:0.2;z-index:100000;background:' +
276 wp_external_links.overlay_color +
277 ';}';
278 exit_confirmation_html +=
279 '#wpel_exit_confirmation{z-index:100001;border-radius:4px;padding-bottom:40px;position:fixed;top:0px;left:0px;top:50%;left:50%;margin-top:-' +
280 wp_external_links.popup_height / 2 +
281 'px;margin-left:-' +
282 wp_external_links.popup_width / 2 +
283 'px;width:' +
284 wp_external_links.popup_width +
285 'px;height:' +
286 wp_external_links.popup_height +
287 'px;background:' +
288 wp_external_links.background +
289 ';}';
290 exit_confirmation_html +=
291 '#wpel_exit_confirmation_title{width:100%;padding:6px 10px; text-align:center; box-sizing: border-box; background:' +
292 wp_external_links.title_background +
293 ';font-size:' +
294 wp_external_links.title_size +
295 'px; color:' +
296 wp_external_links.title_color +
297 ';}';
298 exit_confirmation_html +=
299 '#wpel_exit_confirmation_link{width:100%;padding:10px 20px; line-height: 1.5; box-sizing: border-box;font-size:' +
300 wp_external_links.text_size +
301 'px; color:' +
302 wp_external_links.text_color +
303 ';}';
304 exit_confirmation_html +=
305 '#wpel_exit_confirmation_button_wrapper{width:100%; text-align:center; position:absolute; bottom:10px;}';
306 exit_confirmation_html +=
307 '#wpel_exit_confirmation_cancel{cursor:pointer;border-radius:4px;padding:10px 15px;display:inline-block;font-size:' +
308 wp_external_links.button_size +
309 'px;color:' +
310 wp_external_links.button_color +
311 '; background:' +
312 wp_external_links.button_background +
313 ';}';
314
315 exit_confirmation_html += '@media only screen and (max-width: 900px) {';
316 exit_confirmation_html +=
317 '#wpel_exit_confirmation{ width: 90%; margin: 0 auto; padding-bottom: 40px; top: 20%; position: fixed; left: auto; height: auto; height:' +
318 wp_external_links.popup_height +
319 'px; display: block; margin-left: 5%;}';
320 exit_confirmation_html += '}';
321 exit_confirmation_html += '</style>';
322
323 $('#exit-confirmation-preview').html(exit_confirmation_html);
324 }
325
326 $('body').on('click', '#wpel_exit_confirmation_cancel', function (e) {
327 $('#wpel_exit_confirmation_overlay').remove();
328 $('#wpel_exit_confirmation').remove();
329 });
330
331 $('body').click(function () {
332 $('#wpel_exit_confirmation_overlay').remove();
333 $('#wpel_exit_confirmation').remove();
334 });
335
336 $('#wpel_exit_confirmation').click(function (event) {
337 event.stopPropagation();
338 });
339 });
340
341 function wpel_fix_dialog_close(event, ui) {
342 jQuery('.ui-widget-overlay').bind('click', function () {
343 jQuery('#' + event.target.id).dialog('close');
344 });
345 } // wpel_fix_dialog_close
346