Ticket #24716: 24716.52.diff
File 24716.52.diff, 2.8 KB (added by , 11 years ago) |
---|
-
src/wp-includes/js/media-grid.js
206 206 suggestedWidth: state.get('suggestedWidth'), 207 207 suggestedHeight: state.get('suggestedHeight'), 208 208 209 AttachmentView: state.get('AttachmentView') 209 AttachmentView: state.get('AttachmentView'), 210 211 scrollElement: document 210 212 }); 211 213 } 212 214 }); -
src/wp-includes/js/media-views.js
5195 5195 5196 5196 cssTemplate: media.template('attachments-css'), 5197 5197 5198 events: {5199 'scroll': 'scroll'5200 },5201 5202 5198 initialize: function() { 5203 5199 this.el.id = _.uniqueId('__attachments-view-'); 5204 5200 … … 5229 5225 5230 5226 this.collection.on( 'reset', this.render, this ); 5231 5227 5232 // Throttle the scroll handler .5228 // Throttle the scroll handler and bind this. 5233 5229 this.scroll = _.chain( this.scroll ).bind( this ).throttle( this.options.refreshSensitivity ).value(); 5234 5230 5231 this.options.scrollElement = this.options.scrollElement || this.el; 5232 $( this.options.scrollElement ).on( 'scroll', this.scroll ); 5233 5235 5234 this.initSortable(); 5236 5235 5237 5236 _.bindAll( this, 'css' ); … … 5400 5399 5401 5400 scroll: function() { 5402 5401 var view = this, 5402 el = this.options.scrollElement, 5403 scrollTop = el.scrollTop, 5403 5404 toolbar; 5404 5405 5405 if ( ! this.$el.is(':visible') || ! this.collection.hasMore() ) { 5406 // The scroll event occurs on the document, but the element 5407 // that should be checked is the document body. 5408 if ( el == document ) { 5409 el = document.body; 5410 scrollTop = $(document).scrollTop(); 5411 } 5412 5413 if ( ! $(el).is(':visible') || ! this.collection.hasMore() ) { 5406 5414 return; 5407 5415 } 5408 5416 5409 5417 toolbar = this.views.parent.toolbar; 5410 5418 5411 5419 // Show the spinner only if we are close to the bottom. 5412 if ( this.el.scrollHeight - ( this.el.scrollTop + this.el.clientHeight ) < this.el.clientHeight / 3 ) {5420 if ( el.scrollHeight - ( scrollTop + el.clientHeight ) < el.clientHeight / 3 ) { 5413 5421 toolbar.get('spinner').show(); 5414 5422 } 5415 5423 5416 if ( this.el.scrollHeight < this.el.scrollTop + ( this.el.clientHeight * this.options.refreshThreshold ) ) {5424 if ( el.scrollHeight < scrollTop + ( el.clientHeight * this.options.refreshThreshold ) ) { 5417 5425 this.collection.more().done(function() { 5418 5426 view.scroll(); 5419 5427 toolbar.get('spinner').hide(); … … 5853 5861 selection: this.options.selection, 5854 5862 model: this.model, 5855 5863 sortable: this.options.sortable, 5864 scrollElement: this.options.scrollElement, 5856 5865 5857 5866 // The single `Attachment` view to be used in the `Attachments` view. 5858 5867 AttachmentView: this.options.AttachmentView