2015-02-08 19:43:50 -05:00
|
|
|
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
2015-02-09 11:01:29 -05:00
|
|
|
var media = wp.media,
|
|
|
|
baseSettings = window._wpmejsSettings || {},
|
|
|
|
l10n = window._wpMediaViewsL10n || {};
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-09 11:01:29 -05:00
|
|
|
/**
|
|
|
|
* @mixin
|
|
|
|
*/
|
|
|
|
wp.media.mixin = {
|
|
|
|
mejsSettings: baseSettings,
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-09 11:01:29 -05:00
|
|
|
removeAllPlayers: function() {
|
|
|
|
var p;
|
|
|
|
|
|
|
|
if ( window.mejs && window.mejs.players ) {
|
|
|
|
for ( p in window.mejs.players ) {
|
|
|
|
window.mejs.players[p].pause();
|
|
|
|
this.removePlayer( window.mejs.players[p] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2015-02-08 19:43:50 -05:00
|
|
|
|
|
|
|
/**
|
2015-02-09 11:01:29 -05:00
|
|
|
* Override the MediaElement method for removing a player.
|
|
|
|
* MediaElement tries to pull the audio/video tag out of
|
|
|
|
* its container and re-add it to the DOM.
|
2015-02-08 19:43:50 -05:00
|
|
|
*/
|
2015-02-09 11:01:29 -05:00
|
|
|
removePlayer: function(t) {
|
|
|
|
var featureIndex, feature;
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-09 11:01:29 -05:00
|
|
|
if ( ! t.options ) {
|
|
|
|
return;
|
|
|
|
}
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-09 11:01:29 -05:00
|
|
|
// invoke features cleanup
|
|
|
|
for ( featureIndex in t.options.features ) {
|
|
|
|
feature = t.options.features[featureIndex];
|
|
|
|
if ( t['clean' + feature] ) {
|
|
|
|
try {
|
|
|
|
t['clean' + feature](t);
|
|
|
|
} catch (e) {}
|
2015-02-08 19:43:50 -05:00
|
|
|
}
|
2015-02-09 11:01:29 -05:00
|
|
|
}
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-09 11:01:29 -05:00
|
|
|
if ( ! t.isDynamic ) {
|
|
|
|
t.$node.remove();
|
|
|
|
}
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-09 11:01:29 -05:00
|
|
|
if ( 'native' !== t.media.pluginType ) {
|
2015-02-09 13:45:26 -05:00
|
|
|
t.$media.remove();
|
2015-02-09 11:01:29 -05:00
|
|
|
}
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-09 11:01:29 -05:00
|
|
|
delete window.mejs.players[t.id];
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-09 11:01:29 -05:00
|
|
|
t.container.remove();
|
|
|
|
t.globalUnbind();
|
|
|
|
delete t.node.player;
|
|
|
|
},
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-09 11:01:29 -05:00
|
|
|
/**
|
|
|
|
* Allows any class that has set 'player' to a MediaElementPlayer
|
|
|
|
* instance to remove the player when listening to events.
|
|
|
|
*
|
|
|
|
* Examples: modal closes, shortcode properties are removed, etc.
|
|
|
|
*/
|
|
|
|
unsetPlayers : function() {
|
|
|
|
if ( this.players && this.players.length ) {
|
|
|
|
_.each( this.players, function (player) {
|
|
|
|
player.pause();
|
|
|
|
wp.media.mixin.removePlayer( player );
|
|
|
|
} );
|
|
|
|
this.players = [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-09 11:01:29 -05:00
|
|
|
/**
|
|
|
|
* Autowire "collection"-type shortcodes
|
|
|
|
*/
|
|
|
|
wp.media.playlist = new wp.media.collection({
|
|
|
|
tag: 'playlist',
|
|
|
|
editTitle : l10n.editPlaylistTitle,
|
|
|
|
defaults : {
|
|
|
|
id: wp.media.view.settings.post.id,
|
|
|
|
style: 'light',
|
|
|
|
tracklist: true,
|
|
|
|
tracknumbers: true,
|
|
|
|
images: true,
|
|
|
|
artists: true,
|
|
|
|
type: 'audio'
|
|
|
|
}
|
|
|
|
});
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-09 11:01:29 -05:00
|
|
|
/**
|
|
|
|
* Shortcode modeling for audio
|
|
|
|
* `edit()` prepares the shortcode for the media modal
|
|
|
|
* `shortcode()` builds the new shortcode after update
|
|
|
|
*
|
|
|
|
* @namespace
|
|
|
|
*/
|
|
|
|
wp.media.audio = {
|
|
|
|
coerce : wp.media.coerce,
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-09 11:01:29 -05:00
|
|
|
defaults : {
|
|
|
|
id : wp.media.view.settings.post.id,
|
|
|
|
src : '',
|
|
|
|
loop : false,
|
|
|
|
autoplay : false,
|
|
|
|
preload : 'none',
|
|
|
|
width : 400
|
|
|
|
},
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-09 11:01:29 -05:00
|
|
|
edit : function( data ) {
|
|
|
|
var frame, shortcode = wp.shortcode.next( 'audio', data ).shortcode;
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-09 11:01:29 -05:00
|
|
|
frame = wp.media({
|
|
|
|
frame: 'audio',
|
|
|
|
state: 'audio-details',
|
|
|
|
metadata: _.defaults( shortcode.attrs.named, this.defaults )
|
|
|
|
});
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-09 11:01:29 -05:00
|
|
|
return frame;
|
|
|
|
},
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-09 11:01:29 -05:00
|
|
|
shortcode : function( model ) {
|
|
|
|
var content;
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-09 11:01:29 -05:00
|
|
|
_.each( this.defaults, function( value, key ) {
|
|
|
|
model[ key ] = this.coerce( model, key );
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-09 11:01:29 -05:00
|
|
|
if ( value === model[ key ] ) {
|
|
|
|
delete model[ key ];
|
|
|
|
}
|
|
|
|
}, this );
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-09 11:01:29 -05:00
|
|
|
content = model.content;
|
|
|
|
delete model.content;
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-09 11:01:29 -05:00
|
|
|
return new wp.shortcode({
|
|
|
|
tag: 'audio',
|
|
|
|
attrs: model,
|
|
|
|
content: content
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-09 11:01:29 -05:00
|
|
|
/**
|
|
|
|
* Shortcode modeling for video
|
|
|
|
* `edit()` prepares the shortcode for the media modal
|
|
|
|
* `shortcode()` builds the new shortcode after update
|
|
|
|
*
|
|
|
|
* @namespace
|
|
|
|
*/
|
|
|
|
wp.media.video = {
|
|
|
|
coerce : wp.media.coerce,
|
|
|
|
|
|
|
|
defaults : {
|
|
|
|
id : wp.media.view.settings.post.id,
|
|
|
|
src : '',
|
|
|
|
poster : '',
|
|
|
|
loop : false,
|
|
|
|
autoplay : false,
|
|
|
|
preload : 'metadata',
|
|
|
|
content : '',
|
|
|
|
width : 640,
|
|
|
|
height : 360
|
|
|
|
},
|
|
|
|
|
|
|
|
edit : function( data ) {
|
|
|
|
var frame,
|
|
|
|
shortcode = wp.shortcode.next( 'video', data ).shortcode,
|
|
|
|
attrs;
|
|
|
|
|
|
|
|
attrs = shortcode.attrs.named;
|
|
|
|
attrs.content = shortcode.content;
|
|
|
|
|
|
|
|
frame = wp.media({
|
|
|
|
frame: 'video',
|
|
|
|
state: 'video-details',
|
|
|
|
metadata: _.defaults( attrs, this.defaults )
|
|
|
|
});
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-09 11:01:29 -05:00
|
|
|
return frame;
|
|
|
|
},
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-09 11:01:29 -05:00
|
|
|
shortcode : function( model ) {
|
|
|
|
var content;
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-09 11:01:29 -05:00
|
|
|
_.each( this.defaults, function( value, key ) {
|
|
|
|
model[ key ] = this.coerce( model, key );
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-09 11:01:29 -05:00
|
|
|
if ( value === model[ key ] ) {
|
|
|
|
delete model[ key ];
|
|
|
|
}
|
|
|
|
}, this );
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-09 11:01:29 -05:00
|
|
|
content = model.content;
|
|
|
|
delete model.content;
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-09 11:01:29 -05:00
|
|
|
return new wp.shortcode({
|
|
|
|
tag: 'video',
|
|
|
|
attrs: model,
|
|
|
|
content: content
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-09 11:01:29 -05:00
|
|
|
media.model.PostMedia = require( './models/post-media.js' );
|
|
|
|
media.controller.AudioDetails = require( './controllers/audio-details.js' );
|
|
|
|
media.controller.VideoDetails = require( './controllers/video-details.js' );
|
|
|
|
media.view.MediaFrame.MediaDetails = require( './views/frame/media-details.js' );
|
|
|
|
media.view.MediaFrame.AudioDetails = require( './views/frame/audio-details.js' );
|
|
|
|
media.view.MediaFrame.VideoDetails = require( './views/frame/video-details.js' );
|
|
|
|
media.view.MediaDetails = require( './views/media-details.js' );
|
|
|
|
media.view.AudioDetails = require( './views/audio-details.js' );
|
|
|
|
media.view.VideoDetails = require( './views/video-details.js' );
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
},{"./controllers/audio-details.js":2,"./controllers/video-details.js":3,"./models/post-media.js":4,"./views/audio-details.js":5,"./views/frame/audio-details.js":6,"./views/frame/media-details.js":7,"./views/frame/video-details.js":8,"./views/media-details.js":9,"./views/video-details.js":10}],2:[function(require,module,exports){
|
2015-02-08 19:43:50 -05:00
|
|
|
/**
|
2015-02-22 01:56:27 -05:00
|
|
|
* wp.media.controller.AudioDetails
|
|
|
|
*
|
2015-02-08 19:43:50 -05:00
|
|
|
* The controller for the Audio Details state
|
|
|
|
*
|
2015-02-22 01:28:26 -05:00
|
|
|
* @class
|
2015-02-08 19:43:50 -05:00
|
|
|
* @augments wp.media.controller.State
|
|
|
|
* @augments Backbone.Model
|
|
|
|
*/
|
2015-02-22 03:29:25 -05:00
|
|
|
var State = wp.media.controller.State,
|
2015-02-08 19:43:50 -05:00
|
|
|
l10n = wp.media.view.l10n,
|
|
|
|
AudioDetails;
|
|
|
|
|
|
|
|
AudioDetails = State.extend({
|
|
|
|
defaults: {
|
|
|
|
id: 'audio-details',
|
|
|
|
toolbar: 'audio-details',
|
|
|
|
title: l10n.audioDetailsTitle,
|
|
|
|
content: 'audio-details',
|
|
|
|
menu: 'audio-details',
|
|
|
|
router: false,
|
|
|
|
priority: 60
|
|
|
|
},
|
|
|
|
|
|
|
|
initialize: function( options ) {
|
|
|
|
this.media = options.media;
|
|
|
|
State.prototype.initialize.apply( this, arguments );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = AudioDetails;
|
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
},{}],3:[function(require,module,exports){
|
2015-02-08 19:43:50 -05:00
|
|
|
/**
|
2015-02-22 03:29:25 -05:00
|
|
|
* wp.media.controller.VideoDetails
|
2015-02-08 19:43:50 -05:00
|
|
|
*
|
2015-02-22 03:29:25 -05:00
|
|
|
* The controller for the Video Details state
|
2015-02-08 19:43:50 -05:00
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @augments wp.media.controller.State
|
|
|
|
* @augments Backbone.Model
|
|
|
|
*/
|
2015-02-22 03:29:25 -05:00
|
|
|
var State = wp.media.controller.State,
|
2015-02-08 19:43:50 -05:00
|
|
|
l10n = wp.media.view.l10n,
|
2015-02-22 03:29:25 -05:00
|
|
|
VideoDetails;
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
VideoDetails = State.extend({
|
2015-02-08 19:43:50 -05:00
|
|
|
defaults: {
|
2015-02-22 03:29:25 -05:00
|
|
|
id: 'video-details',
|
|
|
|
toolbar: 'video-details',
|
|
|
|
title: l10n.videoDetailsTitle,
|
|
|
|
content: 'video-details',
|
|
|
|
menu: 'video-details',
|
|
|
|
router: false,
|
|
|
|
priority: 60
|
2015-02-08 19:43:50 -05:00
|
|
|
},
|
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
initialize: function( options ) {
|
|
|
|
this.media = options.media;
|
|
|
|
State.prototype.initialize.apply( this, arguments );
|
|
|
|
}
|
|
|
|
});
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
module.exports = VideoDetails;
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
},{}],4:[function(require,module,exports){
|
|
|
|
/**
|
|
|
|
* wp.media.model.PostMedia
|
|
|
|
*
|
|
|
|
* Shared model class for audio and video. Updates the model after
|
|
|
|
* "Add Audio|Video Source" and "Replace Audio|Video" states return
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @augments Backbone.Model
|
|
|
|
*/
|
|
|
|
var PostMedia = Backbone.Model.extend({
|
|
|
|
initialize: function() {
|
|
|
|
this.attachment = false;
|
2015-02-08 19:43:50 -05:00
|
|
|
},
|
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
setSource: function( attachment ) {
|
|
|
|
this.attachment = attachment;
|
|
|
|
this.extension = attachment.get( 'filename' ).split('.').pop();
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
if ( this.get( 'src' ) && this.extension === this.get( 'src' ).split('.').pop() ) {
|
|
|
|
this.unset( 'src' );
|
|
|
|
}
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
if ( _.contains( wp.media.view.settings.embedExts, this.extension ) ) {
|
|
|
|
this.set( this.extension, this.attachment.get( 'url' ) );
|
|
|
|
} else {
|
|
|
|
this.unset( this.extension );
|
2015-02-08 19:43:50 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
changeAttachment: function( attachment ) {
|
|
|
|
this.setSource( attachment );
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
this.unset( 'src' );
|
|
|
|
_.each( _.without( wp.media.view.settings.embedExts, this.extension ), function( ext ) {
|
|
|
|
this.unset( ext );
|
|
|
|
}, this );
|
|
|
|
}
|
|
|
|
});
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
module.exports = PostMedia;
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
},{}],5:[function(require,module,exports){
|
|
|
|
/**
|
|
|
|
* wp.media.view.AudioDetails
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @augments wp.media.view.MediaDetails
|
|
|
|
* @augments wp.media.view.Settings.AttachmentDisplay
|
|
|
|
* @augments wp.media.view.Settings
|
|
|
|
* @augments wp.media.View
|
|
|
|
* @augments wp.Backbone.View
|
|
|
|
* @augments Backbone.View
|
|
|
|
*/
|
2015-03-30 22:03:29 -04:00
|
|
|
var MediaDetails = wp.media.view.MediaDetails,
|
2015-02-22 03:29:25 -05:00
|
|
|
AudioDetails;
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
AudioDetails = MediaDetails.extend({
|
|
|
|
className: 'audio-details',
|
|
|
|
template: wp.template('audio-details'),
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
setMedia: function() {
|
|
|
|
var audio = this.$('.wp-audio-shortcode');
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
if ( audio.find( 'source' ).length ) {
|
|
|
|
if ( audio.is(':hidden') ) {
|
|
|
|
audio.show();
|
|
|
|
}
|
|
|
|
this.media = MediaDetails.prepareSrc( audio.get(0) );
|
|
|
|
} else {
|
|
|
|
audio.hide();
|
|
|
|
this.media = false;
|
2015-02-08 19:43:50 -05:00
|
|
|
}
|
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
});
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
module.exports = AudioDetails;
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-03-30 22:03:29 -04:00
|
|
|
},{}],6:[function(require,module,exports){
|
2015-02-22 03:29:25 -05:00
|
|
|
/**
|
|
|
|
* wp.media.view.MediaFrame.AudioDetails
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @augments wp.media.view.MediaFrame.MediaDetails
|
|
|
|
* @augments wp.media.view.MediaFrame.Select
|
|
|
|
* @augments wp.media.view.MediaFrame
|
|
|
|
* @augments wp.media.view.Frame
|
|
|
|
* @augments wp.media.View
|
|
|
|
* @augments wp.Backbone.View
|
|
|
|
* @augments Backbone.View
|
|
|
|
* @mixes wp.media.controller.StateMachine
|
|
|
|
*/
|
|
|
|
var MediaDetails = wp.media.view.MediaFrame.MediaDetails,
|
|
|
|
MediaLibrary = wp.media.controller.MediaLibrary,
|
2015-03-30 22:03:29 -04:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
l10n = wp.media.view.l10n,
|
|
|
|
AudioDetails;
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
AudioDetails = MediaDetails.extend({
|
|
|
|
defaults: {
|
|
|
|
id: 'audio',
|
|
|
|
url: '',
|
|
|
|
menu: 'audio-details',
|
|
|
|
content: 'audio-details',
|
|
|
|
toolbar: 'audio-details',
|
|
|
|
type: 'link',
|
|
|
|
title: l10n.audioDetailsTitle,
|
|
|
|
priority: 120
|
2015-02-08 19:43:50 -05:00
|
|
|
},
|
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
initialize: function( options ) {
|
2015-03-30 22:03:29 -04:00
|
|
|
options.DetailsView = wp.media.view.AudioDetails;
|
2015-02-22 03:29:25 -05:00
|
|
|
options.cancelText = l10n.audioDetailsCancel;
|
|
|
|
options.addText = l10n.audioAddSourceTitle;
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
MediaDetails.prototype.initialize.call( this, options );
|
|
|
|
},
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
bindHandlers: function() {
|
|
|
|
MediaDetails.prototype.bindHandlers.apply( this, arguments );
|
|
|
|
|
|
|
|
this.on( 'toolbar:render:replace-audio', this.renderReplaceToolbar, this );
|
|
|
|
this.on( 'toolbar:render:add-audio-source', this.renderAddSourceToolbar, this );
|
2015-02-08 19:43:50 -05:00
|
|
|
},
|
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
createStates: function() {
|
|
|
|
this.states.add([
|
2015-03-30 22:03:29 -04:00
|
|
|
new wp.media.controller.AudioDetails( {
|
2015-02-22 03:29:25 -05:00
|
|
|
media: this.media
|
|
|
|
} ),
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
new MediaLibrary( {
|
|
|
|
type: 'audio',
|
|
|
|
id: 'replace-audio',
|
|
|
|
title: l10n.audioReplaceTitle,
|
|
|
|
toolbar: 'replace-audio',
|
|
|
|
media: this.media,
|
|
|
|
menu: 'audio-details'
|
|
|
|
} ),
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
new MediaLibrary( {
|
|
|
|
type: 'audio',
|
|
|
|
id: 'add-audio-source',
|
|
|
|
title: l10n.audioAddSourceTitle,
|
|
|
|
toolbar: 'add-audio-source',
|
|
|
|
media: this.media,
|
|
|
|
menu: false
|
|
|
|
} )
|
|
|
|
]);
|
2015-02-08 19:43:50 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
module.exports = AudioDetails;
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-03-30 22:03:29 -04:00
|
|
|
},{}],7:[function(require,module,exports){
|
2015-02-08 19:43:50 -05:00
|
|
|
/**
|
2015-02-22 03:29:25 -05:00
|
|
|
* wp.media.view.MediaFrame.MediaDetails
|
2015-02-08 19:43:50 -05:00
|
|
|
*
|
|
|
|
* @class
|
2015-02-22 03:29:25 -05:00
|
|
|
* @augments wp.media.view.MediaFrame.Select
|
|
|
|
* @augments wp.media.view.MediaFrame
|
|
|
|
* @augments wp.media.view.Frame
|
|
|
|
* @augments wp.media.View
|
|
|
|
* @augments wp.Backbone.View
|
|
|
|
* @augments Backbone.View
|
|
|
|
* @mixes wp.media.controller.StateMachine
|
2015-02-08 19:43:50 -05:00
|
|
|
*/
|
2015-03-30 22:03:29 -04:00
|
|
|
var Select = wp.media.view.MediaFrame.Select,
|
2015-02-22 03:29:25 -05:00
|
|
|
l10n = wp.media.view.l10n,
|
|
|
|
MediaDetails;
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
MediaDetails = Select.extend({
|
|
|
|
defaults: {
|
|
|
|
id: 'media',
|
|
|
|
url: '',
|
|
|
|
menu: 'media-details',
|
|
|
|
content: 'media-details',
|
|
|
|
toolbar: 'media-details',
|
|
|
|
type: 'link',
|
|
|
|
priority: 120
|
|
|
|
},
|
2015-02-08 19:43:50 -05:00
|
|
|
|
|
|
|
initialize: function( options ) {
|
2015-02-22 03:29:25 -05:00
|
|
|
this.DetailsView = options.DetailsView;
|
|
|
|
this.cancelText = options.cancelText;
|
|
|
|
this.addText = options.addText;
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
this.media = new wp.media.model.PostMedia( options.metadata );
|
|
|
|
this.options.selection = new wp.media.model.Selection( this.media.attachment, { multiple: false } );
|
|
|
|
Select.prototype.initialize.apply( this, arguments );
|
2015-02-08 19:43:50 -05:00
|
|
|
},
|
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
bindHandlers: function() {
|
|
|
|
var menu = this.defaults.menu;
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
Select.prototype.bindHandlers.apply( this, arguments );
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
this.on( 'menu:create:' + menu, this.createMenu, this );
|
|
|
|
this.on( 'content:render:' + menu, this.renderDetailsContent, this );
|
|
|
|
this.on( 'menu:render:' + menu, this.renderMenu, this );
|
|
|
|
this.on( 'toolbar:render:' + menu, this.renderDetailsToolbar, this );
|
|
|
|
},
|
2015-02-22 01:56:27 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
renderDetailsContent: function() {
|
|
|
|
var view = new this.DetailsView({
|
|
|
|
controller: this,
|
|
|
|
model: this.state().media,
|
|
|
|
attachment: this.state().media.attachment
|
|
|
|
}).render();
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
this.content.set( view );
|
2015-02-08 19:43:50 -05:00
|
|
|
},
|
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
renderMenu: function( view ) {
|
|
|
|
var lastState = this.lastState(),
|
|
|
|
previous = lastState && lastState.id,
|
|
|
|
frame = this;
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
view.set({
|
|
|
|
cancel: {
|
|
|
|
text: this.cancelText,
|
|
|
|
priority: 20,
|
|
|
|
click: function() {
|
|
|
|
if ( previous ) {
|
|
|
|
frame.setState( previous );
|
|
|
|
} else {
|
|
|
|
frame.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2015-03-30 22:03:29 -04:00
|
|
|
separateCancel: new wp.media.View({
|
2015-02-22 03:29:25 -05:00
|
|
|
className: 'separator',
|
|
|
|
priority: 40
|
|
|
|
})
|
|
|
|
});
|
2015-02-08 19:43:50 -05:00
|
|
|
|
|
|
|
},
|
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
setPrimaryButton: function(text, handler) {
|
2015-03-30 22:03:29 -04:00
|
|
|
this.toolbar.set( new wp.media.view.Toolbar({
|
2015-02-22 03:29:25 -05:00
|
|
|
controller: this,
|
|
|
|
items: {
|
|
|
|
button: {
|
|
|
|
style: 'primary',
|
|
|
|
text: text,
|
|
|
|
priority: 80,
|
|
|
|
click: function() {
|
|
|
|
var controller = this.controller;
|
|
|
|
handler.call( this, controller, controller.state() );
|
|
|
|
// Restore and reset the default state.
|
|
|
|
controller.setState( controller.options.state );
|
|
|
|
controller.reset();
|
|
|
|
}
|
|
|
|
}
|
2015-02-08 19:43:50 -05:00
|
|
|
}
|
2015-02-22 03:29:25 -05:00
|
|
|
}) );
|
2015-02-08 19:43:50 -05:00
|
|
|
},
|
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
renderDetailsToolbar: function() {
|
|
|
|
this.setPrimaryButton( l10n.update, function( controller, state ) {
|
|
|
|
controller.close();
|
|
|
|
state.trigger( 'update', controller.media.toJSON() );
|
|
|
|
} );
|
2015-02-08 19:43:50 -05:00
|
|
|
},
|
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
renderReplaceToolbar: function() {
|
|
|
|
this.setPrimaryButton( l10n.replace, function( controller, state ) {
|
|
|
|
var attachment = state.get( 'selection' ).single();
|
|
|
|
controller.media.changeAttachment( attachment );
|
|
|
|
state.trigger( 'replace', controller.media.toJSON() );
|
|
|
|
} );
|
|
|
|
},
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
renderAddSourceToolbar: function() {
|
|
|
|
this.setPrimaryButton( this.addText, function( controller, state ) {
|
|
|
|
var attachment = state.get( 'selection' ).single();
|
|
|
|
controller.media.setSource( attachment );
|
|
|
|
state.trigger( 'add-source', controller.media.toJSON() );
|
|
|
|
} );
|
2015-02-08 19:43:50 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
module.exports = MediaDetails;
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
},{}],8:[function(require,module,exports){
|
2015-02-08 19:43:50 -05:00
|
|
|
/**
|
2015-02-22 03:29:25 -05:00
|
|
|
* wp.media.view.MediaFrame.VideoDetails
|
2015-02-08 19:43:50 -05:00
|
|
|
*
|
|
|
|
* @class
|
2015-02-22 03:29:25 -05:00
|
|
|
* @augments wp.media.view.MediaFrame.MediaDetails
|
|
|
|
* @augments wp.media.view.MediaFrame.Select
|
|
|
|
* @augments wp.media.view.MediaFrame
|
|
|
|
* @augments wp.media.view.Frame
|
2015-02-08 19:43:50 -05:00
|
|
|
* @augments wp.media.View
|
|
|
|
* @augments wp.Backbone.View
|
|
|
|
* @augments Backbone.View
|
2015-02-22 03:29:25 -05:00
|
|
|
* @mixes wp.media.controller.StateMachine
|
2015-02-08 19:43:50 -05:00
|
|
|
*/
|
2015-02-22 03:29:25 -05:00
|
|
|
var MediaDetails = wp.media.view.MediaFrame.MediaDetails,
|
|
|
|
MediaLibrary = wp.media.controller.MediaLibrary,
|
2015-02-08 19:43:50 -05:00
|
|
|
l10n = wp.media.view.l10n,
|
2015-02-22 03:29:25 -05:00
|
|
|
VideoDetails;
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
VideoDetails = MediaDetails.extend({
|
|
|
|
defaults: {
|
|
|
|
id: 'video',
|
|
|
|
url: '',
|
|
|
|
menu: 'video-details',
|
|
|
|
content: 'video-details',
|
|
|
|
toolbar: 'video-details',
|
|
|
|
type: 'link',
|
|
|
|
title: l10n.videoDetailsTitle,
|
|
|
|
priority: 120
|
2015-02-08 19:43:50 -05:00
|
|
|
},
|
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
initialize: function( options ) {
|
2015-03-30 22:03:29 -04:00
|
|
|
options.DetailsView = wp.media.view.VideoDetails;
|
2015-02-22 03:29:25 -05:00
|
|
|
options.cancelText = l10n.videoDetailsCancel;
|
|
|
|
options.addText = l10n.videoAddSourceTitle;
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
MediaDetails.prototype.initialize.call( this, options );
|
2015-02-08 19:43:50 -05:00
|
|
|
},
|
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
bindHandlers: function() {
|
|
|
|
MediaDetails.prototype.bindHandlers.apply( this, arguments );
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
this.on( 'toolbar:render:replace-video', this.renderReplaceToolbar, this );
|
|
|
|
this.on( 'toolbar:render:add-video-source', this.renderAddSourceToolbar, this );
|
|
|
|
this.on( 'toolbar:render:select-poster-image', this.renderSelectPosterImageToolbar, this );
|
|
|
|
this.on( 'toolbar:render:add-track', this.renderAddTrackToolbar, this );
|
2015-02-08 19:43:50 -05:00
|
|
|
},
|
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
createStates: function() {
|
|
|
|
this.states.add([
|
2015-03-30 22:03:29 -04:00
|
|
|
new wp.media.controller.VideoDetails({
|
2015-02-22 03:29:25 -05:00
|
|
|
media: this.media
|
|
|
|
}),
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
new MediaLibrary( {
|
|
|
|
type: 'video',
|
|
|
|
id: 'replace-video',
|
|
|
|
title: l10n.videoReplaceTitle,
|
|
|
|
toolbar: 'replace-video',
|
|
|
|
media: this.media,
|
|
|
|
menu: 'video-details'
|
|
|
|
} ),
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
new MediaLibrary( {
|
|
|
|
type: 'video',
|
|
|
|
id: 'add-video-source',
|
|
|
|
title: l10n.videoAddSourceTitle,
|
|
|
|
toolbar: 'add-video-source',
|
|
|
|
media: this.media,
|
|
|
|
menu: false
|
|
|
|
} ),
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
new MediaLibrary( {
|
|
|
|
type: 'image',
|
|
|
|
id: 'select-poster-image',
|
|
|
|
title: l10n.videoSelectPosterImageTitle,
|
|
|
|
toolbar: 'select-poster-image',
|
|
|
|
media: this.media,
|
|
|
|
menu: 'video-details'
|
|
|
|
} ),
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
new MediaLibrary( {
|
|
|
|
type: 'text',
|
|
|
|
id: 'add-track',
|
|
|
|
title: l10n.videoAddTrackTitle,
|
|
|
|
toolbar: 'add-track',
|
|
|
|
media: this.media,
|
|
|
|
menu: 'video-details'
|
|
|
|
} )
|
|
|
|
]);
|
|
|
|
},
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
renderSelectPosterImageToolbar: function() {
|
|
|
|
this.setPrimaryButton( l10n.videoSelectPosterImageTitle, function( controller, state ) {
|
|
|
|
var urls = [], attachment = state.get( 'selection' ).single();
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
controller.media.set( 'poster', attachment.get( 'url' ) );
|
|
|
|
state.trigger( 'set-poster-image', controller.media.toJSON() );
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
_.each( wp.media.view.settings.embedExts, function (ext) {
|
|
|
|
if ( controller.media.get( ext ) ) {
|
|
|
|
urls.push( controller.media.get( ext ) );
|
|
|
|
}
|
|
|
|
} );
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
wp.ajax.send( 'set-attachment-thumbnail', {
|
|
|
|
data : {
|
|
|
|
urls: urls,
|
|
|
|
thumbnail_id: attachment.get( 'id' )
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
} );
|
2015-02-08 19:43:50 -05:00
|
|
|
},
|
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
renderAddTrackToolbar: function() {
|
|
|
|
this.setPrimaryButton( l10n.videoAddTrackTitle, function( controller, state ) {
|
|
|
|
var attachment = state.get( 'selection' ).single(),
|
|
|
|
content = controller.media.get( 'content' );
|
2015-02-22 02:25:27 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
if ( -1 === content.indexOf( attachment.get( 'url' ) ) ) {
|
|
|
|
content += [
|
2015-06-01 14:09:26 -04:00
|
|
|
'<track srclang="en" label="English" kind="subtitles" src="',
|
2015-02-22 03:29:25 -05:00
|
|
|
attachment.get( 'url' ),
|
|
|
|
'" />'
|
|
|
|
].join('');
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
controller.media.set( 'content', content );
|
|
|
|
}
|
|
|
|
state.trigger( 'add-track', controller.media.toJSON() );
|
|
|
|
} );
|
|
|
|
}
|
2015-02-08 19:43:50 -05:00
|
|
|
});
|
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
module.exports = VideoDetails;
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-03-30 22:03:29 -04:00
|
|
|
},{}],9:[function(require,module,exports){
|
2015-07-20 19:39:24 -04:00
|
|
|
/* global MediaElementPlayer */
|
2015-02-22 01:56:27 -05:00
|
|
|
|
2015-02-08 19:43:50 -05:00
|
|
|
/**
|
2015-02-22 03:29:25 -05:00
|
|
|
* wp.media.view.MediaDetails
|
2015-02-08 19:43:50 -05:00
|
|
|
*
|
|
|
|
* @class
|
2015-02-22 03:29:25 -05:00
|
|
|
* @augments wp.media.view.Settings.AttachmentDisplay
|
|
|
|
* @augments wp.media.view.Settings
|
2015-02-08 19:43:50 -05:00
|
|
|
* @augments wp.media.View
|
|
|
|
* @augments wp.Backbone.View
|
|
|
|
* @augments Backbone.View
|
|
|
|
*/
|
2015-02-22 03:29:25 -05:00
|
|
|
var AttachmentDisplay = wp.media.view.Settings.AttachmentDisplay,
|
|
|
|
$ = jQuery,
|
|
|
|
MediaDetails;
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
MediaDetails = AttachmentDisplay.extend({
|
2015-02-08 19:43:50 -05:00
|
|
|
initialize: function() {
|
2015-02-22 03:29:25 -05:00
|
|
|
_.bindAll(this, 'success');
|
|
|
|
this.players = [];
|
|
|
|
this.listenTo( this.controller, 'close', wp.media.mixin.unsetPlayers );
|
|
|
|
this.on( 'ready', this.setPlayer );
|
|
|
|
this.on( 'media:setting:remove', wp.media.mixin.unsetPlayers, this );
|
|
|
|
this.on( 'media:setting:remove', this.render );
|
|
|
|
this.on( 'media:setting:remove', this.setPlayer );
|
2016-02-17 10:22:26 -05:00
|
|
|
|
|
|
|
AttachmentDisplay.prototype.initialize.apply( this, arguments );
|
|
|
|
},
|
|
|
|
|
|
|
|
events: function(){
|
|
|
|
return _.extend( {
|
2015-02-22 03:29:25 -05:00
|
|
|
'click .remove-setting' : 'removeSetting',
|
|
|
|
'change .content-track' : 'setTracks',
|
|
|
|
'click .remove-track' : 'setTracks',
|
|
|
|
'click .add-media-source' : 'addSource'
|
2016-02-17 10:22:26 -05:00
|
|
|
}, AttachmentDisplay.prototype.events );
|
2015-02-08 19:43:50 -05:00
|
|
|
},
|
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
prepare: function() {
|
|
|
|
return _.defaults({
|
|
|
|
model: this.model.toJSON()
|
|
|
|
}, this.options );
|
2015-02-08 19:43:50 -05:00
|
|
|
},
|
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
/**
|
|
|
|
* Remove a setting's UI when the model unsets it
|
|
|
|
*
|
|
|
|
* @fires wp.media.view.MediaDetails#media:setting:remove
|
|
|
|
*
|
|
|
|
* @param {Event} e
|
|
|
|
*/
|
|
|
|
removeSetting : function(e) {
|
|
|
|
var wrap = $( e.currentTarget ).parent(), setting;
|
|
|
|
setting = wrap.find( 'input' ).data( 'setting' );
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
if ( setting ) {
|
|
|
|
this.model.unset( setting );
|
|
|
|
this.trigger( 'media:setting:remove', this );
|
2015-02-08 19:43:50 -05:00
|
|
|
}
|
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
wrap.remove();
|
2015-02-08 19:43:50 -05:00
|
|
|
},
|
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @fires wp.media.view.MediaDetails#media:setting:remove
|
|
|
|
*/
|
|
|
|
setTracks : function() {
|
|
|
|
var tracks = '';
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
_.each( this.$('.content-track'), function(track) {
|
|
|
|
tracks += $( track ).val();
|
|
|
|
} );
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
this.model.set( 'content', tracks );
|
|
|
|
this.trigger( 'media:setting:remove', this );
|
2015-02-08 19:43:50 -05:00
|
|
|
},
|
2015-02-22 03:29:25 -05:00
|
|
|
|
|
|
|
addSource : function( e ) {
|
|
|
|
this.controller.lastMime = $( e.currentTarget ).data( 'mime' );
|
|
|
|
this.controller.setState( 'add-' + this.controller.defaults.id + '-source' );
|
2015-02-08 19:43:50 -05:00
|
|
|
},
|
2015-02-22 03:29:25 -05:00
|
|
|
|
|
|
|
loadPlayer: function () {
|
|
|
|
this.players.push( new MediaElementPlayer( this.media, this.settings ) );
|
|
|
|
this.scriptXhr = false;
|
2015-02-08 19:43:50 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2015-02-22 03:29:25 -05:00
|
|
|
* @global MediaElementPlayer
|
2015-02-08 19:43:50 -05:00
|
|
|
*/
|
2015-02-22 03:29:25 -05:00
|
|
|
setPlayer : function() {
|
2016-01-08 21:22:26 -05:00
|
|
|
var baseSettings, src;
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
if ( this.players.length || ! this.media || this.scriptXhr ) {
|
|
|
|
return;
|
2015-02-08 19:43:50 -05:00
|
|
|
}
|
|
|
|
|
2016-01-08 21:22:26 -05:00
|
|
|
src = this.model.get( 'src' );
|
|
|
|
|
|
|
|
if ( src && src.indexOf( 'vimeo' ) > -1 && ! ( 'Froogaloop' in window ) ) {
|
2015-02-22 03:29:25 -05:00
|
|
|
baseSettings = wp.media.mixin.mejsSettings;
|
|
|
|
this.scriptXhr = $.getScript( baseSettings.pluginPath + 'froogaloop.min.js', _.bind( this.loadPlayer, this ) );
|
|
|
|
} else {
|
|
|
|
this.loadPlayer();
|
2015-02-08 19:43:50 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
/**
|
|
|
|
* @abstract
|
|
|
|
*/
|
|
|
|
setMedia : function() {
|
|
|
|
return this;
|
2015-02-08 19:43:50 -05:00
|
|
|
},
|
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
success : function(mejs) {
|
|
|
|
var autoplay = mejs.attributes.autoplay && 'false' !== mejs.attributes.autoplay;
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
if ( 'flash' === mejs.pluginType && autoplay ) {
|
|
|
|
mejs.addEventListener( 'canplay', function() {
|
|
|
|
mejs.play();
|
|
|
|
}, false );
|
2015-02-08 19:43:50 -05:00
|
|
|
}
|
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
this.mejs = mejs;
|
2015-02-08 19:43:50 -05:00
|
|
|
},
|
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
/**
|
|
|
|
* @returns {media.view.MediaDetails} Returns itself to allow chaining
|
|
|
|
*/
|
|
|
|
render: function() {
|
|
|
|
AttachmentDisplay.prototype.render.apply( this, arguments );
|
|
|
|
|
|
|
|
setTimeout( _.bind( function() {
|
|
|
|
this.resetFocus();
|
|
|
|
}, this ), 10 );
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
this.settings = _.defaults( {
|
|
|
|
success : this.success
|
|
|
|
}, wp.media.mixin.mejsSettings );
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
return this.setMedia();
|
2015-02-08 19:43:50 -05:00
|
|
|
},
|
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
resetFocus: function() {
|
|
|
|
this.$( '.embed-media-settings' ).scrollTop( 0 );
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
instances : 0,
|
|
|
|
/**
|
|
|
|
* When multiple players in the DOM contain the same src, things get weird.
|
|
|
|
*
|
|
|
|
* @param {HTMLElement} elem
|
|
|
|
* @returns {HTMLElement}
|
|
|
|
*/
|
|
|
|
prepareSrc : function( elem ) {
|
|
|
|
var i = MediaDetails.instances++;
|
|
|
|
_.each( $( elem ).find( 'source' ), function( source ) {
|
|
|
|
source.src = [
|
|
|
|
source.src,
|
|
|
|
source.src.indexOf('?') > -1 ? '&' : '?',
|
|
|
|
'_=',
|
|
|
|
i
|
|
|
|
].join('');
|
|
|
|
} );
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
return elem;
|
2015-02-08 19:43:50 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
module.exports = MediaDetails;
|
2015-02-08 19:43:50 -05:00
|
|
|
|
2015-02-22 03:29:25 -05:00
|
|
|
},{}],10:[function(require,module,exports){
|
2015-02-08 19:43:50 -05:00
|
|
|
/**
|
|
|
|
* wp.media.view.VideoDetails
|
|
|
|
*
|
2015-02-22 01:28:26 -05:00
|
|
|
* @class
|
2015-02-08 19:43:50 -05:00
|
|
|
* @augments wp.media.view.MediaDetails
|
|
|
|
* @augments wp.media.view.Settings.AttachmentDisplay
|
|
|
|
* @augments wp.media.view.Settings
|
|
|
|
* @augments wp.media.View
|
|
|
|
* @augments wp.Backbone.View
|
|
|
|
* @augments Backbone.View
|
|
|
|
*/
|
2015-03-30 22:03:29 -04:00
|
|
|
var MediaDetails = wp.media.view.MediaDetails,
|
2015-02-08 19:43:50 -05:00
|
|
|
VideoDetails;
|
|
|
|
|
|
|
|
VideoDetails = MediaDetails.extend({
|
|
|
|
className: 'video-details',
|
|
|
|
template: wp.template('video-details'),
|
|
|
|
|
|
|
|
setMedia: function() {
|
|
|
|
var video = this.$('.wp-video-shortcode');
|
|
|
|
|
|
|
|
if ( video.find( 'source' ).length ) {
|
|
|
|
if ( video.is(':hidden') ) {
|
|
|
|
video.show();
|
|
|
|
}
|
|
|
|
|
2015-02-22 00:38:27 -05:00
|
|
|
if ( ! video.hasClass( 'youtube-video' ) && ! video.hasClass( 'vimeo-video' ) ) {
|
2015-02-08 19:43:50 -05:00
|
|
|
this.media = MediaDetails.prepareSrc( video.get(0) );
|
|
|
|
} else {
|
|
|
|
this.media = video.get(0);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
video.hide();
|
|
|
|
this.media = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = VideoDetails;
|
|
|
|
|
2015-03-30 22:03:29 -04:00
|
|
|
},{}]},{},[1]);
|