Make WordPress Core

Ticket #24859: 24859.3.diff

File 24859.3.diff, 2.0 KB (added by gcorne, 11 years ago)
  • src/wp-includes/js/media-views.js

    diff --git src/wp-includes/js/media-views.js src/wp-includes/js/media-views.js
    index 54a6c05..a949243 100644
     
    52015201        media.view.AttachmentsBrowser = media.View.extend({
    52025202                tagName:   'div',
    52035203                className: 'attachments-browser',
     5204                showSpinner: false,
    52045205
    52055206                initialize: function() {
    52065207                        _.defaults( this.options, {
     
    52175218
    52185219                        this.collection.on( 'add remove reset', this.updateContent, this );
    52195220                },
     5221                toggleSpinner: function() {
     5222                        if ( ! this.showSpinner ) {
     5223                                this.showSpinner = true;
     5224                                // delay showing the spinner for 500ms and catch case where the spinner is toggled
     5225                                // before delay is finished
     5226                                _.delay( function( view ) {
     5227                                        if ( view.showSpinner ) {
     5228                                                view.toolbar.get('spinner').show();
     5229                                        }
     5230                                }, 600, this );
     5231                        } else {
     5232                                this.showSpinner = false;
     5233                                this.toolbar.get('spinner').hide();
     5234                        }
     5235                },
    52205236                /**
    52215237                 * @returns {wp.media.view.AttachmentsBrowser} Returns itself to allow chaining
    52225238                 */
     
    52535269                                }).render() );
    52545270                        }
    52555271
     5272                        this.toolbar.set( 'spinner', new media.view.Spinner({
     5273                                priority: -70
     5274                        }) );
     5275
    52565276                        if ( this.options.search ) {
    52575277                                this.toolbar.set( 'search', new media.view.Search({
    52585278                                        controller: this.controller,
     
    52775297                        }
    52785298
    52795299                        if ( ! this.collection.length ) {
     5300                                this.toggleSpinner();
    52805301                                this.collection.more().done( function() {
    52815302                                        if ( ! view.collection.length ) {
    52825303                                                view.createUploader();
    52835304                                        }
     5305                                        view.toggleSpinner();
    52845306                                });
    52855307                        }
    52865308                },
     
    62646286                        this.$( '.embed-media-settings' ).scrollTop( 0 );
    62656287                }
    62666288        });
     6289
     6290        /**
     6291         * wp.media.view.Spinner
     6292         *
     6293         *
     6294         * @constructor
     6295         * @augments wp.media.View
     6296         * @augments wp.Backbone.View
     6297         * @augments Backbone.View
     6298         */
     6299        media.view.Spinner = media.View.extend({
     6300                tagName:   'span',
     6301                className: 'spinner',
     6302
     6303                show: function() {
     6304                        this.$el.show();
     6305                        return this;
     6306                },
     6307
     6308                hide: function() {
     6309                        this.$el.hide();
     6310                        return this;
     6311                }
     6312        });
    62676313}(jQuery, _));