PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.2
Jetpack – WP Security, Backup, Speed, & Growth v16.2
16.2 16.2-beta 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 All 502 releases
jetpack / modules / widgets / twitter-timeline-admin.js

twitter-timeline-admin.js in Jetpack – WP Security, Backup, Speed, & Growth 16.2, at modules/widgets/twitter-timeline-admin.js

66 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 jQuery( function ( $ ) {
2 function twitterWidgetTypeChanged( widgetTypeSelector ) {
3 var selectedType = $( widgetTypeSelector ).val();
4 $( widgetTypeSelector )
5 .closest( '.jetpack-twitter-timeline-widget-type-container' )
6 .next( '.jetpack-twitter-timeline-widget-id-container' )
7 .find( 'label' )
8 .css( 'display', function () {
9 var labelType = $( this ).data( 'widget-type' );
10 if ( selectedType === labelType ) {
11 return '';
12 }
13 return 'none';
14 } );
15 }
16
17 function twitterWidgetTweetDisplayChanged( event ) {
18 var $tweetDisplaySelector = $( event.target );
19 var selectedTweetDisplay = $tweetDisplaySelector.val();
20 var $form = $tweetDisplaySelector.closest( 'form' );
21 var $heightContainer = $form.find( '.jetpack-twitter-timeline-widget-height-container' );
22 var $tweetLimitContainer = $form.find(
23 '.jetpack-twitter-timeline-widget-tweet-limit-container'
24 );
25 var $scrollbarInput = $form.find( 'input[id*=chrome-noscrollbar]' );
26 switch ( selectedTweetDisplay ) {
27 case 'fixed':
28 $heightContainer.hide();
29 $tweetLimitContainer.show();
30 $scrollbarInput.prop( 'disabled', true );
31 break;
32 case 'dynamic':
33 $tweetLimitContainer.hide();
34 $heightContainer.show();
35 $scrollbarInput.prop( 'disabled', false );
36 break;
37 }
38 }
39
40 // We could either be in wp-admin/widgets.php or the Customizer.
41 var $container = $( '#customize-controls' );
42 if ( ! $container.length ) {
43 $container = $( '#wpbody' );
44 }
45
46 // Observe widget settings for 'change' events of the 'type' property for
47 // current and future Twitter timeline widgets.
48 $container.on( 'change', '.jetpack-twitter-timeline-widget-type', function () {
49 twitterWidgetTypeChanged( this );
50 } );
51
52 // Set the labels for currently existing widgets (including the "template"
53 // version that is copied when a new widget is added).
54 $container.find( '.jetpack-twitter-timeline-widget-type' ).each( function () {
55 twitterWidgetTypeChanged( this );
56 } );
57
58 // Observe widget settings for 'change' events of the 'tweet-display' property for
59 // current and future Twitter timeline widgets.
60 $container.on(
61 'change',
62 '.jetpack-twitter-timeline-widget-tweet-display-radio',
63 twitterWidgetTweetDisplayChanged
64 );
65 } );
66