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