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.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 7 years ago admin-sharing-rtl.css 7 years ago admin-sharing-rtl.min.css 7 years ago admin-sharing.css 7 years ago admin-sharing.js 6 years ago admin-sharing.min.css 7 years ago recaptcha.php 7 years ago sharedaddy.php 6 years ago sharing-service.php 6 years ago sharing-sources.php 6 years ago sharing.css 6 years ago sharing.js 6 years ago sharing.php 6 years ago
admin-sharing.js
532 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 )
30 .mouseleave( handler_item_leave )
31 .mouseenter( handler_item_enter );
32 $( original )
33 .mouseleave( handler_original_leave )
34 .mouseenter( handler_original_enter );
35
36 // Add a special handler to quickly close the item
37 $( original ).click( close_it );
38 } );
39
40 // 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
41 var handler_item_leave = function() {
42 $( original ).data( 'hasitem', false );
43
44 if ( $( original ).data( 'hasoriginal' ) === false ) {
45 var timer = setTimeout( close_it, 800 );
46 $( original ).data( 'timer2', timer );
47 }
48 };
49
50 var handler_item_enter = function() {
51 $( original ).data( 'hasitem', true );
52 clearTimeout( $( original ).data( 'timer2' ) );
53 };
54
55 var handler_original_leave = function() {
56 $( original ).data( 'hasoriginal', false );
57
58 if ( $( original ).data( 'hasitem' ) === false ) {
59 var timer = setTimeout( close_it, 800 );
60 $( original ).data( 'timer2', timer );
61 }
62 };
63
64 var handler_original_enter = function() {
65 $( original ).data( 'hasoriginal', true );
66 clearTimeout( $( original ).data( 'timer2' ) );
67 };
68
69 var close_it = function() {
70 item.slideUp( 200 );
71
72 // Clear all hooks
73 $( original )
74 .unbind( 'mouseleave', handler_original_leave )
75 .unbind( 'mouseenter', handler_original_enter );
76 $( item )
77 .unbind( 'mouseleave', handler_item_leave )
78 .unbind( 'mouseenter', handler_item_leave );
79 $( original ).data( 'hasappeared', false );
80 $( original ).unbind( 'click', close_it );
81 return false;
82 };
83 }, 200 );
84
85 // Remember the timer so we can detect it on the mouseout
86 $( this ).data( 'timer', timer );
87 }
88 },
89 function() {
90 // Mouse out - remove any timer
91 clearTimeout( $( this ).data( 'timer' ) );
92 $( this ).data( 'timer', false );
93 }
94 );
95 }
96
97 function update_preview() {
98 var button_style = $( '#button_style' ).val();
99
100 // Clear the live preview
101 $( '#live-preview ul.preview li' ).remove();
102
103 // Add label
104 if (
105 $( '#save-enabled-shares input[name=visible]' ).val() ||
106 $( '#save-enabled-shares input[name=hidden]' ).val()
107 ) {
108 $( '#live-preview ul.preview' ).append(
109 $( '#live-preview ul.archive .sharing-label' ).clone()
110 );
111 }
112
113 // Re-insert all the enabled items
114 $( 'ul.services-enabled li' ).each( function() {
115 if ( $( this ).hasClass( 'service' ) ) {
116 var service = $( this ).attr( 'id' );
117 $( '#live-preview ul.preview' ).append(
118 $( '#live-preview ul.archive li.preview-' + service ).clone()
119 );
120 }
121 } );
122
123 // Add any hidden items
124 if ( $( '#save-enabled-shares input[name=hidden]' ).val() ) {
125 // Add share button
126 $( '#live-preview ul.preview' ).append(
127 $( '#live-preview ul.archive .share-more' )
128 .parent()
129 .clone()
130 );
131
132 $( '.sharing-hidden ul li' ).remove();
133
134 // Add hidden items into the inner panel
135 $( 'ul.services-hidden li' ).each( function(/*pos, item*/) {
136 if ( $( this ).hasClass( 'service' ) ) {
137 var service = $( this ).attr( 'id' );
138 $( '.sharing-hidden .inner ul' ).append(
139 $( '#live-preview ul.archive .preview-' + service ).clone()
140 );
141 }
142 } );
143
144 enable_share_button();
145 }
146
147 $( '#live-preview div.sharedaddy' ).removeClass( 'sd-social-icon' );
148 $( '#live-preview li.advanced' ).removeClass( 'no-icon' );
149
150 // Button style
151 if ( 'icon' === button_style ) {
152 $( '#live-preview ul.preview div span, .sharing-hidden .inner ul div span' )
153 .html( ' ' )
154 .parent()
155 .addClass( 'no-text' );
156 $( '#live-preview div.sharedaddy' ).addClass( 'sd-social-icon' );
157 } else if ( 'official' === button_style ) {
158 $( '#live-preview ul.preview .advanced, .sharing-hidden .inner ul .advanced' ).each(
159 function(/*i*/) {
160 if (
161 ! $( this ).hasClass( 'preview-press-this' ) &&
162 ! $( this ).hasClass( 'preview-email' ) &&
163 ! $( this ).hasClass( 'preview-print' ) &&
164 ! $( this ).hasClass( 'preview-telegram' ) &&
165 ! $( this ).hasClass( 'preview-jetpack-whatsapp' ) &&
166 ! $( this ).hasClass( 'share-custom' ) &&
167 ! $( this ).hasClass( 'share-deprecated' )
168 ) {
169 $( this )
170 .find( '.option a span' )
171 .html( '' )
172 .parent()
173 .removeClass( 'sd-button' )
174 .parent()
175 .attr( 'class', 'option option-smart-on' );
176 }
177 }
178 );
179 } else if ( 'text' === button_style ) {
180 $( '#live-preview li.advanced' ).addClass( 'no-icon' );
181 }
182 }
183
184 window.sharing_option_changed = function() {
185 var item = this;
186
187 // Loading icon
188 $( this )
189 .parents( 'li:first' )
190 .css( 'backgroundImage', 'url("' + sharing_loading_icon + '")' );
191
192 // Save
193 $( this )
194 .parents( 'form' )
195 .ajaxSubmit( function( response ) {
196 if ( response.indexOf( '<!---' ) >= 0 ) {
197 var button = response.substring( 0, response.indexOf( '<!--->' ) );
198 var preview = response.substring( response.indexOf( '<!--->' ) + 6 );
199
200 if ( $( item ).is( ':submit' ) === true ) {
201 // Update the DOM using a bit of cut/paste technology
202
203 $( item )
204 .parents( 'li:first' )
205 .replaceWith( button );
206 }
207
208 $(
209 '#live-preview ul.archive li.preview-' +
210 $( item )
211 .parents( 'form' )
212 .find( 'input[name=service]' )
213 .val()
214 ).replaceWith( preview );
215 }
216
217 // Update preview
218 update_preview();
219
220 // Restore the icon
221 $( item )
222 .parents( 'li:first' )
223 .removeAttr( 'style' );
224 } );
225
226 if ( $( item ).is( ':submit' ) === true ) {
227 return false;
228 }
229 return true;
230 };
231
232 function showExtraOptions( service ) {
233 jQuery( '.' + service + '-extra-options' )
234 .css( { backgroundColor: '#ffffcc' } )
235 .fadeIn();
236 }
237
238 function hideExtraOptions( service ) {
239 jQuery( '.' + service + '-extra-options' ).fadeOut( 'slow' );
240 }
241
242 function save_services() {
243 $( '#enabled-services h3 img' ).show();
244
245 // Toggle various dividers/help texts
246 if ( $( '#enabled-services ul.services-enabled li.service' ).length > 0 ) {
247 $( '#drag-instructions' ).hide();
248 } else {
249 $( '#drag-instructions' ).show();
250 }
251
252 if ( $( '#enabled-services li.service' ).length > 0 ) {
253 $( '#live-preview .services h2' ).hide();
254 } else {
255 $( '#live-preview .services h2' ).show();
256 }
257
258 // Gather the modules
259 var visible = [],
260 hidden = [];
261
262 $( 'ul.services-enabled li' ).each( function() {
263 if ( $( this ).hasClass( 'service' ) ) {
264 // Ready for saving
265 visible[ visible.length ] = $( this ).attr( 'id' );
266 showExtraOptions( $( this ).attr( 'id' ) );
267 }
268 } );
269
270 $( 'ul.services-available li' ).each( function() {
271 if ( $( this ).hasClass( 'service' ) ) {
272 hideExtraOptions( $( this ).attr( 'id' ) );
273 }
274 } );
275
276 $( 'ul.services-hidden li' ).each( function() {
277 if ( $( this ).hasClass( 'service' ) ) {
278 // Ready for saving
279 hidden[ hidden.length ] = $( this ).attr( 'id' );
280 showExtraOptions( $( this ).attr( 'id' ) );
281 }
282 } );
283
284 // Set the hidden element values
285 $( '#save-enabled-shares input[name=visible]' ).val( visible.join( ',' ) );
286 $( '#save-enabled-shares input[name=hidden]' ).val( hidden.join( ',' ) );
287
288 update_preview();
289
290 // Save it
291 $( '#save-enabled-shares' ).ajaxSubmit( function() {
292 $( '#enabled-services h3 img' ).hide();
293 } );
294 }
295
296 $( '#enabled-services .services ul' ).sortable( {
297 receive: function(/*event, ui*/) {
298 save_services();
299 },
300 stop: function() {
301 save_services();
302 $( 'li.service' ).enableSelection(); // Fixes a problem with Chrome
303 },
304 over: function(/*event, ui*/) {
305 $( this )
306 .find( 'ul' )
307 .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 )
315 .find( 'ul' )
316 .removeClass( 'dropping' );
317
318 // Ensure the 'end-fix' is at the end
319 $( '#enabled-services li.end-fix' ).remove();
320 $( '#enabled-services ul' ).append( '<li class="end-fix"></li>' );
321 },
322 helper: function( event, ui ) {
323 ui.find( '.advanced-form' ).hide();
324
325 return ui.clone();
326 },
327 start: function(/*event, ui*/) {
328 // Make sure that the advanced section is closed
329 $( '.advanced-form' ).hide();
330 $( 'li.service' ).disableSelection(); // Fixes a problem with Chrome
331 },
332 placeholder: 'dropzone',
333 opacity: 0.8,
334 delay: 150,
335 forcePlaceholderSize: true,
336 items: 'li',
337 connectWith: '#available-services ul, #enabled-services .services ul',
338 cancel: '.advanced-form',
339 } );
340
341 $( '#available-services ul' ).sortable( {
342 opacity: 0.8,
343 delay: 150,
344 cursor: 'move',
345 connectWith: '#enabled-services .services ul',
346 placeholder: 'dropzone',
347 forcePlaceholderSize: true,
348 start: function() {
349 $( '.advanced-form' ).hide();
350 },
351 } );
352
353 // Accessibility keyboard shortcurts
354 $( '.service' ).on( 'keydown', function( e ) {
355 // Reposition if one of the directional keys is pressed
356 switch ( e.keyCode ) {
357 case 13:
358 keyboardDragDrop( $( this ) );
359 break; // Enter
360 case 32:
361 keyboardDragDrop( $( this ) );
362 break; // Space
363 case 37:
364 keyboardChangeOrder( $( this ), 'left' );
365 break; // Left
366 case 39:
367 keyboardChangeOrder( $( this ), 'right' );
368 break; // Right
369 default:
370 return true; // Exit and bubble
371 }
372
373 e.preventDefault();
374 } );
375
376 function keyboardChangeOrder( $this, dir ) {
377 var thisParent = $this.parent(),
378 thisParentsChildren = thisParent.find( 'li' ),
379 thisPosition = thisParentsChildren.index( $this ) + 1,
380 totalChildren = thisParentsChildren.length - 1,
381 thisService;
382
383 // No need to be able to sort order for the "Available Services" section
384 if ( thisParent.hasClass( 'services-available' ) ) {
385 return;
386 }
387
388 if ( 'left' === dir ) {
389 if ( 1 === thisPosition ) {
390 return;
391 }
392
393 // Find service to left
394 var prevSibling = $this.prev();
395
396 // Detach this service from DOM
397 thisService = $this.detach();
398
399 // Move it to the appropriate area and add focus back to service
400 prevSibling.before( thisService );
401
402 // Add focus
403 prevSibling.prev().focus();
404 }
405
406 if ( 'right' === dir ) {
407 if ( thisPosition === totalChildren ) {
408 return;
409 }
410
411 // Find service to left
412 var nextSibling = $this.next();
413
414 // Detach this service from DOM
415 thisService = $this.detach();
416
417 // Move it to the appropriate area and add focus back to service
418 nextSibling.after( thisService );
419
420 // Add focus
421 nextSibling.next().focus();
422 }
423
424 //Save changes
425 save_services();
426 }
427
428 function keyboardDragDrop( $this ) {
429 var dropzone,
430 thisParent = $this.parent();
431
432 // Rotate through 3 available dropzones
433 if ( thisParent.hasClass( 'services-available' ) ) {
434 dropzone = 'services-enabled';
435 } else if ( thisParent.hasClass( 'services-enabled' ) ) {
436 dropzone = 'services-hidden';
437 } else {
438 dropzone = 'services-available';
439 }
440
441 // Detach this service from DOM
442 var thisService = $this.detach();
443
444 // Move it to the appropriate area and add focus back to service
445 $( '.' + dropzone )
446 .prepend( thisService )
447 .find( 'li:first-child' )
448 .focus();
449
450 //Save changes
451 save_services();
452 }
453
454 // Live preview 'hidden' button
455 $( '.preview-hidden a' ).click( function() {
456 $( this )
457 .parent()
458 .find( '.preview' )
459 .toggle();
460 return false;
461 } );
462
463 // Add service
464 $( '#new-service form' ).ajaxForm( {
465 beforeSubmit: function() {
466 $( '#new-service-form .error' ).hide();
467 $( '#new-service-form img' ).show();
468 $( '#new-service-form input[type=submit]' ).prop( 'disabled', true );
469 },
470 success: function( response ) {
471 $( '#new-service-form img' ).hide();
472
473 if ( '' + response === '1' ) {
474 $( '#new-service-form .inerror' )
475 .removeClass( 'inerror' )
476 .addClass( 'error' );
477 $( '#new-service-form .error' ).show();
478 $( '#new-service-form input[type=submit]' ).prop( 'disabled', false );
479 } else {
480 document.location.reload();
481 }
482 },
483 } );
484
485 function init_handlers() {
486 $( '#services-config a.remove' )
487 .unbind( 'click' )
488 .click( function() {
489 var form = $( this )
490 .parent()
491 .next();
492
493 // Loading icon
494 $( this )
495 .parents( 'li:first' )
496 .css( 'backgroundImage', 'url("' + sharing_loading_icon + '")' );
497
498 // Save
499 form.ajaxSubmit( function(/*response*/) {
500 // Remove the item
501 form.parents( 'li:first' ).fadeOut( function() {
502 $( this ).remove();
503
504 // Update preview
505 update_preview();
506 } );
507 } );
508
509 return false;
510 } );
511 }
512
513 $( '#button_style' )
514 .change( function() {
515 update_preview();
516 return true;
517 } )
518 .change();
519
520 $( 'input[name=sharing_label]' ).blur( function() {
521 $( '#live-preview h3.sd-title' ).text(
522 $( '<div/>' )
523 .text( $( this ).val() )
524 .html()
525 );
526 } );
527
528 init_handlers();
529 enable_share_button();
530 } );
531 } )( jQuery );
532