gallery-settings.js 989 B

123456789101112131415161718192021222324252627282930313233
  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.find( 'select[name=type]' ).on( 'change', function () {
  17. var columnSetting = $el.find( 'select[name=columns]' ).closest( 'label.setting' );
  18. if ( 'default' === $( this ).val() || 'thumbnails' === $( this ).val() ) {
  19. columnSetting.show();
  20. } else {
  21. columnSetting.hide();
  22. }
  23. } ).change();
  24. return this;
  25. }
  26. });
  27. })(jQuery);