Add quick insert buttons to attachment views in the library and remove buttons to attachment views in the gallery editor. see #21390, #21809.

git-svn-id: http://core.svn.wordpress.org/trunk@22053 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Daryl Koopersmith 2012-09-27 07:45:26 +00:00
parent 584f39e365
commit 3cf9d9d905
3 changed files with 70 additions and 4 deletions

View File

@ -295,6 +295,36 @@
box-shadow: inset 0 0 0 1px rgba( 0, 0, 0, 0.4 );
}
.attachment .insert {
display: none;
position: absolute;
left: 7px;
bottom: 7px;
}
.attachment:hover .insert {
display: block;
}
.attachment .close {
/*display: none;*/
position: absolute;
top: 0;
right: 0;
height: 26px;
width: 26px;
font-size: 20px;
line-height: 24px;
text-align: center;
text-decoration: none;
color: #464646;
background: #fff;
}
.attachment:hover .close {
display: block;
}
/* Square crop with overflow visible on hover. */
/*

View File

@ -378,6 +378,8 @@
'click': 'toggleSelection'
},
buttons: {},
initialize: function() {
this.controller = this.options.controller;
@ -385,6 +387,9 @@
this.model.on( 'change:percent', this.progress, this );
this.model.on( 'add', this.select, this );
this.model.on( 'remove', this.deselect, this );
// Prevent default navigation on all links.
this.$el.on( 'click', 'a', this.preventDefault );
},
render: function() {
@ -394,7 +399,8 @@
uploading: attachment.uploading,
orientation: attachment.orientation || 'landscape',
type: attachment.type,
subtype: attachment.subtype
subtype: attachment.subtype,
buttons: this.buttons
};
// Use the medium image size if possible. If the medium size
@ -445,6 +451,10 @@
return;
this.$el.removeClass('selected');
},
preventDefault: function( event ) {
event.preventDefault();
}
});
@ -452,14 +462,33 @@
* wp.media.view.Attachment.Library
*/
media.view.Attachment.Library = media.view.Attachment.extend({
className: 'attachment library'
className: 'attachment library',
buttons: {
insert: true
},
events: _.defaults({
'click .insert': 'insert'
}, media.view.Attachment.prototype.events ),
insert: function() {
this.controller.selection.reset([ this.model ]);
this.controller.update();
}
});
/**
* wp.media.view.Attachment.Gallery
*/
media.view.Attachment.Gallery = media.view.Attachment.extend({
events: {}
buttons: {
close: true
},
events: {
'click .close': 'toggleSelection'
}
});
/**

View File

@ -1399,7 +1399,14 @@ function wp_print_media_templates( $attachment ) {
<% if ( uploading ) { %>
<div class="media-progress-bar"><div></div></div>
<% } %>
<div class="actions"></div>
<% if ( buttons.close ) { %>
<a class="close" href="#">&times;</a>
<% } %>
<% if ( buttons.insert ) { %>
<a class="insert button button-primary button-small" href="#"><?php _e( 'Insert' ); ?></a>
<% } %>
</div>
<div class="describe"></div>
</script>