Make WordPress Core

Ticket #24716: 24716.34.diff

File 24716.34.diff, 4.9 KB (added by ericlewis, 11 years ago)
  • src/wp-includes/css/media-views.css

    diff --git a/src/wp-includes/css/media-views.css b/src/wp-includes/css/media-views.css
    index ad5a7be..a98357c 100644
    a b  
    996996        bottom: 0;
    997997        overflow: auto;
    998998        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;
    9991020}
    10001021
    10011022.inline-toolbar {
  • src/wp-includes/js/media-grid.js

    diff --git a/src/wp-includes/js/media-grid.js b/src/wp-includes/js/media-grid.js
    index 0ebbc67..a25a59c 100644
    a b  
    131131                                mode:      [ 'grid', 'edit' ]
    132132                        });
    133133
     134                        $(document).on( 'click', '.add-new-h2', _.bind( this.addNewClickHandler, this ) );
    134135                        // Ensure core and media grid view UI is enabled.
    135136                        this.$el.addClass('wp-core-ui media-grid-view');
    136137
     
    192193                                return;
    193194                        }
    194195
     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                        };
    195213                        // Add the default states.
    196214                        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
    207216                        ]);
    208217                },
    209218
     
    217226                        this.on( 'edit:attachment:previous', this.editPreviousAttachment, this );
    218227                },
    219228
     229                addNewClickHandler: function() {
     230                        this.trigger( 'show:upload:attachment' );
     231                },
     232
    220233                editPreviousAttachment: function( currentModel ) {
    221234                        var library = this.state().get('library'),
    222235                                currentModelIndex = library.indexOf( currentModel );
  • src/wp-includes/js/media-views.js

    diff --git a/src/wp-includes/js/media-views.js b/src/wp-includes/js/media-views.js
    index 6bf147c..81f0509 100644
    a b  
    55315531                                AttachmentView: media.view.Attachment.Library
    55325532                        });
    55335533
     5534                        this.listenTo( this.controller, 'show:upload:attachment', _.bind( this.showUploader, this ) );
    55345535                        this.createToolbar();
     5536                        this.createUploader();
     5537                        this.createAttachments();
    55355538                        this.updateContent();
    55365539                        if ( this.options.sidebar ) {
    55375540                                this.createSidebar();
     
    56355638
    56365639                updateContent: function() {
    56375640                        var view = this;
    5638 
    5639                         if( ! this.attachments ) {
    5640                                 this.createAttachments();
    5641                         }
    5642 
    56435641                        if ( ! this.collection.length ) {
    56445642                                this.toolbar.get( 'spinner' ).show();
    56455643                                this.collection.more().done(function() {
    56465644                                        if ( ! view.collection.length ) {
    5647                                                 view.createUploader();
     5645                                                view.attachmentsNoResults.$el.removeClass( 'hidden' );
     5646                                        } else {
     5647                                                view.attachmentsNoResults.$el.addClass( 'hidden' );
    56485648                                        }
    56495649                                        view.toolbar.get( 'spinner' ).hide();
    56505650                                });
    56515651                        } else {
     5652                                this.attachmentsNoResults.$el.addClass( 'hidden' );
    56525653                                view.toolbar.get( 'spinner' ).hide();
    56535654                        }
    56545655                },
    56555656
    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 
    56655657                createUploader: function() {
    5666                         this.removeContent();
    5667 
    56685658                        this.uploader = new media.view.UploaderInline({
    56695659                                controller: this.controller,
    56705660                                status:     false,
    56715661                                message:    l10n.noItemsFound
    56725662                        });
    56735663
     5664                        this.uploader.$el.addClass( 'hidden' );
    56745665                        this.views.add( this.uploader );
    56755666                },
    56765667
    5677                 createAttachments: function() {
    5678                         this.removeContent();
     5668                showUploader: function() {
     5669                        this.uploader.$el.removeClass( 'hidden' );
     5670                },
    56795671
     5672                createAttachments: function() {
    56805673                        this.attachments = new media.view.Attachments({
    56815674                                controller:           this.controller,
    56825675                                collection:           this.collection,
     
    56905683                        });
    56915684
    56925685                        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
    56935697                },
    56945698
    56955699                createSidebar: function() {