Make WordPress Core

Changeset 27631


Ignore:
Timestamp:
03/20/2014 02:44:26 AM (13 years ago)
Author:
wonderboymusic
Message:

Move wp.media.view.MediaDetails to media-audiovideo.js. This should have moved over with the rest.

See [27608].

Location:
trunk/src/wp-includes/js
Files:
2 edited

Legend:

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

    r27619 r27631  
    786786
    787787        /**
     788         * wp.media.view.MediaDetails
     789         *
     790         * @contructor
     791         * @augments wp.media.view.Settings.AttachmentDisplay
     792         * @augments wp.media.view.Settings
     793         * @augments wp.media.View
     794         * @augments wp.Backbone.View
     795         * @augments Backbone.View
     796         */
     797        media.view.MediaDetails = media.view.Settings.AttachmentDisplay.extend({
     798                initialize: function() {
     799                        _.bindAll(this, 'success');
     800
     801                        this.listenTo( this.controller, 'close', media.mixin.unsetPlayer );
     802                        this.on( 'ready', this.setPlayer );
     803                        this.on( 'media:setting:remove', media.mixin.unsetPlayer, this );
     804                        this.on( 'media:setting:remove', this.render );
     805                        this.on( 'media:setting:remove', this.setPlayer );
     806                        this.events = _.extend( this.events, {
     807                                'click .remove-setting' : 'removeSetting',
     808                                'change .content-track' : 'setTracks',
     809                                'click .remove-track' : 'setTracks'
     810                        } );
     811
     812                        media.view.Settings.AttachmentDisplay.prototype.initialize.apply( this, arguments );
     813                },
     814
     815                prepare: function() {
     816                        return _.defaults({
     817                                model: this.model.toJSON()
     818                        }, this.options );
     819                },
     820
     821                removeSetting : function (e) {
     822                        var wrap = $( e.currentTarget ).parent(), setting;
     823
     824                        setting = wrap.find( 'input' ).data( 'setting' );
     825
     826                        if ( setting ) {
     827                                this.model.unset( setting );
     828                                this.trigger( 'media:setting:remove', this );
     829                        }
     830
     831                        wrap.remove();
     832                },
     833
     834                setTracks : function () {
     835                        var tracks = '';
     836
     837                        _.each( this.$('.content-track'), function (track) {
     838                                tracks += $( track ).val();
     839                        } );
     840
     841                        this.model.set( 'content', tracks );
     842                        this.trigger( 'media:setting:remove', this );
     843                },
     844
     845                setPlayer : function () {
     846                        if ( ! this.player && this.media ) {
     847                                this.player = new MediaElementPlayer( this.media, this.settings );
     848                        }
     849                },
     850
     851                /**
     852                 * @abstract
     853                 */
     854                setMedia : function () {
     855                        return this;
     856                },
     857
     858                success : function (mejs) {
     859                        var autoplay = mejs.attributes.autoplay && 'false' !== mejs.attributes.autoplay;
     860
     861                        if ( 'flash' === mejs.pluginType && autoplay ) {
     862                                mejs.addEventListener( 'canplay', function () {
     863                                        mejs.play();
     864                                }, false );
     865                        }
     866
     867                        this.mejs = mejs;
     868                },
     869
     870                render: function() {
     871                        var self = this, settings = {
     872                                success : this.success
     873                        };
     874
     875                        if ( ! _.isUndefined( window._wpmejsSettings ) ) {
     876                                settings.pluginPath = _wpmejsSettings.pluginPath;
     877                        }
     878
     879                        media.view.Settings.AttachmentDisplay.prototype.render.apply( this, arguments );
     880                        setTimeout( function() { self.resetFocus(); }, 10 );
     881
     882                        this.settings = settings;
     883
     884                        return this.setMedia();
     885                },
     886
     887                resetFocus: function() {
     888                        this.$( '.embed-media-settings' ).scrollTop( 0 );
     889                }
     890        }, {
     891                instances : 0,
     892
     893                /**
     894                 * When multiple players in the DOM contain the same src, things get weird.
     895                 *
     896                 * @param {HTMLElement} media
     897                 * @returns {HTMLElement}
     898                 */
     899                prepareSrc : function (media) {
     900                        var i = wp.media.view.MediaDetails.instances++;
     901                        _.each( $(media).find('source'), function (source) {
     902                                source.src = [
     903                                        source.src,
     904                                        source.src.indexOf('?') > -1 ? '&' : '?',
     905                                        '_=',
     906                                        i
     907                                ].join('');
     908                        });
     909
     910                        return media;
     911                }
     912        });
     913
     914        /**
    788915         * wp.media.view.AudioDetails
    789916         *
  • trunk/src/wp-includes/js/media-views.js

    r27625 r27631  
    60516051
    60526052        /**
    6053          * wp.media.view.MediaDetails
    6054          *
    6055          * @contructor
    6056          * @augments wp.media.view.Settings.AttachmentDisplay
    6057          * @augments wp.media.view.Settings
    6058          * @augments wp.media.View
    6059          * @augments wp.Backbone.View
    6060          * @augments Backbone.View
    6061          */
    6062         media.view.MediaDetails = media.view.Settings.AttachmentDisplay.extend({
    6063                 initialize: function() {
    6064                         _.bindAll(this, 'success');
    6065 
    6066                         this.listenTo( this.controller, 'close', media.mixin.unsetPlayer );
    6067                         this.on( 'ready', this.setPlayer );
    6068                         this.on( 'media:setting:remove', media.mixin.unsetPlayer, this );
    6069                         this.on( 'media:setting:remove', this.render );
    6070                         this.on( 'media:setting:remove', this.setPlayer );
    6071                         this.events = _.extend( this.events, {
    6072                                 'click .remove-setting' : 'removeSetting',
    6073                                 'change .content-track' : 'setTracks',
    6074                                 'click .remove-track' : 'setTracks'
    6075                         } );
    6076 
    6077                         media.view.Settings.AttachmentDisplay.prototype.initialize.apply( this, arguments );
    6078                 },
    6079 
    6080                 prepare: function() {
    6081                         return _.defaults({
    6082                                 model: this.model.toJSON()
    6083                         }, this.options );
    6084                 },
    6085 
    6086                 removeSetting : function (e) {
    6087                         var wrap = $( e.currentTarget ).parent(), setting;
    6088 
    6089                         setting = wrap.find( 'input' ).data( 'setting' );
    6090 
    6091                         if ( setting ) {
    6092                                 this.model.unset( setting );
    6093                                 this.trigger( 'media:setting:remove', this );
    6094                         }
    6095 
    6096                         wrap.remove();
    6097                 },
    6098 
    6099                 setTracks : function () {
    6100                         var tracks = '';
    6101 
    6102                         _.each( this.$('.content-track'), function (track) {
    6103                                 tracks += $( track ).val();
    6104                         } );
    6105 
    6106                         this.model.set( 'content', tracks );
    6107                         this.trigger( 'media:setting:remove', this );
    6108                 },
    6109 
    6110                 setPlayer : function () {
    6111                         if ( ! this.player && this.media ) {
    6112                                 this.player = new MediaElementPlayer( this.media, this.settings );
    6113                         }
    6114                 },
    6115 
    6116                 /**
    6117                  * @abstract
    6118                  */
    6119                 setMedia : function () {
    6120                         return this;
    6121                 },
    6122 
    6123                 success : function (mejs) {
    6124                         var autoplay = mejs.attributes.autoplay && 'false' !== mejs.attributes.autoplay;
    6125 
    6126                         if ( 'flash' === mejs.pluginType && autoplay ) {
    6127                                 mejs.addEventListener( 'canplay', function () {
    6128                                         mejs.play();
    6129                                 }, false );
    6130                         }
    6131 
    6132                         this.mejs = mejs;
    6133                 },
    6134 
    6135                 render: function() {
    6136                         var self = this, settings = {
    6137                                 success : this.success
    6138                         };
    6139 
    6140                         if ( ! _.isUndefined( window._wpmejsSettings ) ) {
    6141                                 settings.pluginPath = _wpmejsSettings.pluginPath;
    6142                         }
    6143 
    6144                         media.view.Settings.AttachmentDisplay.prototype.render.apply( this, arguments );
    6145                         setTimeout( function() { self.resetFocus(); }, 10 );
    6146 
    6147                         this.settings = settings;
    6148 
    6149                         return this.setMedia();
    6150                 },
    6151 
    6152                 resetFocus: function() {
    6153                         this.$( '.embed-media-settings' ).scrollTop( 0 );
    6154                 }
    6155         }, {
    6156                 instances : 0,
    6157 
    6158                 /**
    6159                  * When multiple players in the DOM contain the same src, things get weird.
    6160                  *
    6161                  * @param {HTMLElement} media
    6162                  * @returns {HTMLElement}
    6163                  */
    6164                 prepareSrc : function (media) {
    6165                         var i = wp.media.view.MediaDetails.instances++;
    6166                         _.each( $(media).find('source'), function (source) {
    6167                                 source.src = [
    6168                                         source.src,
    6169                                         source.src.indexOf('?') > -1 ? '&' : '?',
    6170                                         '_=',
    6171                                         i
    6172                                 ].join('');
    6173                         });
    6174 
    6175                         return media;
    6176                 }
    6177         });
    6178 
    6179         /**
    61806053         * wp.media.view.Spinner
    61816054         *
Note: See TracChangeset for help on using the changeset viewer.