PluginProbe ʕ •ᴥ•ʔ
Jetpack – WP Security, Backup, Speed, & Growth / 13.2.4
Jetpack – WP Security, Backup, Speed, & Growth v13.2.4
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 2 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 2 years ago recaptcha.php 4 years ago sharedaddy.php 2 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
518 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( 'share-custom' ) &&
175 ! $( this ).hasClass( 'share-deprecated' )
176 ) {
177 $( this )
178 .find( '.option a span' )
179 .html( '' )
180 .parent()
181 .removeClass( 'sd-button' )
182 .parent()
183 .attr( 'class', 'option option-smart-on' );
184 }
185 }
186 );
187 } else if ( 'text' === button_style ) {
188 $( '#live-preview li.advanced' ).addClass( 'no-icon' );
189 }
190 }
191
192 window.sharing_option_changed = function () {
193 var item = this;
194
195 // Loading icon
196 $( this )
197 .parents( 'li:first' )
198 .css( 'backgroundImage', 'url("' + sharing_loading_icon + '")' );
199
200 // Save
201 $( this )
202 .parents( 'form' )
203 .ajaxSubmit( function ( response ) {
204 if ( response.indexOf( '<!---' ) >= 0 ) {
205 var button = response.substring( 0, response.indexOf( '<!--->' ) );
206 var preview = response.substring( response.indexOf( '<!--->' ) + 6 );
207
208 if ( $( item ).is( ':submit' ) === true ) {
209 // Update the DOM using a bit of cut/paste technology
210
211 $( item ).parents( 'li:first' ).replaceWith( button );
212 }
213
214 $(
215 '#live-preview ul.archive li.preview-' +
216 $( item ).parents( 'form' ).find( 'input[name=service]' ).val()
217 ).replaceWith( preview );
218 }
219
220 // Update preview
221 update_preview();
222
223 // Restore the icon
224 $( item ).parents( 'li:first' ).removeAttr( 'style' );
225 } );
226
227 if ( $( item ).is( ':submit' ) === true ) {
228 return false;
229 }
230 return true;
231 };
232
233 function showExtraOptions( service ) {
234 jQuery( '.' + service + '-extra-options' )
235 .css( { backgroundColor: '#ffffcc' } )
236 .fadeIn();
237 }
238
239 function hideExtraOptions( service ) {
240 jQuery( '.' + service + '-extra-options' ).fadeOut( 'slow' );
241 }
242
243 function save_services() {
244 $( '#enabled-services h3 img' ).show();
245
246 // Toggle various dividers/help texts
247 if ( $( '#enabled-services ul.services-enabled li.service' ).length > 0 ) {
248 $( '#drag-instructions' ).hide();
249 } else {
250 $( '#drag-instructions' ).show();
251 }
252
253 if ( $( '#enabled-services li.service' ).length > 0 ) {
254 $( '#live-preview .services h2' ).hide();
255 } else {
256 $( '#live-preview .services h2' ).show();
257 }
258
259 // Gather the modules
260 var visible = [],
261 hidden = [];
262
263 $( 'ul.services-enabled li' ).each( function () {
264 if ( $( this ).hasClass( 'service' ) ) {
265 // Ready for saving
266 visible[ visible.length ] = $( this ).attr( 'id' );
267 showExtraOptions( $( this ).attr( 'id' ) );
268 }
269 } );
270
271 $( 'ul.services-available li' ).each( function () {
272 if ( $( this ).hasClass( 'service' ) ) {
273 hideExtraOptions( $( this ).attr( 'id' ) );
274 }
275 } );
276
277 $( 'ul.services-hidden li' ).each( function () {
278 if ( $( this ).hasClass( 'service' ) ) {
279 // Ready for saving
280 hidden[ hidden.length ] = $( this ).attr( 'id' );
281 showExtraOptions( $( this ).attr( 'id' ) );
282 }
283 } );
284
285 // Set the hidden element values
286 $( '#save-enabled-shares input[name=visible]' ).val( visible.join( ',' ) );
287 $( '#save-enabled-shares input[name=hidden]' ).val( hidden.join( ',' ) );
288
289 update_preview();
290
291 // Save it
292 $( '#save-enabled-shares' ).ajaxSubmit( function () {
293 $( '#enabled-services h3 img' ).hide();
294 } );
295 }
296
297 $( '#enabled-services .services ul' ).sortable( {
298 receive: function ( /*event, ui*/ ) {
299 save_services();
300 },
301 stop: function () {
302 save_services();
303 $( 'li.service' ).enableSelection(); // Fixes a problem with Chrome
304 },
305 over: function ( /*event, ui*/ ) {
306 $( this ).find( 'ul' ).addClass( 'dropping' );
307
308 // Ensure the 'end-fix' is at the end
309 $( '#enabled-services li.end-fix' ).remove();
310 $( '#enabled-services ul' ).append( '<li class="end-fix"></li>' );
311 },
312 out: function ( /*event, ui*/ ) {
313 $( this ).find( 'ul' ).removeClass( 'dropping' );
314
315 // Ensure the 'end-fix' is at the end
316 $( '#enabled-services li.end-fix' ).remove();
317 $( '#enabled-services ul' ).append( '<li class="end-fix"></li>' );
318 },
319 helper: function ( event, ui ) {
320 ui.find( '.advanced-form' ).hide();
321
322 return ui.clone();
323 },
324 start: function ( /*event, ui*/ ) {
325 // Make sure that the advanced section is closed
326 $( '.advanced-form' ).hide();
327 $( 'li.service' ).disableSelection(); // Fixes a problem with Chrome
328 },
329 placeholder: 'dropzone',
330 opacity: 0.8,
331 delay: 150,
332 forcePlaceholderSize: true,
333 items: 'li',
334 connectWith: '#available-services ul, #enabled-services .services ul',
335 cancel: '.advanced-form',
336 } );
337
338 $( '#available-services ul' ).sortable( {
339 opacity: 0.8,
340 delay: 150,
341 cursor: 'move',
342 connectWith: '#enabled-services .services ul',
343 placeholder: 'dropzone',
344 forcePlaceholderSize: true,
345 start: function () {
346 $( '.advanced-form' ).hide();
347 },
348 } );
349
350 // Accessibility keyboard shortcurts
351 $( '.service' ).on( 'keydown', function ( e ) {
352 // Reposition if one of the directional keys is pressed
353 switch ( e.keyCode ) {
354 case 13:
355 keyboardDragDrop( $( this ) );
356 break; // Enter
357 case 32:
358 keyboardDragDrop( $( this ) );
359 break; // Space
360 case 37:
361 keyboardChangeOrder( $( this ), 'left' );
362 break; // Left
363 case 39:
364 keyboardChangeOrder( $( this ), 'right' );
365 break; // Right
366 default:
367 return true; // Exit and bubble
368 }
369
370 e.preventDefault();
371 } );
372
373 function keyboardChangeOrder( $this, dir ) {
374 var thisParent = $this.parent(),
375 thisParentsChildren = thisParent.find( 'li' ),
376 thisPosition = thisParentsChildren.index( $this ) + 1,
377 totalChildren = thisParentsChildren.length - 1,
378 thisService;
379
380 // No need to be able to sort order for the "Available Services" section
381 if ( thisParent.hasClass( 'services-available' ) ) {
382 return;
383 }
384
385 if ( 'left' === dir ) {
386 if ( 1 === thisPosition ) {
387 return;
388 }
389
390 // Find service to left
391 var prevSibling = $this.prev();
392
393 // Detach this service from DOM
394 thisService = $this.detach();
395
396 // Move it to the appropriate area and add focus back to service
397 prevSibling.before( thisService );
398
399 // Add focus
400 prevSibling.prev().focus();
401 }
402
403 if ( 'right' === dir ) {
404 if ( thisPosition === totalChildren ) {
405 return;
406 }
407
408 // Find service to left
409 var nextSibling = $this.next();
410
411 // Detach this service from DOM
412 thisService = $this.detach();
413
414 // Move it to the appropriate area and add focus back to service
415 nextSibling.after( thisService );
416
417 // Add focus
418 nextSibling.next().focus();
419 }
420
421 //Save changes
422 save_services();
423 }
424
425 function keyboardDragDrop( $this ) {
426 var dropzone,
427 thisParent = $this.parent();
428
429 // Rotate through 3 available dropzones
430 if ( thisParent.hasClass( 'services-available' ) ) {
431 dropzone = 'services-enabled';
432 } else if ( thisParent.hasClass( 'services-enabled' ) ) {
433 dropzone = 'services-hidden';
434 } else {
435 dropzone = 'services-available';
436 }
437
438 // Detach this service from DOM
439 var thisService = $this.detach();
440
441 // Move it to the appropriate area and add focus back to service
442 $( '.' + dropzone )
443 .prepend( thisService )
444 .find( 'li:first-child' )
445 .focus();
446
447 //Save changes
448 save_services();
449 }
450
451 // Live preview 'hidden' button
452 $( '.preview-hidden a' ).click( function () {
453 $( this ).parent().find( '.preview' ).toggle();
454 return false;
455 } );
456
457 // Add service
458 $( '#new-service form' ).ajaxForm( {
459 beforeSubmit: function () {
460 $( '#new-service-form .error' ).hide();
461 $( '#new-service-form img' ).show();
462 $( '#new-service-form input[type=submit]' ).prop( 'disabled', true );
463 },
464 success: function ( response ) {
465 $( '#new-service-form img' ).hide();
466
467 if ( '' + response === '1' ) {
468 $( '#new-service-form .inerror' ).removeClass( 'inerror' ).addClass( 'error' );
469 $( '#new-service-form .error' ).show();
470 $( '#new-service-form input[type=submit]' ).prop( 'disabled', false );
471 } else {
472 document.location.reload();
473 }
474 },
475 } );
476
477 function init_handlers() {
478 $( '#services-config a.remove' )
479 .unbind( 'click' )
480 .click( function () {
481 var form = $( this ).parent().next();
482
483 // Loading icon
484 $( this )
485 .parents( 'li:first' )
486 .css( 'backgroundImage', 'url("' + sharing_loading_icon + '")' );
487
488 // Save
489 form.ajaxSubmit( function ( /*response*/ ) {
490 // Remove the item
491 form.parents( 'li:first' ).fadeOut( function () {
492 $( this ).remove();
493
494 // Update preview
495 update_preview();
496 } );
497 } );
498
499 return false;
500 } );
501 }
502
503 $( '#button_style' )
504 .change( function () {
505 update_preview();
506 return true;
507 } )
508 .change();
509
510 $( 'input[name=sharing_label]' ).blur( function () {
511 $( '#live-preview h3.sd-title' ).text( $( '<div/>' ).text( $( this ).val() ).html() );
512 } );
513
514 init_handlers();
515 enable_share_button();
516 } );
517 } )( jQuery );
518