Make WordPress Core

Changeset 27438


Ignore:
Timestamp:
03/06/2014 05:45:26 PM (13 years ago)
Author:
wonderboymusic
Message:

Add a loading indicator to the Media Library.

Props kadamwhite, gcorne, kovshenin.
Fixes #24859.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/css/media-views.css

    r27411 r27438  
    12911291}
    12921292
     1293.media-toolbar .spinner {
     1294        margin-top: 14px;
     1295}
     1296
    12931297.media-sidebar .settings-save-status {
    12941298        background: #f5f5f5;
  • trunk/src/wp-includes/js/media-views.js

    r27435 r27438  
    52555255                        this.collection.on( 'add remove reset', this.updateContent, this );
    52565256                },
     5257                toggleSpinner: function( state ) {
     5258                        if ( state ) {
     5259                                this.spinnerTimeout = _.delay(function( view ) {
     5260                                        view.toolbar.get( 'spinner' ).show();
     5261                                }, 600, this );
     5262                        } else {
     5263                                this.toolbar.get( 'spinner' ).hide();
     5264                                clearTimeout( this.spinnerTimeout );
     5265                        }
     5266                },
    52575267                /**
    52585268                 * @returns {wp.media.view.AttachmentsBrowser} Returns itself to allow chaining
     
    52915301                        }
    52925302
     5303                        this.toolbar.set( 'spinner', new media.view.Spinner({
     5304                                priority: -70
     5305                        }) );
     5306
    52935307                        if ( this.options.search ) {
    52945308                                this.toolbar.set( 'search', new media.view.Search({
     
    53155329
    53165330                        if ( ! this.collection.length ) {
    5317                                 this.collection.more().done( function() {
     5331                                this.toggleSpinner( true );
     5332                                this.collection.more().done(function() {
    53185333                                        if ( ! view.collection.length ) {
    53195334                                                view.createUploader();
    53205335                                        }
     5336                                        view.toggleSpinner( false );
    53215337                                });
    53225338                        }
     
    63146330                }
    63156331        });
     6332
     6333        /**
     6334         * wp.media.view.Spinner
     6335         *
     6336         * @constructor
     6337         * @augments wp.media.View
     6338         * @augments wp.Backbone.View
     6339         * @augments Backbone.View
     6340         */
     6341        media.view.Spinner = media.View.extend({
     6342                tagName:   'span',
     6343                className: 'spinner',
     6344
     6345                show: function() {
     6346                        this.$el.show();
     6347                        return this;
     6348                },
     6349
     6350                hide: function() {
     6351                        this.$el.hide();
     6352                        return this;
     6353                }
     6354        });
    63166355}(jQuery, _));
Note: See TracChangeset for help on using the changeset viewer.