PluginProbe ʕ •ᴥ•ʔ
Jetpack – WP Security, Backup, Speed, & Growth / 12.7.3
Jetpack – WP Security, Backup, Speed, & Growth v12.7.3
12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 14.4.2 14.5.1 14.6.1 14.7.1 14.8.1 14.9.2 15.0.3 15.1.2 15.2.1 15.3.2 15.4.1 15.5.1 15.6.1 15.7.2 15.8.1 15.9.2 16.0.2 16.1.3 16.2-a.5 16.2-a.3 16.1.2 16.2-a.1 16.1.1 16.1 16.1-beta 16.1-beta.2 16.1-beta.3 16.1-a.5 16.1-a.3 16.0.1 16.1-a.1 16.0 16.0-beta 16.0-a.7 16.0-a.5 15.9.1 16.0-a.3 16.0-a.1 15.9 15.9-beta 15.9-a.7 15.9-a.5 15.9-a.3 15.9-a.1 15.8 15.8-beta 15.8-a.7 15.8-a.5 5.2.5 5.3.4 5.4.4 5.5.5 5.6.5 5.7.5 5.8.4 5.9.4 6.0.4 6.1 6.1.1 6.1.2 6.1.3 6.1.4 6.1.5 6.2 6.2.1 6.2.2 6.2.3 6.2.4 6.2.5 6.3 6.3.1 6.3.2 6.3.3 6.3.4 6.3.5 6.3.6 6.3.7 6.4 6.4.1 6.4.2 6.4.3 6.4.4 6.4.5 6.4.6 6.5 6.5.1 6.5.2 6.5.3 6.5.4 6.6 6.6.1 6.6.2 6.6.3 6.6.4 6.6.5 6.7 6.7.1 6.7.2 6.7.3 6.7.4 6.8 6.8.1 6.8.2 6.8.3 6.8.4 6.8.5 6.9 6.9.1 6.9.2 6.9.3 6.9.4 7.0 7.0.1 7.0.2 7.0.3 7.0.4 7.0.5 7.1 7.1.1 7.1.2 7.1.3 7.1.4 7.1.5 7.2 7.2.1 7.2.1.1 7.2.2 7.2.3 7.2.4 7.2.5 7.3 7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3 4.7.4 4.8.5 4.9.3 5.0.3 5.1.4 trunk 10.0 10.0.1 10.0.2 10.1 10.1.1 10.1.2 10.2 10.2.1 10.2.2 10.2.3 10.3 10.3.1 10.3.2 10.4 10.4.1 10.4.2 10.5 10.5.1 10.5.2 10.5.3 10.6 10.6.1 10.6.2 10.7 10.7.1 10.7.2 10.8 10.8.1 10.8.2 10.9 10.9.1 10.9.2 10.9.3 11.0 11.0.1 11.0.2 11.1 11.1.1 11.1.2 11.1.3 11.1.4 11.2 11.2.1 11.2.2 11.3 11.3.1 11.3.2 11.3.3 11.3.4 11.4 11.4.1 11.4.2 11.5 11.5.1 11.5.2 11.5.3 11.6 11.6.1 11.6.2 11.7 11.7.1 11.7.2 11.7.3 11.8 11.8.3 11.8.4 11.8.5 11.8.6 11.9 11.9.1 11.9.2 11.9.3 12.0 12.0.1 12.0.2 12.1 12.1.1 12.1.2 12.2 12.2.1 12.2.2 12.3 12.3.1 12.4 12.4.1 12.5 12.5.1 12.6 12.6.1 12.6.2 12.6.3 12.7 12.7.1 12.7.2 12.8 12.8.1 12.8.2 12.9 12.9.1 12.9.2 12.9.3 12.9.4 13.0 13.0.1 13.1 13.1.1 13.1.2 13.1.3 13.1.4 13.2 13.2.1 13.2.2 13.2.3 13.3 13.3.1 13.3.2 13.4 13.4.1 13.4.2 13.4.3 13.4.4 13.5 13.5.1 13.6 13.6.1 13.7 13.7.1 13.8 13.8.1 13.8.2 13.9 13.9.1 14.0 14.1 14.2 14.2.1 14.3 14.4 14.4.1 14.5 14.6 14.7 14.8 14.9 14.9.1 15.0 15.0.1 15.0.2 15.1 15.1.1 15.2 15.3 15.3.1 15.4 15.5 15.6 15.7 15.7-a.1 15.7-a.3 15.7-a.5 15.7-a.7 15.7-beta
jetpack / modules / sharedaddy / admin-sharing.js
jetpack / modules / sharedaddy Last commit date
images 3 years ago services 2 years ago admin-sharing-rtl.css 2 years ago admin-sharing-rtl.min.css 2 years ago admin-sharing.css 2 years ago admin-sharing.js 2 years ago admin-sharing.min.css 2 years ago amp-sharing.css 4 years ago recaptcha.php 4 years ago sharedaddy.php 3 years ago sharing-service.php 2 years ago sharing-sources.php 2 years ago sharing.css 2 years ago sharing.js 3 years ago sharing.php 2 years ago
admin-sharing.js
519 lines
1 /* global sharing_loading_icon */
2
3 ( function ( $ ) {
4 $( document ).ready( function () {
5 function enable_share_button() {
6 $( '.preview a.sharing-anchor' )
7 .unbind( 'mouseenter mouseenter' )
8 .hover(
9 function () {
10 if ( $( this ).data( 'hasappeared' ) !== true ) {
11 var item = $( '.sharing-hidden .inner' );
12 var original = $( this ).parents( 'li' );
13
14 // Create a timer to make the area appear if the mouse hovers for a period
15 var timer = setTimeout( function () {
16 $( item )
17 .css( {
18 left: $( original ).position().left + 'px',
19 top: $( original ).position().top + $( original ).height() + 3 + 'px',
20 } )
21 .slideDown( 200, function () {
22 // Mark the item as have being appeared by the hover
23 $( original )
24 .data( 'hasappeared', true )
25 .data( 'hasoriginal', true )
26 .data( 'hasitem', false );
27
28 // Remove all special handlers
29 $( item ).mouseleave( handler_item_leave ).mouseenter( handler_item_enter );
30 $( original )
31 .mouseleave( handler_original_leave )
32 .mouseenter( handler_original_enter );
33
34 // Add a special handler to quickly close the item
35 $( original ).click( close_it );
36 } );
37
38 // The following handlers take care of the mouseenter/mouseleave for the share button and the share area - if both are left then we close the share area
39 var handler_item_leave = function () {
40 $( original ).data( 'hasitem', false );
41
42 if ( $( original ).data( 'hasoriginal' ) === false ) {
43 var timer = setTimeout( close_it, 800 );
44 $( original ).data( 'timer2', timer );
45 }
46 };
47
48 var handler_item_enter = function () {
49 $( original ).data( 'hasitem', true );
50 clearTimeout( $( original ).data( 'timer2' ) );
51 };
52
53 var handler_original_leave = function () {
54 $( original ).data( 'hasoriginal', false );
55
56 if ( $( original ).data( 'hasitem' ) === false ) {
57 var timer = setTimeout( close_it, 800 );
58 $( original ).data( 'timer2', timer );
59 }
60 };
61
62 var handler_original_enter = function () {
63 $( original ).data( 'hasoriginal', true );
64 clearTimeout( $( original ).data( 'timer2' ) );
65 };
66
67 var close_it = function () {
68 item.slideUp( 200 );
69
70 // Clear all hooks
71 $( original )
72 .unbind( 'mouseleave', handler_original_leave )
73 .unbind( 'mouseenter', handler_original_enter );
74 $( item )
75 .unbind( 'mouseleave', handler_item_leave )
76 .unbind( 'mouseenter', handler_item_leave );
77 $( original ).data( 'hasappeared', false );
78 $( original ).unbind( 'click', close_it );
79 return false;
80 };
81 }, 200 );
82
83 // Remember the timer so we can detect it on the mouseout
84 $( this ).data( 'timer', timer );
85 }
86 },
87 function () {
88 // Mouse out - remove any timer
89 clearTimeout( $( this ).data( 'timer' ) );
90 $( this ).data( 'timer', false );
91 }
92 );
93 }
94
95 function update_preview() {
96 var button_style = $( '#button_style' ).val();
97
98 // Toggle .sd-social-official class
99 var sharedaddy = $( '.sharedaddy' );
100 var oficialClass = 'sd-social-official';
101 if ( 'official' === button_style ) {
102 sharedaddy.addClass( oficialClass );
103 } else {
104 sharedaddy.removeClass( oficialClass );
105 }
106
107 // Clear the live preview
108 $( '#live-preview ul.preview li' ).remove();
109
110 // Add label
111 if (
112 $( '#save-enabled-shares input[name=visible]' ).val() ||
113 $( '#save-enabled-shares input[name=hidden]' ).val()
114 ) {
115 $( '#live-preview ul.preview' ).append(
116 $( '#live-preview ul.archive .sharing-label' ).clone()
117 );
118 }
119
120 // Re-insert all the enabled items
121 $( 'ul.services-enabled li' ).each( function () {
122 if ( $( this ).hasClass( 'service' ) ) {
123 var service = $( this ).attr( 'id' );
124 $( '#live-preview ul.preview' ).append(
125 $( '#live-preview ul.archive li.preview-' + service ).clone()
126 );
127 }
128 } );
129
130 // Add any hidden items
131 if ( $( '#save-enabled-shares input[name=hidden]' ).val() ) {
132 // Add share button
133 $( '#live-preview ul.preview' ).append(
134 $( '#live-preview ul.archive .share-more' ).parent().clone()
135 );
136
137 $( '.sharing-hidden ul li' ).remove();
138
139 // Add hidden items into the inner panel
140 $( 'ul.services-hidden li' ).each( function (/*pos, item*/) {
141 if ( $( this ).hasClass( 'service' ) ) {
142 var service = $( this ).attr( 'id' );
143 $( '.sharing-hidden .inner ul' ).append(
144 $( '#live-preview ul.archive .preview-' + service ).clone()
145 );
146 }
147 } );
148
149 enable_share_button();
150 }
151
152 $( '#live-preview div.sharedaddy' ).removeClass( 'sd-social-icon' );
153 $( '#live-preview li.advanced' ).removeClass( 'no-icon' );
154
155 // Button style
156 if ( 'icon' === button_style ) {
157 $( '#live-preview ul.preview div span, .sharing-hidden .inner ul div span' )
158 .html( ' ' )
159 .parent()
160 .addClass( 'no-text' );
161 $( '#live-preview div.sharedaddy' ).addClass( 'sd-social-icon' );
162 } else if ( 'official' === button_style ) {
163 $( '#live-preview ul.preview .advanced, .sharing-hidden .inner ul .advanced' ).each(
164 function (/*i*/) {
165 if (
166 ! $( this ).hasClass( 'preview-press-this' ) &&
167 ! $( this ).hasClass( 'preview-email' ) &&
168 ! $( this ).hasClass( 'preview-mastodon' ) &&
169 ! $( this ).hasClass( 'preview-nextdoor' ) &&
170 ! $( this ).hasClass( 'preview-print' ) &&
171 ! $( this ).hasClass( 'preview-reddit' ) &&
172 ! $( this ).hasClass( 'preview-telegram' ) &&
173 ! $( this ).hasClass( 'preview-jetpack-whatsapp' ) &&
174 ! $( this ).hasClass( 'preview-x' ) &&
175 ! $( this ).hasClass( 'share-custom' ) &&
176 ! $( this ).hasClass( 'share-deprecated' )
177 ) {
178 $( this )
179 .find( '.option a span' )
180 .html( '' )
181 .parent()
182 .removeClass( 'sd-button' )
183 .parent()
184 .attr( 'class', 'option option-smart-on' );
185 }
186 }
187 );
188 } else if ( 'text' === button_style ) {
189 $( '#live-preview li.advanced' ).addClass( 'no-icon' );
190 }
191 }
192
193 window.sharing_option_changed = function () {
194 var item = this;
195
196 // Loading icon
197 $( this )
198 .parents( 'li:first' )
199 .css( 'backgroundImage', 'url("' + sharing_loading_icon + '")' );
200
201 // Save
202 $( this )
203 .parents( 'form' )
204 .ajaxSubmit( function ( response ) {
205 if ( response.indexOf( '<!---' ) >= 0 ) {
206 var button = response.substring( 0, response.indexOf( '<!--->' ) );
207 var preview = response.substring( response.indexOf( '<!--->' ) + 6 );
208
209 if ( $( item ).is( ':submit' ) === true ) {
210 // Update the DOM using a bit of cut/paste technology
211
212 $( item ).parents( 'li:first' ).replaceWith( button );
213 }
214
215 $(
216 '#live-preview ul.archive li.preview-' +
217 $( item ).parents( 'form' ).find( 'input[name=service]' ).val()
218 ).replaceWith( preview );
219 }
220
221 // Update preview
222 update_preview();
223
224 // Restore the icon
225 $( item ).parents( 'li:first' ).removeAttr( 'style' );
226 } );
227
228 if ( $( item ).is( ':submit' ) === true ) {
229 return false;
230 }
231 return true;
232 };
233
234 function showExtraOptions( service ) {
235 jQuery( '.' + service + '-extra-options' )
236 .css( { backgroundColor: '#ffffcc' } )
237 .fadeIn();
238 }
239
240 function hideExtraOptions( service ) {
241 jQuery( '.' + service + '-extra-options' ).fadeOut( 'slow' );
242 }
243
244 function save_services() {
245 $( '#enabled-services h3 img' ).show();
246
247 // Toggle various dividers/help texts
248 if ( $( '#enabled-services ul.services-enabled li.service' ).length > 0 ) {
249 $( '#drag-instructions' ).hide();
250 } else {
251 $( '#drag-instructions' ).show();
252 }
253
254 if ( $( '#enabled-services li.service' ).length > 0 ) {
255 $( '#live-preview .services h2' ).hide();
256 } else {
257 $( '#live-preview .services h2' ).show();
258 }
259
260 // Gather the modules
261 var visible = [],
262 hidden = [];
263
264 $( 'ul.services-enabled li' ).each( function () {
265 if ( $( this ).hasClass( 'service' ) ) {
266 // Ready for saving
267 visible[ visible.length ] = $( this ).attr( 'id' );
268 showExtraOptions( $( this ).attr( 'id' ) );
269 }
270 } );
271
272 $( 'ul.services-available li' ).each( function () {
273 if ( $( this ).hasClass( 'service' ) ) {
274 hideExtraOptions( $( this ).attr( 'id' ) );
275 }
276 } );
277
278 $( 'ul.services-hidden li' ).each( function () {
279 if ( $( this ).hasClass( 'service' ) ) {
280 // Ready for saving
281 hidden[ hidden.length ] = $( this ).attr( 'id' );
282 showExtraOptions( $( this ).attr( 'id' ) );
283 }
284 } );
285
286 // Set the hidden element values
287 $( '#save-enabled-shares input[name=visible]' ).val( visible.join( ',' ) );
288 $( '#save-enabled-shares input[name=hidden]' ).val( hidden.join( ',' ) );
289
290 update_preview();
291
292 // Save it
293 $( '#save-enabled-shares' ).ajaxSubmit( function () {
294 $( '#enabled-services h3 img' ).hide();
295 } );
296 }
297
298 $( '#enabled-services .services ul' ).sortable( {
299 receive: function (/*event, ui*/) {
300 save_services();
301 },
302 stop: function () {
303 save_services();
304 $( 'li.service' ).enableSelection(); // Fixes a problem with Chrome
305 },
306 over: function (/*event, ui*/) {
307 $( this ).find( 'ul' ).addClass( 'dropping' );
308
309 // Ensure the 'end-fix' is at the end
310 $( '#enabled-services li.end-fix' ).remove();
311 $( '#enabled-services ul' ).append( '<li class="end-fix"></li>' );
312 },
313 out: function (/*event, ui*/) {
314 $( this ).find( 'ul' ).removeClass( 'dropping' );
315
316 // Ensure the 'end-fix' is at the end
317 $( '#enabled-services li.end-fix' ).remove();
318 $( '#enabled-services ul' ).append( '<li class="end-fix"></li>' );
319 },
320 helper: function ( event, ui ) {
321 ui.find( '.advanced-form' ).hide();
322
323 return ui.clone();
324 },
325 start: function (/*event, ui*/) {
326 // Make sure that the advanced section is closed
327 $( '.advanced-form' ).hide();
328 $( 'li.service' ).disableSelection(); // Fixes a problem with Chrome
329 },
330 placeholder: 'dropzone',
331 opacity: 0.8,
332 delay: 150,
333 forcePlaceholderSize: true,
334 items: 'li',
335 connectWith: '#available-services ul, #enabled-services .services ul',
336 cancel: '.advanced-form',
337 } );
338
339 $( '#available-services ul' ).sortable( {
340 opacity: 0.8,
341 delay: 150,
342 cursor: 'move',
343 connectWith: '#enabled-services .services ul',
344 placeholder: 'dropzone',
345 forcePlaceholderSize: true,
346 start: function () {
347 $( '.advanced-form' ).hide();
348 },
349 } );
350
351 // Accessibility keyboard shortcurts
352 $( '.service' ).on( 'keydown', function ( e ) {
353 // Reposition if one of the directional keys is pressed
354 switch ( e.keyCode ) {
355 case 13:
356 keyboardDragDrop( $( this ) );
357 break; // Enter
358 case 32:
359 keyboardDragDrop( $( this ) );
360 break; // Space
361 case 37:
362 keyboardChangeOrder( $( this ), 'left' );
363 break; // Left
364 case 39:
365 keyboardChangeOrder( $( this ), 'right' );
366 break; // Right
367 default:
368 return true; // Exit and bubble
369 }
370
371 e.preventDefault();
372 } );
373
374 function keyboardChangeOrder( $this, dir ) {
375 var thisParent = $this.parent(),
376 thisParentsChildren = thisParent.find( 'li' ),
377 thisPosition = thisParentsChildren.index( $this ) + 1,
378 totalChildren = thisParentsChildren.length - 1,
379 thisService;
380
381 // No need to be able to sort order for the "Available Services" section
382 if ( thisParent.hasClass( 'services-available' ) ) {
383 return;
384 }
385
386 if ( 'left' === dir ) {
387 if ( 1 === thisPosition ) {
388 return;
389 }
390
391 // Find service to left
392 var prevSibling = $this.prev();
393
394 // Detach this service from DOM
395 thisService = $this.detach();
396
397 // Move it to the appropriate area and add focus back to service
398 prevSibling.before( thisService );
399
400 // Add focus
401 prevSibling.prev().focus();
402 }
403
404 if ( 'right' === dir ) {
405 if ( thisPosition === totalChildren ) {
406 return;
407 }
408
409 // Find service to left
410 var nextSibling = $this.next();
411
412 // Detach this service from DOM
413 thisService = $this.detach();
414
415 // Move it to the appropriate area and add focus back to service
416 nextSibling.after( thisService );
417
418 // Add focus
419 nextSibling.next().focus();
420 }
421
422 //Save changes
423 save_services();
424 }
425
426 function keyboardDragDrop( $this ) {
427 var dropzone,
428 thisParent = $this.parent();
429
430 // Rotate through 3 available dropzones
431 if ( thisParent.hasClass( 'services-available' ) ) {
432 dropzone = 'services-enabled';
433 } else if ( thisParent.hasClass( 'services-enabled' ) ) {
434 dropzone = 'services-hidden';
435 } else {
436 dropzone = 'services-available';
437 }
438
439 // Detach this service from DOM
440 var thisService = $this.detach();
441
442 // Move it to the appropriate area and add focus back to service
443 $( '.' + dropzone )
444 .prepend( thisService )
445 .find( 'li:first-child' )
446 .focus();
447
448 //Save changes
449 save_services();
450 }
451
452 // Live preview 'hidden' button
453 $( '.preview-hidden a' ).click( function () {
454 $( this ).parent().find( '.preview' ).toggle();
455 return false;
456 } );
457
458 // Add service
459 $( '#new-service form' ).ajaxForm( {
460 beforeSubmit: function () {
461 $( '#new-service-form .error' ).hide();
462 $( '#new-service-form img' ).show();
463 $( '#new-service-form input[type=submit]' ).prop( 'disabled', true );
464 },
465 success: function ( response ) {
466 $( '#new-service-form img' ).hide();
467
468 if ( '' + response === '1' ) {
469 $( '#new-service-form .inerror' ).removeClass( 'inerror' ).addClass( 'error' );
470 $( '#new-service-form .error' ).show();
471 $( '#new-service-form input[type=submit]' ).prop( 'disabled', false );
472 } else {
473 document.location.reload();
474 }
475 },
476 } );
477
478 function init_handlers() {
479 $( '#services-config a.remove' )
480 .unbind( 'click' )
481 .click( function () {
482 var form = $( this ).parent().next();
483
484 // Loading icon
485 $( this )
486 .parents( 'li:first' )
487 .css( 'backgroundImage', 'url("' + sharing_loading_icon + '")' );
488
489 // Save
490 form.ajaxSubmit( function (/*response*/) {
491 // Remove the item
492 form.parents( 'li:first' ).fadeOut( function () {
493 $( this ).remove();
494
495 // Update preview
496 update_preview();
497 } );
498 } );
499
500 return false;
501 } );
502 }
503
504 $( '#button_style' )
505 .change( function () {
506 update_preview();
507 return true;
508 } )
509 .change();
510
511 $( 'input[name=sharing_label]' ).blur( function () {
512 $( '#live-preview h3.sd-title' ).text( $( '<div/>' ).text( $( this ).val() ).html() );
513 } );
514
515 init_handlers();
516 enable_share_button();
517 } );
518 } )( jQuery );
519