diff --git a/src/wp-includes/css/media-views.css b/src/wp-includes/css/media-views.css
index ad5a7be..a98357c 100644
a
|
b
|
|
996 | 996 | bottom: 0; |
997 | 997 | overflow: auto; |
998 | 998 | outline: none; |
| 999 | -webkit-transition: 1s ease-in-out; |
| 1000 | -moz-transition: 1s ease-in-out; |
| 1001 | -o-transition: 1s ease-in-out; |
| 1002 | transition: 1s ease-in-out; |
| 1003 | } |
| 1004 | |
| 1005 | .attachments-browser .uploader-inline:not(.hidden) + .attachments { |
| 1006 | -webkit-transform: translateY( 300px ); |
| 1007 | -ms-transform: translateY( 300px ); |
| 1008 | transform: translateY( 300px ); |
| 1009 | } |
| 1010 | |
| 1011 | .attachments-browser .uploader-inline.hidden { |
| 1012 | display: block; |
| 1013 | -webkit-transform: translateY( -100% ); |
| 1014 | -ms-transform: translateY( -100% ); |
| 1015 | transform: translateY( -100% ); |
| 1016 | } |
| 1017 | |
| 1018 | .attachments-browser .uploader-inline-content { |
| 1019 | top: 0; |
999 | 1020 | } |
1000 | 1021 | |
1001 | 1022 | .inline-toolbar { |
diff --git a/src/wp-includes/js/media-grid.js b/src/wp-includes/js/media-grid.js
index 0ebbc67..a25a59c 100644
a
|
b
|
|
131 | 131 | mode: [ 'grid', 'edit' ] |
132 | 132 | }); |
133 | 133 | |
| 134 | $(document).on( 'click', '.add-new-h2', _.bind( this.addNewClickHandler, this ) ); |
134 | 135 | // Ensure core and media grid view UI is enabled. |
135 | 136 | this.$el.addClass('wp-core-ui media-grid-view'); |
136 | 137 | |
… |
… |
|
192 | 193 | return; |
193 | 194 | } |
194 | 195 | |
| 196 | var libraryState = new media.controller.Library({ |
| 197 | library: media.query( options.library ), |
| 198 | multiple: options.multiple, |
| 199 | title: options.title, |
| 200 | priority: 20, |
| 201 | toolbar: false, |
| 202 | router: false, |
| 203 | content: 'browse', |
| 204 | filterable: 'mime-types' |
| 205 | }); |
| 206 | |
| 207 | libraryState._renderTitle = function( view ) { |
| 208 | var text = this.get('title') || ''; |
| 209 | view.$el.addClass( 'wrap' ); |
| 210 | text += '<a class="add-new-h2">Add New</a>'; |
| 211 | view.$el.html( text ); |
| 212 | }; |
195 | 213 | // Add the default states. |
196 | 214 | this.states.add([ |
197 | | new media.controller.Library({ |
198 | | library: media.query( options.library ), |
199 | | multiple: options.multiple, |
200 | | title: options.title, |
201 | | priority: 20, |
202 | | toolbar: false, |
203 | | router: false, |
204 | | content: 'browse', |
205 | | filterable: 'mime-types' |
206 | | }) |
| 215 | libraryState |
207 | 216 | ]); |
208 | 217 | }, |
209 | 218 | |
… |
… |
|
217 | 226 | this.on( 'edit:attachment:previous', this.editPreviousAttachment, this ); |
218 | 227 | }, |
219 | 228 | |
| 229 | addNewClickHandler: function() { |
| 230 | this.trigger( 'show:upload:attachment' ); |
| 231 | }, |
| 232 | |
220 | 233 | editPreviousAttachment: function( currentModel ) { |
221 | 234 | var library = this.state().get('library'), |
222 | 235 | currentModelIndex = library.indexOf( currentModel ); |
diff --git a/src/wp-includes/js/media-views.js b/src/wp-includes/js/media-views.js
index 6bf147c..81f0509 100644
a
|
b
|
|
5531 | 5531 | AttachmentView: media.view.Attachment.Library |
5532 | 5532 | }); |
5533 | 5533 | |
| 5534 | this.listenTo( this.controller, 'show:upload:attachment', _.bind( this.showUploader, this ) ); |
5534 | 5535 | this.createToolbar(); |
| 5536 | this.createUploader(); |
| 5537 | this.createAttachments(); |
5535 | 5538 | this.updateContent(); |
5536 | 5539 | if ( this.options.sidebar ) { |
5537 | 5540 | this.createSidebar(); |
… |
… |
|
5635 | 5638 | |
5636 | 5639 | updateContent: function() { |
5637 | 5640 | var view = this; |
5638 | | |
5639 | | if( ! this.attachments ) { |
5640 | | this.createAttachments(); |
5641 | | } |
5642 | | |
5643 | 5641 | if ( ! this.collection.length ) { |
5644 | 5642 | this.toolbar.get( 'spinner' ).show(); |
5645 | 5643 | this.collection.more().done(function() { |
5646 | 5644 | if ( ! view.collection.length ) { |
5647 | | view.createUploader(); |
| 5645 | view.attachmentsNoResults.$el.removeClass( 'hidden' ); |
| 5646 | } else { |
| 5647 | view.attachmentsNoResults.$el.addClass( 'hidden' ); |
5648 | 5648 | } |
5649 | 5649 | view.toolbar.get( 'spinner' ).hide(); |
5650 | 5650 | }); |
5651 | 5651 | } else { |
| 5652 | this.attachmentsNoResults.$el.addClass( 'hidden' ); |
5652 | 5653 | view.toolbar.get( 'spinner' ).hide(); |
5653 | 5654 | } |
5654 | 5655 | }, |
5655 | 5656 | |
5656 | | removeContent: function() { |
5657 | | _.each(['attachments','uploader'], function( key ) { |
5658 | | if ( this[ key ] ) { |
5659 | | this[ key ].remove(); |
5660 | | delete this[ key ]; |
5661 | | } |
5662 | | }, this ); |
5663 | | }, |
5664 | | |
5665 | 5657 | createUploader: function() { |
5666 | | this.removeContent(); |
5667 | | |
5668 | 5658 | this.uploader = new media.view.UploaderInline({ |
5669 | 5659 | controller: this.controller, |
5670 | 5660 | status: false, |
5671 | 5661 | message: l10n.noItemsFound |
5672 | 5662 | }); |
5673 | 5663 | |
| 5664 | this.uploader.$el.addClass( 'hidden' ); |
5674 | 5665 | this.views.add( this.uploader ); |
5675 | 5666 | }, |
5676 | 5667 | |
5677 | | createAttachments: function() { |
5678 | | this.removeContent(); |
| 5668 | showUploader: function() { |
| 5669 | this.uploader.$el.removeClass( 'hidden' ); |
| 5670 | }, |
5679 | 5671 | |
| 5672 | createAttachments: function() { |
5680 | 5673 | this.attachments = new media.view.Attachments({ |
5681 | 5674 | controller: this.controller, |
5682 | 5675 | collection: this.collection, |
… |
… |
|
5690 | 5683 | }); |
5691 | 5684 | |
5692 | 5685 | this.views.add( this.attachments ); |
| 5686 | |
| 5687 | this.attachmentsNoResults = new media.View({ |
| 5688 | controller: this.controller |
| 5689 | }); |
| 5690 | |
| 5691 | this.attachmentsNoResults.$el.addClass( 'hidden' ); |
| 5692 | this.attachmentsNoResults.$el.html( 'No media found.' ); |
| 5693 | |
| 5694 | this.views.add( this.attachmentsNoResults ); |
| 5695 | |
| 5696 | |
5693 | 5697 | }, |
5694 | 5698 | |
5695 | 5699 | createSidebar: function() { |