Make WordPress Core

Changeset 27516


Ignore:
Timestamp:
03/12/2014 09:06:30 PM (12 years ago)
Author:
helen
Message:

Smooth out some display and race condition issues with the media modal loading spinner. props kadamwhite, gcorne. see #24859.

File:
1 edited

Legend:

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

    r27498 r27516  
    52065206
    52075207                scroll: function() {
     5208                        var view = this,
     5209                                toolbar;
     5210
    52085211                        // @todo: is this still necessary?
    52095212                        if ( ! this.$el.is(':visible') ) {
     
    52125215
    52135216                        if ( this.collection.hasMore() && this.el.scrollHeight < this.el.scrollTop + ( this.el.clientHeight * this.options.refreshThreshold ) ) {
    5214                                 this.collection.more().done( this.scroll );
     5217                                toolbar = this.views.parent.toolbar;
     5218                                toolbar.get('spinner').show();
     5219
     5220                                this.collection.more().done(function() {
     5221                                        view.scroll();
     5222                                        toolbar.get('spinner').hide();
     5223                                });
    52155224                        }
    52165225                }
     
    54525461                        this.collection.on( 'add remove reset', this.updateContent, this );
    54535462                },
    5454                 toggleSpinner: function( state ) {
    5455                         if ( state ) {
    5456                                 this.spinnerTimeout = _.delay(function( view ) {
    5457                                         view.toolbar.get( 'spinner' ).show();
    5458                                 }, 600, this );
    5459                         } else {
    5460                                 this.toolbar.get( 'spinner' ).hide();
    5461                                 clearTimeout( this.spinnerTimeout );
    5462                         }
    5463                 },
    54645463                /**
    54655464                 * @returns {wp.media.view.AttachmentsBrowser} Returns itself to allow chaining
     
    55265525
    55275526                        if ( ! this.collection.length ) {
    5528                                 this.toggleSpinner( true );
     5527                                this.toolbar.get( 'spinner' ).show();
    55295528                                this.collection.more().done(function() {
    55305529                                        if ( ! view.collection.length ) {
    55315530                                                view.createUploader();
    55325531                                        }
    5533                                         view.toggleSpinner( false );
     5532                                        view.toolbar.get( 'spinner' ).hide();
    55345533                                });
    55355534                        }
     
    67656764                tagName:   'span',
    67666765                className: 'spinner',
     6766                spinnerTimeout: false,
     6767                delay: 400,
    67676768
    67686769                show: function() {
    6769                         this.$el.show();
     6770                        if ( ! this.spinnerTimeout ) {
     6771                                this.spinnerTimeout = _.delay(function( $el ) {
     6772                                        $el.show();
     6773                                }, this.delay, this.$el );
     6774                        }
     6775
    67706776                        return this;
    67716777                },
     
    67736779                hide: function() {
    67746780                        this.$el.hide();
     6781                        this.spinnerTimeout = clearTimeout( this.spinnerTimeout );
     6782
    67756783                        return this;
    67766784                }
Note: See TracChangeset for help on using the changeset viewer.