Make WordPress Core

Ticket #24716: 24716.52.diff

File 24716.52.diff, 2.8 KB (added by kovshenin, 11 years ago)
  • src/wp-includes/js/media-grid.js

     
    206206                                suggestedWidth:  state.get('suggestedWidth'),
    207207                                suggestedHeight: state.get('suggestedHeight'),
    208208
    209                                 AttachmentView: state.get('AttachmentView')
     209                                AttachmentView: state.get('AttachmentView'),
     210
     211                                scrollElement: document
    210212                        });
    211213                }
    212214        });
  • src/wp-includes/js/media-views.js

     
    51955195
    51965196                cssTemplate: media.template('attachments-css'),
    51975197
    5198                 events: {
    5199                         'scroll': 'scroll'
    5200                 },
    5201 
    52025198                initialize: function() {
    52035199                        this.el.id = _.uniqueId('__attachments-view-');
    52045200
     
    52295225
    52305226                        this.collection.on( 'reset', this.render, this );
    52315227
    5232                         // Throttle the scroll handler.
     5228                        // Throttle the scroll handler and bind this.
    52335229                        this.scroll = _.chain( this.scroll ).bind( this ).throttle( this.options.refreshSensitivity ).value();
    52345230
     5231                        this.options.scrollElement = this.options.scrollElement || this.el;
     5232                        $( this.options.scrollElement ).on( 'scroll', this.scroll );
     5233
    52355234                        this.initSortable();
    52365235
    52375236                        _.bindAll( this, 'css' );
     
    54005399
    54015400                scroll: function() {
    54025401                        var view = this,
     5402                                el = this.options.scrollElement,
     5403                                scrollTop = el.scrollTop,
    54035404                                toolbar;
    54045405
    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() ) {
    54065414                                return;
    54075415                        }
    54085416
    54095417                        toolbar = this.views.parent.toolbar;
    54105418
    54115419                        // 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 ) {
    54135421                                toolbar.get('spinner').show();
    54145422                        }
    54155423
    5416                         if ( this.el.scrollHeight < this.el.scrollTop + ( this.el.clientHeight * this.options.refreshThreshold ) ) {
     5424                        if ( el.scrollHeight < scrollTop + ( el.clientHeight * this.options.refreshThreshold ) ) {
    54175425                                this.collection.more().done(function() {
    54185426                                        view.scroll();
    54195427                                        toolbar.get('spinner').hide();
     
    58535861                                selection:            this.options.selection,
    58545862                                model:                this.model,
    58555863                                sortable:             this.options.sortable,
     5864                                scrollElement:        this.options.scrollElement,
    58565865
    58575866                                // The single `Attachment` view to be used in the `Attachments` view.
    58585867                                AttachmentView: this.options.AttachmentView