Keine Beschreibung

gallery-settings.js 1.0KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /**
  2. * Jetpack Gallery Settings
  3. */
  4. ( function ( $ ) {
  5. var media = wp.media;
  6. // Wrap the render() function to append controls.
  7. media.view.Settings.Gallery = media.view.Settings.Gallery.extend( {
  8. render: function () {
  9. var $el = this.$el;
  10. media.view.Settings.prototype.render.apply( this, arguments );
  11. // Append the type template and update the settings.
  12. $el.append( media.template( 'jetpack-gallery-settings' ) );
  13. media.gallery.defaults.type = 'default'; // lil hack that lets media know there's a type attribute.
  14. this.update.apply( this, [ 'type' ] );
  15. // Hide the Columns setting for all types except Default
  16. $el
  17. .find( 'select[name=type]' )
  18. .on( 'change', function () {
  19. var columnSetting = $el.find( 'select[name=columns]' ).closest( 'label.setting' );
  20. if ( 'default' === $( this ).val() || 'thumbnails' === $( this ).val() ) {
  21. columnSetting.show();
  22. } else {
  23. columnSetting.hide();
  24. }
  25. } )
  26. .change();
  27. return this;
  28. },
  29. } );
  30. } )( jQuery );