Ticket #24859: 24859.2.diff
File 24859.2.diff, 3.1 KB (added by , 11 years ago) |
---|
-
src/wp-includes/js/media-models.js
36 36 37 37 _.extend( media, { model: {}, view: {}, controller: {}, frames: {} }); 38 38 39 _.extend( media, Backbone.Events ); 40 39 41 // Link any localized strings. 40 42 l10n = media.model.l10n = typeof _wpMediaModelsL10n === 'undefined' ? {} : _wpMediaModelsL10n; 41 43 … … 90 92 * Sends an XHR request to WordPress. 91 93 * See wp.ajax.send() in `wp-includes/js/wp-util.js`. 92 94 */ 93 ajax: wp.ajax.send, 95 ajax: function( action, options ) { 96 if ( _.isObject( action ) ) { 97 options = action; 98 } 94 99 100 var result = wp.ajax.send.apply( this, arguments ); 101 102 media.trigger( 'ajax:start', options ); 103 104 result.always(function() { 105 media.trigger( 'ajax:end', options ); 106 }); 107 108 return result; 109 }, 110 95 111 // Scales a set of dimensions to fit within bounding dimensions. 96 112 fit: function( dimensions ) { 97 113 var width = dimensions.width, -
src/wp-includes/js/media-views.js
3257 3257 media.view.AttachmentsBrowser = media.View.extend({ 3258 3258 tagName: 'div', 3259 3259 className: 'attachments-browser', 3260 spinnerCount: 0, 3260 3261 3261 3262 initialize: function() { 3262 3263 _.defaults( this.options, { … … 3267 3268 AttachmentView: media.view.Attachment.Library 3268 3269 }); 3269 3270 3271 media.on( 'ajax:start', function( options ) { 3272 this.spinnerCount += 1; 3273 this.updateSpinner( options ); 3274 }, this); 3275 3276 media.on( 'ajax:end', function( options ) { 3277 this.spinnerCount -= 1; 3278 this.updateSpinner( options ); 3279 }, this); 3280 3270 3281 this.createToolbar(); 3271 3282 this.updateContent(); 3272 3283 this.createSidebar(); … … 3274 3285 this.collection.on( 'add remove reset', this.updateContent, this ); 3275 3286 }, 3276 3287 3288 updateSpinner: function( options ) { 3289 var spinnerActions = ['query-attachments']; 3290 3291 if ( _.indexOf(spinnerActions, options.data.action) < 0 ) { 3292 return; 3293 } 3294 3295 if ( 0 < this.spinnerCount ) { 3296 this.toolbar.get('spinner').show(); 3297 } else { 3298 this.toolbar.get('spinner').hide(); 3299 } 3300 }, 3301 3277 3302 dispose: function() { 3278 3303 this.options.selection.off( null, null, this ); 3304 media.off( null, null, this ); 3279 3305 media.View.prototype.dispose.apply( this, arguments ); 3280 3306 return this; 3281 3307 }, … … 3303 3329 }).render() ); 3304 3330 } 3305 3331 3332 this.toolbar.set( 'spinner', new media.view.Spinner({ 3333 priority: -70 3334 }) ); 3335 3306 3336 if ( this.options.search ) { 3307 3337 this.toolbar.set( 'search', new media.view.Search({ 3308 3338 controller: this.controller, … … 3963 3993 this.$('img').attr( 'src', this.model.get('url') ); 3964 3994 } 3965 3995 }); 3966 }(jQuery)); 3967 No newline at end of file 3996 3997 media.view.Spinner = media.View.extend({ 3998 tagName: 'span', 3999 className: 'spinner', 4000 4001 show: function() { 4002 this.$el.show(); 4003 return this; 4004 }, 4005 4006 hide: function() { 4007 this.$el.hide(); 4008 return this; 4009 } 4010 }); 4011 4012 }(jQuery));