mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-04 07:28:22 +01:00
d568679946
* Add a new folder in `wp-includes/js`, `media` * Create manifest files for `views`, `models`, `grid`, and `audio-video` * Make `browserify` an `npm` dependency * Add Grunt tasks for `browserify` and `uglify:media` on `build` and `watch` * Update the paths loaded for media files in `script-loader` * All new files were created using `svn cp` from their original location Please run `npm install`. While developing media JS, you must run `grunt watch`. See #28510. Built from https://develop.svn.wordpress.org/trunk@31373 git-svn-id: http://core.svn.wordpress.org/trunk@31354 1a063a9b-81f0-0310-95a4-ce76da25c4cd
55 lines
1.7 KiB
JavaScript
55 lines
1.7 KiB
JavaScript
/*globals wp */
|
|
|
|
var Button = require( '../button.js' ),
|
|
l10n = wp.media.view.l10n,
|
|
SelectModeToggle;
|
|
|
|
SelectModeToggle = Button.extend({
|
|
initialize: function() {
|
|
Button.prototype.initialize.apply( this, arguments );
|
|
this.listenTo( this.controller, 'select:activate select:deactivate', this.toggleBulkEditHandler );
|
|
this.listenTo( this.controller, 'selection:action:done', this.back );
|
|
},
|
|
|
|
back: function () {
|
|
this.controller.deactivateMode( 'select' ).activateMode( 'edit' );
|
|
},
|
|
|
|
click: function() {
|
|
Button.prototype.click.apply( this, arguments );
|
|
if ( this.controller.isModeActive( 'select' ) ) {
|
|
this.back();
|
|
} else {
|
|
this.controller.deactivateMode( 'edit' ).activateMode( 'select' );
|
|
}
|
|
},
|
|
|
|
render: function() {
|
|
Button.prototype.render.apply( this, arguments );
|
|
this.$el.addClass( 'select-mode-toggle-button' );
|
|
return this;
|
|
},
|
|
|
|
toggleBulkEditHandler: function() {
|
|
var toolbar = this.controller.content.get().toolbar, children;
|
|
|
|
children = toolbar.$( '.media-toolbar-secondary > *, .media-toolbar-primary > *' );
|
|
|
|
// TODO: the Frame should be doing all of this.
|
|
if ( this.controller.isModeActive( 'select' ) ) {
|
|
this.model.set( 'text', l10n.cancelSelection );
|
|
children.not( '.media-button' ).hide();
|
|
this.$el.show();
|
|
toolbar.$( '.delete-selected-button' ).removeClass( 'hidden' );
|
|
} else {
|
|
this.model.set( 'text', l10n.bulkSelect );
|
|
this.controller.content.get().$el.removeClass( 'fixed' );
|
|
toolbar.$el.css( 'width', '' );
|
|
toolbar.$( '.delete-selected-button' ).addClass( 'hidden' );
|
|
children.not( '.spinner, .media-button' ).show();
|
|
this.controller.state().get( 'selection' ).reset();
|
|
}
|
|
}
|
|
});
|
|
|
|
module.exports = SelectModeToggle; |