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