wp/wp-includes/js/media-audiovideo.js
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
     1 (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){
     1 /******/ (function(modules) { // webpackBootstrap
     2 /*globals wp, _ */
     2 /******/ 	// The module cache
       
     3 /******/ 	var installedModules = {};
       
     4 /******/
       
     5 /******/ 	// The require function
       
     6 /******/ 	function __webpack_require__(moduleId) {
       
     7 /******/
       
     8 /******/ 		// Check if module is in cache
       
     9 /******/ 		if(installedModules[moduleId]) {
       
    10 /******/ 			return installedModules[moduleId].exports;
       
    11 /******/ 		}
       
    12 /******/ 		// Create a new module (and put it into the cache)
       
    13 /******/ 		var module = installedModules[moduleId] = {
       
    14 /******/ 			i: moduleId,
       
    15 /******/ 			l: false,
       
    16 /******/ 			exports: {}
       
    17 /******/ 		};
       
    18 /******/
       
    19 /******/ 		// Execute the module function
       
    20 /******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
       
    21 /******/
       
    22 /******/ 		// Flag the module as loaded
       
    23 /******/ 		module.l = true;
       
    24 /******/
       
    25 /******/ 		// Return the exports of the module
       
    26 /******/ 		return module.exports;
       
    27 /******/ 	}
       
    28 /******/
       
    29 /******/
       
    30 /******/ 	// expose the modules object (__webpack_modules__)
       
    31 /******/ 	__webpack_require__.m = modules;
       
    32 /******/
       
    33 /******/ 	// expose the module cache
       
    34 /******/ 	__webpack_require__.c = installedModules;
       
    35 /******/
       
    36 /******/ 	// define getter function for harmony exports
       
    37 /******/ 	__webpack_require__.d = function(exports, name, getter) {
       
    38 /******/ 		if(!__webpack_require__.o(exports, name)) {
       
    39 /******/ 			Object.defineProperty(exports, name, {
       
    40 /******/ 				configurable: false,
       
    41 /******/ 				enumerable: true,
       
    42 /******/ 				get: getter
       
    43 /******/ 			});
       
    44 /******/ 		}
       
    45 /******/ 	};
       
    46 /******/
       
    47 /******/ 	// getDefaultExport function for compatibility with non-harmony modules
       
    48 /******/ 	__webpack_require__.n = function(module) {
       
    49 /******/ 		var getter = module && module.__esModule ?
       
    50 /******/ 			function getDefault() { return module['default']; } :
       
    51 /******/ 			function getModuleExports() { return module; };
       
    52 /******/ 		__webpack_require__.d(getter, 'a', getter);
       
    53 /******/ 		return getter;
       
    54 /******/ 	};
       
    55 /******/
       
    56 /******/ 	// Object.prototype.hasOwnProperty.call
       
    57 /******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
       
    58 /******/
       
    59 /******/ 	// __webpack_public_path__
       
    60 /******/ 	__webpack_require__.p = "";
       
    61 /******/
       
    62 /******/ 	// Load entry module and return exports
       
    63 /******/ 	return __webpack_require__(__webpack_require__.s = 0);
       
    64 /******/ })
       
    65 /************************************************************************/
       
    66 /******/ ([
       
    67 /* 0 */
       
    68 /***/ (function(module, exports, __webpack_require__) {
     3 
    69 
     4 var media = wp.media,
    70 var media = wp.media,
     5 	baseSettings = window._wpmejsSettings || {},
    71 	baseSettings = window._wpmejsSettings || {},
     6 	l10n = window._wpMediaViewsL10n || {};
    72 	l10n = window._wpMediaViewsL10n || {};
     7 
    73 
     8 /**
    74 /**
       
    75  *
       
    76  * @summary Defines the wp.media.mixin object.
       
    77  *
     9  * @mixin
    78  * @mixin
       
    79  *
       
    80  * @since 4.2.0
    10  */
    81  */
    11 wp.media.mixin = {
    82 wp.media.mixin = {
    12 	mejsSettings: baseSettings,
    83 	mejsSettings: baseSettings,
    13 
    84 
       
    85 	/**
       
    86 	 * @summary Pauses and removes all players.
       
    87 	 *
       
    88 	 * @since 4.2.0
       
    89 	 *
       
    90 	 * @return {void}
       
    91 	 */
    14 	removeAllPlayers: function() {
    92 	removeAllPlayers: function() {
    15 		var p;
    93 		var p;
    16 
    94 
    17 		if ( window.mejs && window.mejs.players ) {
    95 		if ( window.mejs && window.mejs.players ) {
    18 			for ( p in window.mejs.players ) {
    96 			for ( p in window.mejs.players ) {
    21 			}
    99 			}
    22 		}
   100 		}
    23 	},
   101 	},
    24 
   102 
    25 	/**
   103 	/**
       
   104 	 * @summary Removes the player.
       
   105 	 *
    26 	 * Override the MediaElement method for removing a player.
   106 	 * Override the MediaElement method for removing a player.
    27 	 *	MediaElement tries to pull the audio/video tag out of
   107 	 * MediaElement tries to pull the audio/video tag out of
    28 	 *	its container and re-add it to the DOM.
   108 	 * its container and re-add it to the DOM.
       
   109 	 *
       
   110 	 * @since 4.2.0
       
   111 	 *
       
   112 	 * @return {void}
    29 	 */
   113 	 */
    30 	removePlayer: function(t) {
   114 	removePlayer: function(t) {
    31 		var featureIndex, feature;
   115 		var featureIndex, feature;
    32 
   116 
    33 		if ( ! t.options ) {
   117 		if ( ! t.options ) {
    43 				} catch (e) {}
   127 				} catch (e) {}
    44 			}
   128 			}
    45 		}
   129 		}
    46 
   130 
    47 		if ( ! t.isDynamic ) {
   131 		if ( ! t.isDynamic ) {
    48 			t.$node.remove();
   132 			t.node.remove();
    49 		}
   133 		}
    50 
   134 
    51 		if ( 'native' !== t.media.pluginType ) {
   135 		if ( 'html5' !== t.media.rendererName ) {
    52 			t.$media.remove();
   136 			t.media.remove();
    53 		}
   137 		}
    54 
   138 
    55 		delete window.mejs.players[t.id];
   139 		delete window.mejs.players[t.id];
    56 
   140 
    57 		t.container.remove();
   141 		t.container.remove();
    58 		t.globalUnbind();
   142 		t.globalUnbind('resize', t.globalResizeCallback);
    59 		delete t.node.player;
   143 		t.globalUnbind('keydown', t.globalKeydownCallback);
       
   144 		t.globalUnbind('click', t.globalClickCallback);
       
   145 		delete t.media.player;
    60 	},
   146 	},
    61 
   147 
    62 	/**
   148 	/**
       
   149 	 *
       
   150 	 * @summary Removes and resets all players.
       
   151 	 *
    63 	 * Allows any class that has set 'player' to a MediaElementPlayer
   152 	 * Allows any class that has set 'player' to a MediaElementPlayer
    64 	 *  instance to remove the player when listening to events.
   153 	 * instance to remove the player when listening to events.
    65 	 *
   154 	 *
    66 	 *  Examples: modal closes, shortcode properties are removed, etc.
   155 	 * Examples: modal closes, shortcode properties are removed, etc.
       
   156 	 *
       
   157 	 * @since 4.2.0
    67 	 */
   158 	 */
    68 	unsetPlayers : function() {
   159 	unsetPlayers : function() {
    69 		if ( this.players && this.players.length ) {
   160 		if ( this.players && this.players.length ) {
    70 			_.each( this.players, function (player) {
   161 			_.each( this.players, function (player) {
    71 				player.pause();
   162 				player.pause();
    75 		}
   166 		}
    76 	}
   167 	}
    77 };
   168 };
    78 
   169 
    79 /**
   170 /**
    80  * Autowire "collection"-type shortcodes
   171  * @summary Shortcode modeling for playlists.
       
   172  *
       
   173  * @since 4.2.0
    81  */
   174  */
    82 wp.media.playlist = new wp.media.collection({
   175 wp.media.playlist = new wp.media.collection({
    83 	tag: 'playlist',
   176 	tag: 'playlist',
    84 	editTitle : l10n.editPlaylistTitle,
   177 	editTitle : l10n.editPlaylistTitle,
    85 	defaults : {
   178 	defaults : {
    92 		type: 'audio'
   185 		type: 'audio'
    93 	}
   186 	}
    94 });
   187 });
    95 
   188 
    96 /**
   189 /**
    97  * Shortcode modeling for audio
   190  * @summary Shortcode modeling for audio.
    98  *  `edit()` prepares the shortcode for the media modal
   191  *
    99  *  `shortcode()` builds the new shortcode after update
   192  * `edit()` prepares the shortcode for the media modal.
       
   193  * `shortcode()` builds the new shortcode after an update.
   100  *
   194  *
   101  * @namespace
   195  * @namespace
       
   196  *
       
   197  * @since 4.2.0
   102  */
   198  */
   103 wp.media.audio = {
   199 wp.media.audio = {
   104 	coerce : wp.media.coerce,
   200 	coerce : wp.media.coerce,
   105 
   201 
   106 	defaults : {
   202 	defaults : {
   110 		autoplay : false,
   206 		autoplay : false,
   111 		preload : 'none',
   207 		preload : 'none',
   112 		width : 400
   208 		width : 400
   113 	},
   209 	},
   114 
   210 
       
   211 	/**
       
   212 	 * @summary Instantiates a new media object with the next matching shortcode.
       
   213 	 *
       
   214 	 * @since 4.2.0
       
   215 	 *
       
   216 	 * @param {string} data The text to apply the shortcode on.
       
   217 	 * @returns {wp.media} The media object.
       
   218 	 */
   115 	edit : function( data ) {
   219 	edit : function( data ) {
   116 		var frame, shortcode = wp.shortcode.next( 'audio', data ).shortcode;
   220 		var frame, shortcode = wp.shortcode.next( 'audio', data ).shortcode;
   117 
   221 
   118 		frame = wp.media({
   222 		frame = wp.media({
   119 			frame: 'audio',
   223 			frame: 'audio',
   122 		});
   226 		});
   123 
   227 
   124 		return frame;
   228 		return frame;
   125 	},
   229 	},
   126 
   230 
       
   231 	/**
       
   232 	 * @summary Generates an audio shortcode.
       
   233 	 *
       
   234 	 * @since 4.2.0
       
   235 	 *
       
   236 	 * @param {Array} model Array with attributes for the shortcode.
       
   237 	 * @returns {wp.shortcode} The audio shortcode object.
       
   238 	 */
   127 	shortcode : function( model ) {
   239 	shortcode : function( model ) {
   128 		var content;
   240 		var content;
   129 
   241 
   130 		_.each( this.defaults, function( value, key ) {
   242 		_.each( this.defaults, function( value, key ) {
   131 			model[ key ] = this.coerce( model, key );
   243 			model[ key ] = this.coerce( model, key );
   145 		});
   257 		});
   146 	}
   258 	}
   147 };
   259 };
   148 
   260 
   149 /**
   261 /**
   150  * Shortcode modeling for video
   262  * @summary Shortcode modeling for video.
   151  *  `edit()` prepares the shortcode for the media modal
   263  *
   152  *  `shortcode()` builds the new shortcode after update
   264  *  `edit()` prepares the shortcode for the media modal.
       
   265  *  `shortcode()` builds the new shortcode after update.
       
   266  *
       
   267  * @since 4.2.0
   153  *
   268  *
   154  * @namespace
   269  * @namespace
   155  */
   270  */
   156 wp.media.video = {
   271 wp.media.video = {
   157 	coerce : wp.media.coerce,
   272 	coerce : wp.media.coerce,
   166 		content : '',
   281 		content : '',
   167 		width : 640,
   282 		width : 640,
   168 		height : 360
   283 		height : 360
   169 	},
   284 	},
   170 
   285 
       
   286 	/**
       
   287 	 * @summary Instantiates a new media object with the next matching shortcode.
       
   288 	 *
       
   289 	 * @since 4.2.0
       
   290 	 *
       
   291 	 * @param {string} data The text to apply the shortcode on.
       
   292 	 * @returns {wp.media} The media object.
       
   293 	 */
   171 	edit : function( data ) {
   294 	edit : function( data ) {
   172 		var frame,
   295 		var frame,
   173 			shortcode = wp.shortcode.next( 'video', data ).shortcode,
   296 			shortcode = wp.shortcode.next( 'video', data ).shortcode,
   174 			attrs;
   297 			attrs;
   175 
   298 
   183 		});
   306 		});
   184 
   307 
   185 		return frame;
   308 		return frame;
   186 	},
   309 	},
   187 
   310 
       
   311 	/**
       
   312 	 * @summary Generates an video shortcode.
       
   313 	 *
       
   314 	 * @since 4.2.0
       
   315 	 *
       
   316 	 * @param {Array} model Array with attributes for the shortcode.
       
   317 	 * @returns {wp.shortcode} The video shortcode object.
       
   318 	 */
   188 	shortcode : function( model ) {
   319 	shortcode : function( model ) {
   189 		var content;
   320 		var content;
   190 
   321 
   191 		_.each( this.defaults, function( value, key ) {
   322 		_.each( this.defaults, function( value, key ) {
   192 			model[ key ] = this.coerce( model, key );
   323 			model[ key ] = this.coerce( model, key );
   205 			content: content
   336 			content: content
   206 		});
   337 		});
   207 	}
   338 	}
   208 };
   339 };
   209 
   340 
   210 media.model.PostMedia = require( './models/post-media.js' );
   341 media.model.PostMedia = __webpack_require__( 1 );
   211 media.controller.AudioDetails = require( './controllers/audio-details.js' );
   342 media.controller.AudioDetails = __webpack_require__( 2 );
   212 media.controller.VideoDetails = require( './controllers/video-details.js' );
   343 media.controller.VideoDetails = __webpack_require__( 3 );
   213 media.view.MediaFrame.MediaDetails = require( './views/frame/media-details.js' );
   344 media.view.MediaFrame.MediaDetails = __webpack_require__( 4 );
   214 media.view.MediaFrame.AudioDetails = require( './views/frame/audio-details.js' );
   345 media.view.MediaFrame.AudioDetails = __webpack_require__( 5 );
   215 media.view.MediaFrame.VideoDetails = require( './views/frame/video-details.js' );
   346 media.view.MediaFrame.VideoDetails = __webpack_require__( 6 );
   216 media.view.MediaDetails = require( './views/media-details.js' );
   347 media.view.MediaDetails = __webpack_require__( 7 );
   217 media.view.AudioDetails = require( './views/audio-details.js' );
   348 media.view.AudioDetails = __webpack_require__( 8 );
   218 media.view.VideoDetails = require( './views/video-details.js' );
   349 media.view.VideoDetails = __webpack_require__( 9 );
   219 
   350 
   220 },{"./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){
   351 
   221 /*globals wp */
   352 /***/ }),
       
   353 /* 1 */
       
   354 /***/ (function(module, exports) {
       
   355 
       
   356 /**
       
   357  * wp.media.model.PostMedia
       
   358  *
       
   359  * Shared model class for audio and video. Updates the model after
       
   360  *   "Add Audio|Video Source" and "Replace Audio|Video" states return
       
   361  *
       
   362  * @memberOf wp.media.model
       
   363  *
       
   364  * @class
       
   365  * @augments Backbone.Model
       
   366  */
       
   367 var PostMedia = Backbone.Model.extend(/** @lends wp.media.model.PostMedia.prototype */{
       
   368 	initialize: function() {
       
   369 		this.attachment = false;
       
   370 	},
       
   371 
       
   372 	setSource: function( attachment ) {
       
   373 		this.attachment = attachment;
       
   374 		this.extension = attachment.get( 'filename' ).split('.').pop();
       
   375 
       
   376 		if ( this.get( 'src' ) && this.extension === this.get( 'src' ).split('.').pop() ) {
       
   377 			this.unset( 'src' );
       
   378 		}
       
   379 
       
   380 		if ( _.contains( wp.media.view.settings.embedExts, this.extension ) ) {
       
   381 			this.set( this.extension, this.attachment.get( 'url' ) );
       
   382 		} else {
       
   383 			this.unset( this.extension );
       
   384 		}
       
   385 	},
       
   386 
       
   387 	changeAttachment: function( attachment ) {
       
   388 		this.setSource( attachment );
       
   389 
       
   390 		this.unset( 'src' );
       
   391 		_.each( _.without( wp.media.view.settings.embedExts, this.extension ), function( ext ) {
       
   392 			this.unset( ext );
       
   393 		}, this );
       
   394 	}
       
   395 });
       
   396 
       
   397 module.exports = PostMedia;
       
   398 
       
   399 
       
   400 /***/ }),
       
   401 /* 2 */
       
   402 /***/ (function(module, exports) {
       
   403 
       
   404 var State = wp.media.controller.State,
       
   405 	l10n = wp.media.view.l10n,
       
   406 	AudioDetails;
   222 
   407 
   223 /**
   408 /**
   224  * wp.media.controller.AudioDetails
   409  * wp.media.controller.AudioDetails
   225  *
   410  *
   226  * The controller for the Audio Details state
   411  * The controller for the Audio Details state
       
   412  *
       
   413  * @memberOf wp.media.controller
   227  *
   414  *
   228  * @class
   415  * @class
   229  * @augments wp.media.controller.State
   416  * @augments wp.media.controller.State
   230  * @augments Backbone.Model
   417  * @augments Backbone.Model
   231  */
   418  */
   232 var State = wp.media.controller.State,
   419 AudioDetails = State.extend(/** @lends wp.media.controller.AudioDetails.prototype */{
   233 	l10n = wp.media.view.l10n,
       
   234 	AudioDetails;
       
   235 
       
   236 AudioDetails = State.extend({
       
   237 	defaults: {
   420 	defaults: {
   238 		id: 'audio-details',
   421 		id: 'audio-details',
   239 		toolbar: 'audio-details',
   422 		toolbar: 'audio-details',
   240 		title: l10n.audioDetailsTitle,
   423 		title: l10n.audioDetailsTitle,
   241 		content: 'audio-details',
   424 		content: 'audio-details',
   250 	}
   433 	}
   251 });
   434 });
   252 
   435 
   253 module.exports = AudioDetails;
   436 module.exports = AudioDetails;
   254 
   437 
   255 },{}],3:[function(require,module,exports){
   438 
   256 /*globals wp */
   439 /***/ }),
       
   440 /* 3 */
       
   441 /***/ (function(module, exports) {
   257 
   442 
   258 /**
   443 /**
   259  * wp.media.controller.VideoDetails
   444  * wp.media.controller.VideoDetails
   260  *
   445  *
   261  * The controller for the Video Details state
   446  * The controller for the Video Details state
       
   447  *
       
   448  * @memberOf wp.media.controller
   262  *
   449  *
   263  * @class
   450  * @class
   264  * @augments wp.media.controller.State
   451  * @augments wp.media.controller.State
   265  * @augments Backbone.Model
   452  * @augments Backbone.Model
   266  */
   453  */
   267 var State = wp.media.controller.State,
   454 var State = wp.media.controller.State,
   268 	l10n = wp.media.view.l10n,
   455 	l10n = wp.media.view.l10n,
   269 	VideoDetails;
   456 	VideoDetails;
   270 
   457 
   271 VideoDetails = State.extend({
   458 VideoDetails = State.extend(/** @lends wp.media.controller.VideoDetails.prototype */{
   272 	defaults: {
   459 	defaults: {
   273 		id: 'video-details',
   460 		id: 'video-details',
   274 		toolbar: 'video-details',
   461 		toolbar: 'video-details',
   275 		title: l10n.videoDetailsTitle,
   462 		title: l10n.videoDetailsTitle,
   276 		content: 'video-details',
   463 		content: 'video-details',
   285 	}
   472 	}
   286 });
   473 });
   287 
   474 
   288 module.exports = VideoDetails;
   475 module.exports = VideoDetails;
   289 
   476 
   290 },{}],4:[function(require,module,exports){
   477 
   291 /*globals wp, Backbone, _ */
   478 /***/ }),
   292 
   479 /* 4 */
   293 /**
   480 /***/ (function(module, exports) {
   294  * wp.media.model.PostMedia
   481 
   295  *
   482 var Select = wp.media.view.MediaFrame.Select,
   296  * Shared model class for audio and video. Updates the model after
       
   297  *   "Add Audio|Video Source" and "Replace Audio|Video" states return
       
   298  *
       
   299  * @class
       
   300  * @augments Backbone.Model
       
   301  */
       
   302 var PostMedia = Backbone.Model.extend({
       
   303 	initialize: function() {
       
   304 		this.attachment = false;
       
   305 	},
       
   306 
       
   307 	setSource: function( attachment ) {
       
   308 		this.attachment = attachment;
       
   309 		this.extension = attachment.get( 'filename' ).split('.').pop();
       
   310 
       
   311 		if ( this.get( 'src' ) && this.extension === this.get( 'src' ).split('.').pop() ) {
       
   312 			this.unset( 'src' );
       
   313 		}
       
   314 
       
   315 		if ( _.contains( wp.media.view.settings.embedExts, this.extension ) ) {
       
   316 			this.set( this.extension, this.attachment.get( 'url' ) );
       
   317 		} else {
       
   318 			this.unset( this.extension );
       
   319 		}
       
   320 	},
       
   321 
       
   322 	changeAttachment: function( attachment ) {
       
   323 		this.setSource( attachment );
       
   324 
       
   325 		this.unset( 'src' );
       
   326 		_.each( _.without( wp.media.view.settings.embedExts, this.extension ), function( ext ) {
       
   327 			this.unset( ext );
       
   328 		}, this );
       
   329 	}
       
   330 });
       
   331 
       
   332 module.exports = PostMedia;
       
   333 
       
   334 },{}],5:[function(require,module,exports){
       
   335 /*globals wp */
       
   336 
       
   337 /**
       
   338  * wp.media.view.AudioDetails
       
   339  *
       
   340  * @class
       
   341  * @augments wp.media.view.MediaDetails
       
   342  * @augments wp.media.view.Settings.AttachmentDisplay
       
   343  * @augments wp.media.view.Settings
       
   344  * @augments wp.media.View
       
   345  * @augments wp.Backbone.View
       
   346  * @augments Backbone.View
       
   347  */
       
   348 var MediaDetails = wp.media.view.MediaDetails,
       
   349 	AudioDetails;
       
   350 
       
   351 AudioDetails = MediaDetails.extend({
       
   352 	className: 'audio-details',
       
   353 	template:  wp.template('audio-details'),
       
   354 
       
   355 	setMedia: function() {
       
   356 		var audio = this.$('.wp-audio-shortcode');
       
   357 
       
   358 		if ( audio.find( 'source' ).length ) {
       
   359 			if ( audio.is(':hidden') ) {
       
   360 				audio.show();
       
   361 			}
       
   362 			this.media = MediaDetails.prepareSrc( audio.get(0) );
       
   363 		} else {
       
   364 			audio.hide();
       
   365 			this.media = false;
       
   366 		}
       
   367 
       
   368 		return this;
       
   369 	}
       
   370 });
       
   371 
       
   372 module.exports = AudioDetails;
       
   373 
       
   374 },{}],6:[function(require,module,exports){
       
   375 /*globals wp */
       
   376 
       
   377 /**
       
   378  * wp.media.view.MediaFrame.AudioDetails
       
   379  *
       
   380  * @class
       
   381  * @augments wp.media.view.MediaFrame.MediaDetails
       
   382  * @augments wp.media.view.MediaFrame.Select
       
   383  * @augments wp.media.view.MediaFrame
       
   384  * @augments wp.media.view.Frame
       
   385  * @augments wp.media.View
       
   386  * @augments wp.Backbone.View
       
   387  * @augments Backbone.View
       
   388  * @mixes wp.media.controller.StateMachine
       
   389  */
       
   390 var MediaDetails = wp.media.view.MediaFrame.MediaDetails,
       
   391 	MediaLibrary = wp.media.controller.MediaLibrary,
       
   392 
       
   393 	l10n = wp.media.view.l10n,
   483 	l10n = wp.media.view.l10n,
   394 	AudioDetails;
   484 	MediaDetails;
   395 
       
   396 AudioDetails = MediaDetails.extend({
       
   397 	defaults: {
       
   398 		id:      'audio',
       
   399 		url:     '',
       
   400 		menu:    'audio-details',
       
   401 		content: 'audio-details',
       
   402 		toolbar: 'audio-details',
       
   403 		type:    'link',
       
   404 		title:    l10n.audioDetailsTitle,
       
   405 		priority: 120
       
   406 	},
       
   407 
       
   408 	initialize: function( options ) {
       
   409 		options.DetailsView = wp.media.view.AudioDetails;
       
   410 		options.cancelText = l10n.audioDetailsCancel;
       
   411 		options.addText = l10n.audioAddSourceTitle;
       
   412 
       
   413 		MediaDetails.prototype.initialize.call( this, options );
       
   414 	},
       
   415 
       
   416 	bindHandlers: function() {
       
   417 		MediaDetails.prototype.bindHandlers.apply( this, arguments );
       
   418 
       
   419 		this.on( 'toolbar:render:replace-audio', this.renderReplaceToolbar, this );
       
   420 		this.on( 'toolbar:render:add-audio-source', this.renderAddSourceToolbar, this );
       
   421 	},
       
   422 
       
   423 	createStates: function() {
       
   424 		this.states.add([
       
   425 			new wp.media.controller.AudioDetails( {
       
   426 				media: this.media
       
   427 			} ),
       
   428 
       
   429 			new MediaLibrary( {
       
   430 				type: 'audio',
       
   431 				id: 'replace-audio',
       
   432 				title: l10n.audioReplaceTitle,
       
   433 				toolbar: 'replace-audio',
       
   434 				media: this.media,
       
   435 				menu: 'audio-details'
       
   436 			} ),
       
   437 
       
   438 			new MediaLibrary( {
       
   439 				type: 'audio',
       
   440 				id: 'add-audio-source',
       
   441 				title: l10n.audioAddSourceTitle,
       
   442 				toolbar: 'add-audio-source',
       
   443 				media: this.media,
       
   444 				menu: false
       
   445 			} )
       
   446 		]);
       
   447 	}
       
   448 });
       
   449 
       
   450 module.exports = AudioDetails;
       
   451 
       
   452 },{}],7:[function(require,module,exports){
       
   453 /*globals wp */
       
   454 
   485 
   455 /**
   486 /**
   456  * wp.media.view.MediaFrame.MediaDetails
   487  * wp.media.view.MediaFrame.MediaDetails
       
   488  *
       
   489  * @memberOf wp.media.view.MediaFrame
   457  *
   490  *
   458  * @class
   491  * @class
   459  * @augments wp.media.view.MediaFrame.Select
   492  * @augments wp.media.view.MediaFrame.Select
   460  * @augments wp.media.view.MediaFrame
   493  * @augments wp.media.view.MediaFrame
   461  * @augments wp.media.view.Frame
   494  * @augments wp.media.view.Frame
   462  * @augments wp.media.View
   495  * @augments wp.media.View
   463  * @augments wp.Backbone.View
   496  * @augments wp.Backbone.View
   464  * @augments Backbone.View
   497  * @augments Backbone.View
   465  * @mixes wp.media.controller.StateMachine
   498  * @mixes wp.media.controller.StateMachine
   466  */
   499  */
   467 var Select = wp.media.view.MediaFrame.Select,
   500 MediaDetails = Select.extend(/** @lends wp.media.view.MediaFrame.MediaDetails.prototype */{
   468 	l10n = wp.media.view.l10n,
       
   469 	MediaDetails;
       
   470 
       
   471 MediaDetails = Select.extend({
       
   472 	defaults: {
   501 	defaults: {
   473 		id:      'media',
   502 		id:      'media',
   474 		url:     '',
   503 		url:     '',
   475 		menu:    'media-details',
   504 		menu:    'media-details',
   476 		content: 'media-details',
   505 		content: 'media-details',
   579 	}
   608 	}
   580 });
   609 });
   581 
   610 
   582 module.exports = MediaDetails;
   611 module.exports = MediaDetails;
   583 
   612 
   584 },{}],8:[function(require,module,exports){
   613 
   585 /*globals wp, _ */
   614 /***/ }),
   586 
   615 /* 5 */
   587 /**
   616 /***/ (function(module, exports) {
   588  * wp.media.view.MediaFrame.VideoDetails
   617 
       
   618 var MediaDetails = wp.media.view.MediaFrame.MediaDetails,
       
   619 	MediaLibrary = wp.media.controller.MediaLibrary,
       
   620 
       
   621 	l10n = wp.media.view.l10n,
       
   622 	AudioDetails;
       
   623 
       
   624 /**
       
   625  * wp.media.view.MediaFrame.AudioDetails
       
   626  *
       
   627  * @memberOf wp.media.view.MediaFrame
   589  *
   628  *
   590  * @class
   629  * @class
   591  * @augments wp.media.view.MediaFrame.MediaDetails
   630  * @augments wp.media.view.MediaFrame.MediaDetails
   592  * @augments wp.media.view.MediaFrame.Select
   631  * @augments wp.media.view.MediaFrame.Select
   593  * @augments wp.media.view.MediaFrame
   632  * @augments wp.media.view.MediaFrame
   595  * @augments wp.media.View
   634  * @augments wp.media.View
   596  * @augments wp.Backbone.View
   635  * @augments wp.Backbone.View
   597  * @augments Backbone.View
   636  * @augments Backbone.View
   598  * @mixes wp.media.controller.StateMachine
   637  * @mixes wp.media.controller.StateMachine
   599  */
   638  */
       
   639 AudioDetails = MediaDetails.extend(/** @lends wp.media.view.MediaFrame.AudioDetails.prototype */{
       
   640 	defaults: {
       
   641 		id:      'audio',
       
   642 		url:     '',
       
   643 		menu:    'audio-details',
       
   644 		content: 'audio-details',
       
   645 		toolbar: 'audio-details',
       
   646 		type:    'link',
       
   647 		title:    l10n.audioDetailsTitle,
       
   648 		priority: 120
       
   649 	},
       
   650 
       
   651 	initialize: function( options ) {
       
   652 		options.DetailsView = wp.media.view.AudioDetails;
       
   653 		options.cancelText = l10n.audioDetailsCancel;
       
   654 		options.addText = l10n.audioAddSourceTitle;
       
   655 
       
   656 		MediaDetails.prototype.initialize.call( this, options );
       
   657 	},
       
   658 
       
   659 	bindHandlers: function() {
       
   660 		MediaDetails.prototype.bindHandlers.apply( this, arguments );
       
   661 
       
   662 		this.on( 'toolbar:render:replace-audio', this.renderReplaceToolbar, this );
       
   663 		this.on( 'toolbar:render:add-audio-source', this.renderAddSourceToolbar, this );
       
   664 	},
       
   665 
       
   666 	createStates: function() {
       
   667 		this.states.add([
       
   668 			new wp.media.controller.AudioDetails( {
       
   669 				media: this.media
       
   670 			} ),
       
   671 
       
   672 			new MediaLibrary( {
       
   673 				type: 'audio',
       
   674 				id: 'replace-audio',
       
   675 				title: l10n.audioReplaceTitle,
       
   676 				toolbar: 'replace-audio',
       
   677 				media: this.media,
       
   678 				menu: 'audio-details'
       
   679 			} ),
       
   680 
       
   681 			new MediaLibrary( {
       
   682 				type: 'audio',
       
   683 				id: 'add-audio-source',
       
   684 				title: l10n.audioAddSourceTitle,
       
   685 				toolbar: 'add-audio-source',
       
   686 				media: this.media,
       
   687 				menu: false
       
   688 			} )
       
   689 		]);
       
   690 	}
       
   691 });
       
   692 
       
   693 module.exports = AudioDetails;
       
   694 
       
   695 
       
   696 /***/ }),
       
   697 /* 6 */
       
   698 /***/ (function(module, exports) {
       
   699 
   600 var MediaDetails = wp.media.view.MediaFrame.MediaDetails,
   700 var MediaDetails = wp.media.view.MediaFrame.MediaDetails,
   601 	MediaLibrary = wp.media.controller.MediaLibrary,
   701 	MediaLibrary = wp.media.controller.MediaLibrary,
   602 	l10n = wp.media.view.l10n,
   702 	l10n = wp.media.view.l10n,
   603 	VideoDetails;
   703 	VideoDetails;
   604 
   704 
   605 VideoDetails = MediaDetails.extend({
   705 /**
       
   706  * wp.media.view.MediaFrame.VideoDetails
       
   707  *
       
   708  * @memberOf wp.media.view.MediaFrame
       
   709  *
       
   710  * @class
       
   711  * @augments wp.media.view.MediaFrame.MediaDetails
       
   712  * @augments wp.media.view.MediaFrame.Select
       
   713  * @augments wp.media.view.MediaFrame
       
   714  * @augments wp.media.view.Frame
       
   715  * @augments wp.media.View
       
   716  * @augments wp.Backbone.View
       
   717  * @augments Backbone.View
       
   718  * @mixes wp.media.controller.StateMachine
       
   719  */
       
   720 VideoDetails = MediaDetails.extend(/** @lends wp.media.view.MediaFrame.VideoDetails.prototype */{
   606 	defaults: {
   721 	defaults: {
   607 		id:      'video',
   722 		id:      'video',
   608 		url:     '',
   723 		url:     '',
   609 		menu:    'video-details',
   724 		menu:    'video-details',
   610 		content: 'video-details',
   725 		content: 'video-details',
   702 			var attachment = state.get( 'selection' ).single(),
   817 			var attachment = state.get( 'selection' ).single(),
   703 				content = controller.media.get( 'content' );
   818 				content = controller.media.get( 'content' );
   704 
   819 
   705 			if ( -1 === content.indexOf( attachment.get( 'url' ) ) ) {
   820 			if ( -1 === content.indexOf( attachment.get( 'url' ) ) ) {
   706 				content += [
   821 				content += [
   707 					'<track srclang="en" label="English"kind="subtitles" src="',
   822 					'<track srclang="en" label="English" kind="subtitles" src="',
   708 					attachment.get( 'url' ),
   823 					attachment.get( 'url' ),
   709 					'" />'
   824 					'" />'
   710 				].join('');
   825 				].join('');
   711 
   826 
   712 				controller.media.set( 'content', content );
   827 				controller.media.set( 'content', content );
   716 	}
   831 	}
   717 });
   832 });
   718 
   833 
   719 module.exports = VideoDetails;
   834 module.exports = VideoDetails;
   720 
   835 
   721 },{}],9:[function(require,module,exports){
   836 
   722 /*global wp, jQuery, _, MediaElementPlayer */
   837 /***/ }),
       
   838 /* 7 */
       
   839 /***/ (function(module, exports) {
       
   840 
       
   841 /* global MediaElementPlayer */
       
   842 var AttachmentDisplay = wp.media.view.Settings.AttachmentDisplay,
       
   843 	$ = jQuery,
       
   844 	MediaDetails;
   723 
   845 
   724 /**
   846 /**
   725  * wp.media.view.MediaDetails
   847  * wp.media.view.MediaDetails
       
   848  *
       
   849  * @memberOf wp.media.view
   726  *
   850  *
   727  * @class
   851  * @class
   728  * @augments wp.media.view.Settings.AttachmentDisplay
   852  * @augments wp.media.view.Settings.AttachmentDisplay
   729  * @augments wp.media.view.Settings
   853  * @augments wp.media.view.Settings
   730  * @augments wp.media.View
   854  * @augments wp.media.View
   731  * @augments wp.Backbone.View
   855  * @augments wp.Backbone.View
   732  * @augments Backbone.View
   856  * @augments Backbone.View
   733  */
   857  */
   734 var AttachmentDisplay = wp.media.view.Settings.AttachmentDisplay,
   858 MediaDetails = AttachmentDisplay.extend(/** @lends wp.media.view.MediaDetails.prototype */{
   735 	$ = jQuery,
       
   736 	MediaDetails;
       
   737 
       
   738 MediaDetails = AttachmentDisplay.extend({
       
   739 	initialize: function() {
   859 	initialize: function() {
   740 		_.bindAll(this, 'success');
   860 		_.bindAll(this, 'success');
   741 		this.players = [];
   861 		this.players = [];
   742 		this.listenTo( this.controller, 'close', wp.media.mixin.unsetPlayers );
   862 		this.listenTo( this.controller, 'close', wp.media.mixin.unsetPlayers );
   743 		this.on( 'ready', this.setPlayer );
   863 		this.on( 'ready', this.setPlayer );
   744 		this.on( 'media:setting:remove', wp.media.mixin.unsetPlayers, this );
   864 		this.on( 'media:setting:remove', wp.media.mixin.unsetPlayers, this );
   745 		this.on( 'media:setting:remove', this.render );
   865 		this.on( 'media:setting:remove', this.render );
   746 		this.on( 'media:setting:remove', this.setPlayer );
   866 		this.on( 'media:setting:remove', this.setPlayer );
   747 		this.events = _.extend( this.events, {
   867 
       
   868 		AttachmentDisplay.prototype.initialize.apply( this, arguments );
       
   869 	},
       
   870 
       
   871 	events: function(){
       
   872 		return _.extend( {
   748 			'click .remove-setting' : 'removeSetting',
   873 			'click .remove-setting' : 'removeSetting',
   749 			'change .content-track' : 'setTracks',
   874 			'change .content-track' : 'setTracks',
   750 			'click .remove-track' : 'setTracks',
   875 			'click .remove-track' : 'setTracks',
   751 			'click .add-media-source' : 'addSource'
   876 			'click .add-media-source' : 'addSource'
   752 		} );
   877 		}, AttachmentDisplay.prototype.events );
   753 
       
   754 		AttachmentDisplay.prototype.initialize.apply( this, arguments );
       
   755 	},
   878 	},
   756 
   879 
   757 	prepare: function() {
   880 	prepare: function() {
   758 		return _.defaults({
   881 		return _.defaults({
   759 			model: this.model.toJSON()
   882 			model: this.model.toJSON()
   802 	loadPlayer: function () {
   925 	loadPlayer: function () {
   803 		this.players.push( new MediaElementPlayer( this.media, this.settings ) );
   926 		this.players.push( new MediaElementPlayer( this.media, this.settings ) );
   804 		this.scriptXhr = false;
   927 		this.scriptXhr = false;
   805 	},
   928 	},
   806 
   929 
   807 	/**
       
   808 	 * @global MediaElementPlayer
       
   809 	 */
       
   810 	setPlayer : function() {
   930 	setPlayer : function() {
   811 		var baseSettings;
   931 		var src;
   812 
   932 
   813 		if ( this.players.length || ! this.media || this.scriptXhr ) {
   933 		if ( this.players.length || ! this.media || this.scriptXhr ) {
   814 			return;
   934 			return;
   815 		}
   935 		}
   816 
   936 
   817 		if ( this.model.get( 'src' ).indexOf( 'vimeo' ) > -1 && ! ( 'Froogaloop' in window ) ) {
   937 		src = this.model.get( 'src' );
   818 			baseSettings = wp.media.mixin.mejsSettings;
   938 
   819 			this.scriptXhr = $.getScript( baseSettings.pluginPath + 'froogaloop.min.js', _.bind( this.loadPlayer, this ) );
   939 		if ( src && src.indexOf( 'vimeo' ) > -1 && ! ( 'Vimeo' in window ) ) {
       
   940 			this.scriptXhr = $.getScript( 'https://player.vimeo.com/api/player.js', _.bind( this.loadPlayer, this ) );
   820 		} else {
   941 		} else {
   821 			this.loadPlayer();
   942 			this.loadPlayer();
   822 		}
   943 		}
   823 	},
   944 	},
   824 
   945 
   859 	},
   980 	},
   860 
   981 
   861 	resetFocus: function() {
   982 	resetFocus: function() {
   862 		this.$( '.embed-media-settings' ).scrollTop( 0 );
   983 		this.$( '.embed-media-settings' ).scrollTop( 0 );
   863 	}
   984 	}
   864 }, {
   985 },/** @lends wp.media.view.MediaDetails */{
   865 	instances : 0,
   986 	instances : 0,
   866 	/**
   987 	/**
   867 	 * When multiple players in the DOM contain the same src, things get weird.
   988 	 * When multiple players in the DOM contain the same src, things get weird.
   868 	 *
   989 	 *
   869 	 * @param {HTMLElement} elem
   990 	 * @param {HTMLElement} elem
   884 	}
  1005 	}
   885 });
  1006 });
   886 
  1007 
   887 module.exports = MediaDetails;
  1008 module.exports = MediaDetails;
   888 
  1009 
   889 },{}],10:[function(require,module,exports){
  1010 
   890 /*globals wp */
  1011 /***/ }),
   891 
  1012 /* 8 */
   892 /**
  1013 /***/ (function(module, exports) {
   893  * wp.media.view.VideoDetails
  1014 
       
  1015 var MediaDetails = wp.media.view.MediaDetails,
       
  1016 	AudioDetails;
       
  1017 
       
  1018 /**
       
  1019  * wp.media.view.AudioDetails
       
  1020  *
       
  1021  * @memberOf wp.media.view
   894  *
  1022  *
   895  * @class
  1023  * @class
   896  * @augments wp.media.view.MediaDetails
  1024  * @augments wp.media.view.MediaDetails
   897  * @augments wp.media.view.Settings.AttachmentDisplay
  1025  * @augments wp.media.view.Settings.AttachmentDisplay
   898  * @augments wp.media.view.Settings
  1026  * @augments wp.media.view.Settings
   899  * @augments wp.media.View
  1027  * @augments wp.media.View
   900  * @augments wp.Backbone.View
  1028  * @augments wp.Backbone.View
   901  * @augments Backbone.View
  1029  * @augments Backbone.View
   902  */
  1030  */
       
  1031 AudioDetails = MediaDetails.extend(/** @lends wp.media.view.AudioDetails.prototype */{
       
  1032 	className: 'audio-details',
       
  1033 	template:  wp.template('audio-details'),
       
  1034 
       
  1035 	setMedia: function() {
       
  1036 		var audio = this.$('.wp-audio-shortcode');
       
  1037 
       
  1038 		if ( audio.find( 'source' ).length ) {
       
  1039 			if ( audio.is(':hidden') ) {
       
  1040 				audio.show();
       
  1041 			}
       
  1042 			this.media = MediaDetails.prepareSrc( audio.get(0) );
       
  1043 		} else {
       
  1044 			audio.hide();
       
  1045 			this.media = false;
       
  1046 		}
       
  1047 
       
  1048 		return this;
       
  1049 	}
       
  1050 });
       
  1051 
       
  1052 module.exports = AudioDetails;
       
  1053 
       
  1054 
       
  1055 /***/ }),
       
  1056 /* 9 */
       
  1057 /***/ (function(module, exports) {
       
  1058 
   903 var MediaDetails = wp.media.view.MediaDetails,
  1059 var MediaDetails = wp.media.view.MediaDetails,
   904 	VideoDetails;
  1060 	VideoDetails;
   905 
  1061 
   906 VideoDetails = MediaDetails.extend({
  1062 /**
       
  1063  * wp.media.view.VideoDetails
       
  1064  *
       
  1065  * @memberOf wp.media.view
       
  1066  *
       
  1067  * @class
       
  1068  * @augments wp.media.view.MediaDetails
       
  1069  * @augments wp.media.view.Settings.AttachmentDisplay
       
  1070  * @augments wp.media.view.Settings
       
  1071  * @augments wp.media.View
       
  1072  * @augments wp.Backbone.View
       
  1073  * @augments Backbone.View
       
  1074  */
       
  1075 VideoDetails = MediaDetails.extend(/** @lends wp.media.view.VideoDetails.prototype */{
   907 	className: 'video-details',
  1076 	className: 'video-details',
   908 	template:  wp.template('video-details'),
  1077 	template:  wp.template('video-details'),
   909 
  1078 
   910 	setMedia: function() {
  1079 	setMedia: function() {
   911 		var video = this.$('.wp-video-shortcode');
  1080 		var video = this.$('.wp-video-shortcode');
   929 	}
  1098 	}
   930 });
  1099 });
   931 
  1100 
   932 module.exports = VideoDetails;
  1101 module.exports = VideoDetails;
   933 
  1102 
   934 },{}]},{},[1]);
  1103 
       
  1104 /***/ })
       
  1105 /******/ ]);