Make WordPress Core

Changeset 27535


Ignore:
Timestamp:
03/14/2014 12:42:57 PM (12 years ago)
Author:
wonderboymusic
Message:

Make media.view.VideoDetails.prepareSrc a static class method instead of an instance method. Properly pairs it with its incrementing instances property.

See #27389.

File:
1 edited

Legend:

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

    r27531 r27535  
    65706570                },
    65716571
     6572                removeSetting : function (e) {
     6573                        var wrap = $( e.currentTarget ).parent(), setting;
     6574
     6575                        setting = wrap.find( 'input' ).data( 'setting' );
     6576
     6577                        if ( setting ) {
     6578                                this.model.unset( setting );
     6579                                this.trigger( 'media:setting:remove', this );
     6580                        }
     6581
     6582                        wrap.remove();
     6583                },
     6584
     6585                setTracks : function () {
     6586                        var tracks = '';
     6587
     6588                        _.each( this.$('.content-track'), function (track) {
     6589                                tracks += $( track ).val();
     6590                        } );
     6591
     6592                        this.model.set( 'content', tracks );
     6593                        this.trigger( 'media:setting:remove', this );
     6594                },
     6595
     6596                setPlayer : function () {
     6597                        if ( ! this.player && this.media ) {
     6598                                this.player = new MediaElementPlayer( this.media, this.settings );
     6599                        }
     6600                },
     6601
     6602                /**
     6603                 * @abstract
     6604                 */
     6605                setMedia : function () {
     6606                        return this;
     6607                },
     6608
     6609                /**
     6610                 * Override the MediaElement method for removing a player.
     6611                 *      MediaElement tries to pull the audio/video tag out of
     6612                 *      its container and re-add it to the DOM.
     6613                 */
     6614                removePlayer: function() {
     6615                        var t = this.player, featureIndex, feature;
     6616
     6617                        // invoke features cleanup
     6618                        for ( featureIndex in t.options.features ) {
     6619                                feature = t.options.features[featureIndex];
     6620                                if ( t['clean' + feature] ) {
     6621                                        try {
     6622                                                t['clean' + feature](t);
     6623                                        } catch (e) {}
     6624                                }
     6625                        }
     6626
     6627                        if ( ! t.isDynamic ) {
     6628                                t.$node.remove();
     6629                        }
     6630
     6631                        if ( 'native' !== t.media.pluginType ) {
     6632                                t.media.remove();
     6633                        }
     6634
     6635                        delete window.mejs.players[t.id];
     6636
     6637                        t.container.remove();
     6638                        t.globalUnbind();
     6639                        delete t.node.player;
     6640                },
     6641
     6642                unsetPlayer : function() {
     6643                        if ( this.player ) {
     6644                                if ( _.isUndefined( this.mejs.pluginType ) ) {
     6645                                        this.mejs.pause();
     6646                                }
     6647                                this.removePlayer();
     6648                                this.player = false;
     6649                        }
     6650                },
     6651
     6652                success : function (mejs) {
     6653                        var autoplay = mejs.attributes.autoplay && 'false' !== mejs.attributes.autoplay;
     6654
     6655                        if ( 'flash' === mejs.pluginType && autoplay ) {
     6656                                mejs.addEventListener( 'canplay', function () {
     6657                                        mejs.play();
     6658                                }, false );
     6659                        }
     6660
     6661                        this.mejs = mejs;
     6662                },
     6663
     6664                render: function() {
     6665                        var self = this, settings = {
     6666                                success : this.success
     6667                        };
     6668
     6669                        if ( ! _.isUndefined( window._wpmejsSettings ) ) {
     6670                                settings.pluginPath = _wpmejsSettings.pluginPath;
     6671                        }
     6672
     6673                        media.view.Settings.AttachmentDisplay.prototype.render.apply( this, arguments );
     6674                        setTimeout( function() { self.resetFocus(); }, 10 );
     6675
     6676                        this.settings = settings;
     6677
     6678                        return this.setMedia();
     6679                },
     6680
     6681                resetFocus: function() {
     6682                        this.$( '.embed-media-settings' ).scrollTop( 0 );
     6683                }
     6684        }, {
     6685                instances : 0,
     6686
    65726687                /**
    65736688                 * When multiple players in the DOM contain the same src, things get weird.
     
    65886703
    65896704                        return media;
    6590                 },
    6591 
    6592                 removeSetting : function (e) {
    6593                         var wrap = $( e.currentTarget ).parent(), setting;
    6594 
    6595                         setting = wrap.find( 'input' ).data( 'setting' );
    6596 
    6597                         if ( setting ) {
    6598                                 this.model.unset( setting );
    6599                                 this.trigger( 'media:setting:remove', this );
    6600                         }
    6601 
    6602                         wrap.remove();
    6603                 },
    6604 
    6605                 setTracks : function () {
    6606                         var tracks = '';
    6607 
    6608                         _.each( this.$('.content-track'), function (track) {
    6609                                 tracks += $( track ).val();
    6610                         } );
    6611 
    6612                         this.model.set( 'content', tracks );
    6613                         this.trigger( 'media:setting:remove', this );
    6614                 },
    6615 
    6616                 setPlayer : function () {
    6617                         if ( ! this.player && this.media ) {
    6618                                 this.player = new MediaElementPlayer( this.media, this.settings );
    6619                         }
    6620                 },
    6621 
    6622                 /**
    6623                  * @abstract
    6624                  */
    6625                 setMedia : function () {
    6626                         return this;
    6627                 },
    6628 
    6629                 /**
    6630                  * Override the MediaElement method for removing a player.
    6631                  *      MediaElement tries to pull the audio/video tag out of
    6632                  *      its container and re-add it to the DOM.
    6633                  */
    6634                 removePlayer: function() {
    6635                         var t = this.player, featureIndex, feature;
    6636 
    6637                         // invoke features cleanup
    6638                         for ( featureIndex in t.options.features ) {
    6639                                 feature = t.options.features[featureIndex];
    6640                                 if ( t['clean' + feature] ) {
    6641                                         try {
    6642                                                 t['clean' + feature](t);
    6643                                         } catch (e) {}
    6644                                 }
    6645                         }
    6646 
    6647                         if ( ! t.isDynamic ) {
    6648                                 t.$node.remove();
    6649                         }
    6650 
    6651                         if ( 'native' !== t.media.pluginType ) {
    6652                                 t.media.remove();
    6653                         }
    6654 
    6655                         delete window.mejs.players[t.id];
    6656 
    6657                         t.container.remove();
    6658                         t.globalUnbind();
    6659                         delete t.node.player;
    6660                 },
    6661 
    6662                 unsetPlayer : function() {
    6663                         if ( this.player ) {
    6664                                 if ( _.isUndefined( this.mejs.pluginType ) ) {
    6665                                         this.mejs.pause();
    6666                                 }
    6667                                 this.removePlayer();
    6668                                 this.player = false;
    6669                         }
    6670                 },
    6671 
    6672                 success : function (mejs) {
    6673                         var autoplay = mejs.attributes.autoplay && 'false' !== mejs.attributes.autoplay;
    6674 
    6675                         if ( 'flash' === mejs.pluginType && autoplay ) {
    6676                                 mejs.addEventListener( 'canplay', function () {
    6677                                         mejs.play();
    6678                                 }, false );
    6679                         }
    6680 
    6681                         this.mejs = mejs;
    6682                 },
    6683 
    6684                 render: function() {
    6685                         var self = this, settings = {
    6686                                 success : this.success
    6687                         };
    6688 
    6689                         if ( ! _.isUndefined( window._wpmejsSettings ) ) {
    6690                                 settings.pluginPath = _wpmejsSettings.pluginPath;
    6691                         }
    6692 
    6693                         media.view.Settings.AttachmentDisplay.prototype.render.apply( this, arguments );
    6694                         setTimeout( function() { self.resetFocus(); }, 10 );
    6695 
    6696                         this.settings = settings;
    6697 
    6698                         return this.setMedia();
    6699                 },
    6700 
    6701                 resetFocus: function() {
    6702                         this.$( '.embed-media-settings' ).scrollTop( 0 );
    6703                 }
    6704         }, {
    6705                 instances : 0
     6705                }
    67066706        });
    67076707
     
    67286728                                        audio.show();
    67296729                                }
    6730                                 this.media = this.prepareSrc( audio.get(0) );
     6730                                this.media = media.view.MediaDetails.prepareSrc( audio.get(0) );
    67316731                        } else {
    67326732                                audio.hide();
     
    67626762
    67636763                                if ( ! video.hasClass('youtube-video') ) {
    6764                                         this.media = this.prepareSrc( video.get(0) );
     6764                                        this.media = media.view.MediaDetails.prepareSrc( video.get(0) );
    67656765                                } else {
    67666766                                        this.media = video.get(0);
Note: See TracChangeset for help on using the changeset viewer.