Nav apraksta

twitter-timeline-admin.js 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. } else {
  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. // We could either be in wp-admin/widgets.php or the Customizer.
  40. var $container = $( '#customize-controls' );
  41. if ( ! $container.length ) {
  42. $container = $( '#wpbody' );
  43. }
  44. // Observe widget settings for 'change' events of the 'type' property for
  45. // current and future Twitter timeline widgets.
  46. $container.on( 'change', '.jetpack-twitter-timeline-widget-type', function () {
  47. twitterWidgetTypeChanged( this );
  48. } );
  49. // Set the labels for currently existing widgets (including the "template"
  50. // version that is copied when a new widget is added).
  51. $container.find( '.jetpack-twitter-timeline-widget-type' ).each( function () {
  52. twitterWidgetTypeChanged( this );
  53. } );
  54. // Observe widget settings for 'change' events of the 'tweet-display' property for
  55. // current and future Twitter timeline widgets.
  56. $container.on(
  57. 'change',
  58. '.jetpack-twitter-timeline-widget-tweet-display-radio',
  59. twitterWidgetTweetDisplayChanged
  60. );
  61. } );