- md5
- 5d75d16a3e0692ab582c5e117819c4d2
- sha1
- db813a0ac9ccbcff2d41f93f9072b76e90c5ee7b
- sha256
- bf7e6846e13d9092f56e1be7aa92e061217108127d0f320171ee2d89031e12fb
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
/**
* wp.media.view.Menu
*
* @class
* @augments wp.media.view.PriorityList
* @augments wp.media.View
* @augments wp.Backbone.View
* @augments Backbone.View
*/
var MenuItem = require( './menu-item.js' ),
PriorityList = require( './priority-list.js' ),
Menu;
Menu = PriorityList.extend({
tagName: 'div',
className: 'media-menu',
property: 'state',
ItemView: MenuItem,
region: 'menu',
/* TODO: alternatively hide on any click anywhere
events: {
'click': 'click'
},
click: function() {
this.$el.removeClass( 'visible' );
},
*/
/**
* @param {Object} options
* @param {string} id
* @returns {wp.media.View}
*/
toView: function( options, id ) {
options = options || {};
options[ this.property ] = options[ this.property ] || id;
return new this.ItemView( options ).render();
},
ready: function() {
/**
* call 'ready' directly on the parent class
*/
PriorityList.prototype.ready.apply( this, arguments );
this.visibility();
},
set: function() {
/**
* call 'set' directly on the parent class
*/
PriorityList.prototype.set.apply( this, arguments );
this.visibility();
},
unset: function() {
/**
* call 'unset' directly on the parent class
*/
PriorityList.prototype.unset.apply( this, arguments );
this.visibility();
},
visibility: function() {
var region = this.region,
view = this.controller[ region ].get(),
views = this.views.get(),
hide = ! views || views.length < 2;
if ( this === view ) {
this.controller.$el.toggleClass( 'hide-' + region, hide );
}
},
/**
* @param {string} id
*/
select: function( id ) {
var view = this.get( id );
if ( ! view ) {
return;
}
this.deselect();
view.$el.addClass('active');
},
deselect: function() {
this.$el.children().removeClass('active');
},
hide: function( id ) {
var view = this.get( id );
if ( ! view ) {
return;
}
view.$el.addClass('hidden');
},
show: function( id ) {
var view = this.get( id );
if ( ! view ) {
return;
}
view.$el.removeClass('hidden');
}
});
module.exports = Menu;
The same content is in 3 releases, WordPress 4.2-beta1 to 4.2-beta3. See them all, or every version of this file.