media-audiovideo.js 24 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082
  1. /******/ (function() { // webpackBootstrap
  2. /******/ var __webpack_modules__ = ({
  3. /***/ 6045:
  4. /***/ (function(module) {
  5. var State = wp.media.controller.State,
  6. l10n = wp.media.view.l10n,
  7. AudioDetails;
  8. /**
  9. * wp.media.controller.AudioDetails
  10. *
  11. * The controller for the Audio Details state
  12. *
  13. * @memberOf wp.media.controller
  14. *
  15. * @class
  16. * @augments wp.media.controller.State
  17. * @augments Backbone.Model
  18. */
  19. AudioDetails = State.extend(/** @lends wp.media.controller.AudioDetails.prototype */{
  20. defaults: {
  21. id: 'audio-details',
  22. toolbar: 'audio-details',
  23. title: l10n.audioDetailsTitle,
  24. content: 'audio-details',
  25. menu: 'audio-details',
  26. router: false,
  27. priority: 60
  28. },
  29. initialize: function( options ) {
  30. this.media = options.media;
  31. State.prototype.initialize.apply( this, arguments );
  32. }
  33. });
  34. module.exports = AudioDetails;
  35. /***/ }),
  36. /***/ 580:
  37. /***/ (function(module) {
  38. /**
  39. * wp.media.controller.VideoDetails
  40. *
  41. * The controller for the Video Details state
  42. *
  43. * @memberOf wp.media.controller
  44. *
  45. * @class
  46. * @augments wp.media.controller.State
  47. * @augments Backbone.Model
  48. */
  49. var State = wp.media.controller.State,
  50. l10n = wp.media.view.l10n,
  51. VideoDetails;
  52. VideoDetails = State.extend(/** @lends wp.media.controller.VideoDetails.prototype */{
  53. defaults: {
  54. id: 'video-details',
  55. toolbar: 'video-details',
  56. title: l10n.videoDetailsTitle,
  57. content: 'video-details',
  58. menu: 'video-details',
  59. router: false,
  60. priority: 60
  61. },
  62. initialize: function( options ) {
  63. this.media = options.media;
  64. State.prototype.initialize.apply( this, arguments );
  65. }
  66. });
  67. module.exports = VideoDetails;
  68. /***/ }),
  69. /***/ 6615:
  70. /***/ (function(module) {
  71. /**
  72. * wp.media.model.PostMedia
  73. *
  74. * Shared model class for audio and video. Updates the model after
  75. * "Add Audio|Video Source" and "Replace Audio|Video" states return
  76. *
  77. * @memberOf wp.media.model
  78. *
  79. * @class
  80. * @augments Backbone.Model
  81. */
  82. var PostMedia = Backbone.Model.extend(/** @lends wp.media.model.PostMedia.prototype */{
  83. initialize: function() {
  84. this.attachment = false;
  85. },
  86. setSource: function( attachment ) {
  87. this.attachment = attachment;
  88. this.extension = attachment.get( 'filename' ).split('.').pop();
  89. if ( this.get( 'src' ) && this.extension === this.get( 'src' ).split('.').pop() ) {
  90. this.unset( 'src' );
  91. }
  92. if ( _.contains( wp.media.view.settings.embedExts, this.extension ) ) {
  93. this.set( this.extension, this.attachment.get( 'url' ) );
  94. } else {
  95. this.unset( this.extension );
  96. }
  97. },
  98. changeAttachment: function( attachment ) {
  99. this.setSource( attachment );
  100. this.unset( 'src' );
  101. _.each( _.without( wp.media.view.settings.embedExts, this.extension ), function( ext ) {
  102. this.unset( ext );
  103. }, this );
  104. }
  105. });
  106. module.exports = PostMedia;
  107. /***/ }),
  108. /***/ 1764:
  109. /***/ (function(module) {
  110. var MediaDetails = wp.media.view.MediaDetails,
  111. AudioDetails;
  112. /**
  113. * wp.media.view.AudioDetails
  114. *
  115. * @memberOf wp.media.view
  116. *
  117. * @class
  118. * @augments wp.media.view.MediaDetails
  119. * @augments wp.media.view.Settings.AttachmentDisplay
  120. * @augments wp.media.view.Settings
  121. * @augments wp.media.View
  122. * @augments wp.Backbone.View
  123. * @augments Backbone.View
  124. */
  125. AudioDetails = MediaDetails.extend(/** @lends wp.media.view.AudioDetails.prototype */{
  126. className: 'audio-details',
  127. template: wp.template('audio-details'),
  128. setMedia: function() {
  129. var audio = this.$('.wp-audio-shortcode');
  130. if ( audio.find( 'source' ).length ) {
  131. if ( audio.is(':hidden') ) {
  132. audio.show();
  133. }
  134. this.media = MediaDetails.prepareSrc( audio.get(0) );
  135. } else {
  136. audio.hide();
  137. this.media = false;
  138. }
  139. return this;
  140. }
  141. });
  142. module.exports = AudioDetails;
  143. /***/ }),
  144. /***/ 5262:
  145. /***/ (function(module) {
  146. var MediaDetails = wp.media.view.MediaFrame.MediaDetails,
  147. MediaLibrary = wp.media.controller.MediaLibrary,
  148. l10n = wp.media.view.l10n,
  149. AudioDetails;
  150. /**
  151. * wp.media.view.MediaFrame.AudioDetails
  152. *
  153. * @memberOf wp.media.view.MediaFrame
  154. *
  155. * @class
  156. * @augments wp.media.view.MediaFrame.MediaDetails
  157. * @augments wp.media.view.MediaFrame.Select
  158. * @augments wp.media.view.MediaFrame
  159. * @augments wp.media.view.Frame
  160. * @augments wp.media.View
  161. * @augments wp.Backbone.View
  162. * @augments Backbone.View
  163. * @mixes wp.media.controller.StateMachine
  164. */
  165. AudioDetails = MediaDetails.extend(/** @lends wp.media.view.MediaFrame.AudioDetails.prototype */{
  166. defaults: {
  167. id: 'audio',
  168. url: '',
  169. menu: 'audio-details',
  170. content: 'audio-details',
  171. toolbar: 'audio-details',
  172. type: 'link',
  173. title: l10n.audioDetailsTitle,
  174. priority: 120
  175. },
  176. initialize: function( options ) {
  177. options.DetailsView = wp.media.view.AudioDetails;
  178. options.cancelText = l10n.audioDetailsCancel;
  179. options.addText = l10n.audioAddSourceTitle;
  180. MediaDetails.prototype.initialize.call( this, options );
  181. },
  182. bindHandlers: function() {
  183. MediaDetails.prototype.bindHandlers.apply( this, arguments );
  184. this.on( 'toolbar:render:replace-audio', this.renderReplaceToolbar, this );
  185. this.on( 'toolbar:render:add-audio-source', this.renderAddSourceToolbar, this );
  186. },
  187. createStates: function() {
  188. this.states.add([
  189. new wp.media.controller.AudioDetails( {
  190. media: this.media
  191. } ),
  192. new MediaLibrary( {
  193. type: 'audio',
  194. id: 'replace-audio',
  195. title: l10n.audioReplaceTitle,
  196. toolbar: 'replace-audio',
  197. media: this.media,
  198. menu: 'audio-details'
  199. } ),
  200. new MediaLibrary( {
  201. type: 'audio',
  202. id: 'add-audio-source',
  203. title: l10n.audioAddSourceTitle,
  204. toolbar: 'add-audio-source',
  205. media: this.media,
  206. menu: false
  207. } )
  208. ]);
  209. }
  210. });
  211. module.exports = AudioDetails;
  212. /***/ }),
  213. /***/ 6445:
  214. /***/ (function(module) {
  215. var Select = wp.media.view.MediaFrame.Select,
  216. l10n = wp.media.view.l10n,
  217. MediaDetails;
  218. /**
  219. * wp.media.view.MediaFrame.MediaDetails
  220. *
  221. * @memberOf wp.media.view.MediaFrame
  222. *
  223. * @class
  224. * @augments wp.media.view.MediaFrame.Select
  225. * @augments wp.media.view.MediaFrame
  226. * @augments wp.media.view.Frame
  227. * @augments wp.media.View
  228. * @augments wp.Backbone.View
  229. * @augments Backbone.View
  230. * @mixes wp.media.controller.StateMachine
  231. */
  232. MediaDetails = Select.extend(/** @lends wp.media.view.MediaFrame.MediaDetails.prototype */{
  233. defaults: {
  234. id: 'media',
  235. url: '',
  236. menu: 'media-details',
  237. content: 'media-details',
  238. toolbar: 'media-details',
  239. type: 'link',
  240. priority: 120
  241. },
  242. initialize: function( options ) {
  243. this.DetailsView = options.DetailsView;
  244. this.cancelText = options.cancelText;
  245. this.addText = options.addText;
  246. this.media = new wp.media.model.PostMedia( options.metadata );
  247. this.options.selection = new wp.media.model.Selection( this.media.attachment, { multiple: false } );
  248. Select.prototype.initialize.apply( this, arguments );
  249. },
  250. bindHandlers: function() {
  251. var menu = this.defaults.menu;
  252. Select.prototype.bindHandlers.apply( this, arguments );
  253. this.on( 'menu:create:' + menu, this.createMenu, this );
  254. this.on( 'content:render:' + menu, this.renderDetailsContent, this );
  255. this.on( 'menu:render:' + menu, this.renderMenu, this );
  256. this.on( 'toolbar:render:' + menu, this.renderDetailsToolbar, this );
  257. },
  258. renderDetailsContent: function() {
  259. var view = new this.DetailsView({
  260. controller: this,
  261. model: this.state().media,
  262. attachment: this.state().media.attachment
  263. }).render();
  264. this.content.set( view );
  265. },
  266. renderMenu: function( view ) {
  267. var lastState = this.lastState(),
  268. previous = lastState && lastState.id,
  269. frame = this;
  270. view.set({
  271. cancel: {
  272. text: this.cancelText,
  273. priority: 20,
  274. click: function() {
  275. if ( previous ) {
  276. frame.setState( previous );
  277. } else {
  278. frame.close();
  279. }
  280. }
  281. },
  282. separateCancel: new wp.media.View({
  283. className: 'separator',
  284. priority: 40
  285. })
  286. });
  287. },
  288. setPrimaryButton: function(text, handler) {
  289. this.toolbar.set( new wp.media.view.Toolbar({
  290. controller: this,
  291. items: {
  292. button: {
  293. style: 'primary',
  294. text: text,
  295. priority: 80,
  296. click: function() {
  297. var controller = this.controller;
  298. handler.call( this, controller, controller.state() );
  299. // Restore and reset the default state.
  300. controller.setState( controller.options.state );
  301. controller.reset();
  302. }
  303. }
  304. }
  305. }) );
  306. },
  307. renderDetailsToolbar: function() {
  308. this.setPrimaryButton( l10n.update, function( controller, state ) {
  309. controller.close();
  310. state.trigger( 'update', controller.media.toJSON() );
  311. } );
  312. },
  313. renderReplaceToolbar: function() {
  314. this.setPrimaryButton( l10n.replace, function( controller, state ) {
  315. var attachment = state.get( 'selection' ).single();
  316. controller.media.changeAttachment( attachment );
  317. state.trigger( 'replace', controller.media.toJSON() );
  318. } );
  319. },
  320. renderAddSourceToolbar: function() {
  321. this.setPrimaryButton( this.addText, function( controller, state ) {
  322. var attachment = state.get( 'selection' ).single();
  323. controller.media.setSource( attachment );
  324. state.trigger( 'add-source', controller.media.toJSON() );
  325. } );
  326. }
  327. });
  328. module.exports = MediaDetails;
  329. /***/ }),
  330. /***/ 2075:
  331. /***/ (function(module) {
  332. var MediaDetails = wp.media.view.MediaFrame.MediaDetails,
  333. MediaLibrary = wp.media.controller.MediaLibrary,
  334. l10n = wp.media.view.l10n,
  335. VideoDetails;
  336. /**
  337. * wp.media.view.MediaFrame.VideoDetails
  338. *
  339. * @memberOf wp.media.view.MediaFrame
  340. *
  341. * @class
  342. * @augments wp.media.view.MediaFrame.MediaDetails
  343. * @augments wp.media.view.MediaFrame.Select
  344. * @augments wp.media.view.MediaFrame
  345. * @augments wp.media.view.Frame
  346. * @augments wp.media.View
  347. * @augments wp.Backbone.View
  348. * @augments Backbone.View
  349. * @mixes wp.media.controller.StateMachine
  350. */
  351. VideoDetails = MediaDetails.extend(/** @lends wp.media.view.MediaFrame.VideoDetails.prototype */{
  352. defaults: {
  353. id: 'video',
  354. url: '',
  355. menu: 'video-details',
  356. content: 'video-details',
  357. toolbar: 'video-details',
  358. type: 'link',
  359. title: l10n.videoDetailsTitle,
  360. priority: 120
  361. },
  362. initialize: function( options ) {
  363. options.DetailsView = wp.media.view.VideoDetails;
  364. options.cancelText = l10n.videoDetailsCancel;
  365. options.addText = l10n.videoAddSourceTitle;
  366. MediaDetails.prototype.initialize.call( this, options );
  367. },
  368. bindHandlers: function() {
  369. MediaDetails.prototype.bindHandlers.apply( this, arguments );
  370. this.on( 'toolbar:render:replace-video', this.renderReplaceToolbar, this );
  371. this.on( 'toolbar:render:add-video-source', this.renderAddSourceToolbar, this );
  372. this.on( 'toolbar:render:select-poster-image', this.renderSelectPosterImageToolbar, this );
  373. this.on( 'toolbar:render:add-track', this.renderAddTrackToolbar, this );
  374. },
  375. createStates: function() {
  376. this.states.add([
  377. new wp.media.controller.VideoDetails({
  378. media: this.media
  379. }),
  380. new MediaLibrary( {
  381. type: 'video',
  382. id: 'replace-video',
  383. title: l10n.videoReplaceTitle,
  384. toolbar: 'replace-video',
  385. media: this.media,
  386. menu: 'video-details'
  387. } ),
  388. new MediaLibrary( {
  389. type: 'video',
  390. id: 'add-video-source',
  391. title: l10n.videoAddSourceTitle,
  392. toolbar: 'add-video-source',
  393. media: this.media,
  394. menu: false
  395. } ),
  396. new MediaLibrary( {
  397. type: 'image',
  398. id: 'select-poster-image',
  399. title: l10n.videoSelectPosterImageTitle,
  400. toolbar: 'select-poster-image',
  401. media: this.media,
  402. menu: 'video-details'
  403. } ),
  404. new MediaLibrary( {
  405. type: 'text',
  406. id: 'add-track',
  407. title: l10n.videoAddTrackTitle,
  408. toolbar: 'add-track',
  409. media: this.media,
  410. menu: 'video-details'
  411. } )
  412. ]);
  413. },
  414. renderSelectPosterImageToolbar: function() {
  415. this.setPrimaryButton( l10n.videoSelectPosterImageTitle, function( controller, state ) {
  416. var urls = [], attachment = state.get( 'selection' ).single();
  417. controller.media.set( 'poster', attachment.get( 'url' ) );
  418. state.trigger( 'set-poster-image', controller.media.toJSON() );
  419. _.each( wp.media.view.settings.embedExts, function (ext) {
  420. if ( controller.media.get( ext ) ) {
  421. urls.push( controller.media.get( ext ) );
  422. }
  423. } );
  424. wp.ajax.send( 'set-attachment-thumbnail', {
  425. data : {
  426. urls: urls,
  427. thumbnail_id: attachment.get( 'id' )
  428. }
  429. } );
  430. } );
  431. },
  432. renderAddTrackToolbar: function() {
  433. this.setPrimaryButton( l10n.videoAddTrackTitle, function( controller, state ) {
  434. var attachment = state.get( 'selection' ).single(),
  435. content = controller.media.get( 'content' );
  436. if ( -1 === content.indexOf( attachment.get( 'url' ) ) ) {
  437. content += [
  438. '<track srclang="en" label="English" kind="subtitles" src="',
  439. attachment.get( 'url' ),
  440. '" />'
  441. ].join('');
  442. controller.media.set( 'content', content );
  443. }
  444. state.trigger( 'add-track', controller.media.toJSON() );
  445. } );
  446. }
  447. });
  448. module.exports = VideoDetails;
  449. /***/ }),
  450. /***/ 8867:
  451. /***/ (function(module) {
  452. /* global MediaElementPlayer */
  453. var AttachmentDisplay = wp.media.view.Settings.AttachmentDisplay,
  454. $ = jQuery,
  455. MediaDetails;
  456. /**
  457. * wp.media.view.MediaDetails
  458. *
  459. * @memberOf wp.media.view
  460. *
  461. * @class
  462. * @augments wp.media.view.Settings.AttachmentDisplay
  463. * @augments wp.media.view.Settings
  464. * @augments wp.media.View
  465. * @augments wp.Backbone.View
  466. * @augments Backbone.View
  467. */
  468. MediaDetails = AttachmentDisplay.extend(/** @lends wp.media.view.MediaDetails.prototype */{
  469. initialize: function() {
  470. _.bindAll(this, 'success');
  471. this.players = [];
  472. this.listenTo( this.controller.states, 'close', wp.media.mixin.unsetPlayers );
  473. this.on( 'ready', this.setPlayer );
  474. this.on( 'media:setting:remove', wp.media.mixin.unsetPlayers, this );
  475. this.on( 'media:setting:remove', this.render );
  476. this.on( 'media:setting:remove', this.setPlayer );
  477. AttachmentDisplay.prototype.initialize.apply( this, arguments );
  478. },
  479. events: function(){
  480. return _.extend( {
  481. 'click .remove-setting' : 'removeSetting',
  482. 'change .content-track' : 'setTracks',
  483. 'click .remove-track' : 'setTracks',
  484. 'click .add-media-source' : 'addSource'
  485. }, AttachmentDisplay.prototype.events );
  486. },
  487. prepare: function() {
  488. return _.defaults({
  489. model: this.model.toJSON()
  490. }, this.options );
  491. },
  492. /**
  493. * Remove a setting's UI when the model unsets it
  494. *
  495. * @fires wp.media.view.MediaDetails#media:setting:remove
  496. *
  497. * @param {Event} e
  498. */
  499. removeSetting : function(e) {
  500. var wrap = $( e.currentTarget ).parent(), setting;
  501. setting = wrap.find( 'input' ).data( 'setting' );
  502. if ( setting ) {
  503. this.model.unset( setting );
  504. this.trigger( 'media:setting:remove', this );
  505. }
  506. wrap.remove();
  507. },
  508. /**
  509. *
  510. * @fires wp.media.view.MediaDetails#media:setting:remove
  511. */
  512. setTracks : function() {
  513. var tracks = '';
  514. _.each( this.$('.content-track'), function(track) {
  515. tracks += $( track ).val();
  516. } );
  517. this.model.set( 'content', tracks );
  518. this.trigger( 'media:setting:remove', this );
  519. },
  520. addSource : function( e ) {
  521. this.controller.lastMime = $( e.currentTarget ).data( 'mime' );
  522. this.controller.setState( 'add-' + this.controller.defaults.id + '-source' );
  523. },
  524. loadPlayer: function () {
  525. this.players.push( new MediaElementPlayer( this.media, this.settings ) );
  526. this.scriptXhr = false;
  527. },
  528. setPlayer : function() {
  529. var src;
  530. if ( this.players.length || ! this.media || this.scriptXhr ) {
  531. return;
  532. }
  533. src = this.model.get( 'src' );
  534. if ( src && src.indexOf( 'vimeo' ) > -1 && ! ( 'Vimeo' in window ) ) {
  535. this.scriptXhr = $.getScript( 'https://player.vimeo.com/api/player.js', _.bind( this.loadPlayer, this ) );
  536. } else {
  537. this.loadPlayer();
  538. }
  539. },
  540. /**
  541. * @abstract
  542. */
  543. setMedia : function() {
  544. return this;
  545. },
  546. success : function(mejs) {
  547. var autoplay = mejs.attributes.autoplay && 'false' !== mejs.attributes.autoplay;
  548. if ( 'flash' === mejs.pluginType && autoplay ) {
  549. mejs.addEventListener( 'canplay', function() {
  550. mejs.play();
  551. }, false );
  552. }
  553. this.mejs = mejs;
  554. },
  555. /**
  556. * @return {media.view.MediaDetails} Returns itself to allow chaining.
  557. */
  558. render: function() {
  559. AttachmentDisplay.prototype.render.apply( this, arguments );
  560. setTimeout( _.bind( function() {
  561. this.scrollToTop();
  562. }, this ), 10 );
  563. this.settings = _.defaults( {
  564. success : this.success
  565. }, wp.media.mixin.mejsSettings );
  566. return this.setMedia();
  567. },
  568. scrollToTop: function() {
  569. this.$( '.embed-media-settings' ).scrollTop( 0 );
  570. }
  571. },/** @lends wp.media.view.MediaDetails */{
  572. instances : 0,
  573. /**
  574. * When multiple players in the DOM contain the same src, things get weird.
  575. *
  576. * @param {HTMLElement} elem
  577. * @return {HTMLElement}
  578. */
  579. prepareSrc : function( elem ) {
  580. var i = MediaDetails.instances++;
  581. _.each( $( elem ).find( 'source' ), function( source ) {
  582. source.src = [
  583. source.src,
  584. source.src.indexOf('?') > -1 ? '&' : '?',
  585. '_=',
  586. i
  587. ].join('');
  588. } );
  589. return elem;
  590. }
  591. });
  592. module.exports = MediaDetails;
  593. /***/ }),
  594. /***/ 7697:
  595. /***/ (function(module) {
  596. var MediaDetails = wp.media.view.MediaDetails,
  597. VideoDetails;
  598. /**
  599. * wp.media.view.VideoDetails
  600. *
  601. * @memberOf wp.media.view
  602. *
  603. * @class
  604. * @augments wp.media.view.MediaDetails
  605. * @augments wp.media.view.Settings.AttachmentDisplay
  606. * @augments wp.media.view.Settings
  607. * @augments wp.media.View
  608. * @augments wp.Backbone.View
  609. * @augments Backbone.View
  610. */
  611. VideoDetails = MediaDetails.extend(/** @lends wp.media.view.VideoDetails.prototype */{
  612. className: 'video-details',
  613. template: wp.template('video-details'),
  614. setMedia: function() {
  615. var video = this.$('.wp-video-shortcode');
  616. if ( video.find( 'source' ).length ) {
  617. if ( video.is(':hidden') ) {
  618. video.show();
  619. }
  620. if ( ! video.hasClass( 'youtube-video' ) && ! video.hasClass( 'vimeo-video' ) ) {
  621. this.media = MediaDetails.prepareSrc( video.get(0) );
  622. } else {
  623. this.media = video.get(0);
  624. }
  625. } else {
  626. video.hide();
  627. this.media = false;
  628. }
  629. return this;
  630. }
  631. });
  632. module.exports = VideoDetails;
  633. /***/ })
  634. /******/ });
  635. /************************************************************************/
  636. /******/ // The module cache
  637. /******/ var __webpack_module_cache__ = {};
  638. /******/
  639. /******/ // The require function
  640. /******/ function __webpack_require__(moduleId) {
  641. /******/ // Check if module is in cache
  642. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  643. /******/ if (cachedModule !== undefined) {
  644. /******/ return cachedModule.exports;
  645. /******/ }
  646. /******/ // Create a new module (and put it into the cache)
  647. /******/ var module = __webpack_module_cache__[moduleId] = {
  648. /******/ // no module.id needed
  649. /******/ // no module.loaded needed
  650. /******/ exports: {}
  651. /******/ };
  652. /******/
  653. /******/ // Execute the module function
  654. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  655. /******/
  656. /******/ // Return the exports of the module
  657. /******/ return module.exports;
  658. /******/ }
  659. /******/
  660. /************************************************************************/
  661. var __webpack_exports__ = {};
  662. // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
  663. !function() {
  664. /**
  665. * @output wp-includes/js/media-audiovideo.js
  666. */
  667. var media = wp.media,
  668. baseSettings = window._wpmejsSettings || {},
  669. l10n = window._wpMediaViewsL10n || {};
  670. /**
  671. *
  672. * Defines the wp.media.mixin object.
  673. *
  674. * @mixin
  675. *
  676. * @since 4.2.0
  677. */
  678. wp.media.mixin = {
  679. mejsSettings: baseSettings,
  680. /**
  681. * Pauses and removes all players.
  682. *
  683. * @since 4.2.0
  684. *
  685. * @return {void}
  686. */
  687. removeAllPlayers: function() {
  688. var p;
  689. if ( window.mejs && window.mejs.players ) {
  690. for ( p in window.mejs.players ) {
  691. window.mejs.players[p].pause();
  692. this.removePlayer( window.mejs.players[p] );
  693. }
  694. }
  695. },
  696. /**
  697. * Removes the player.
  698. *
  699. * Override the MediaElement method for removing a player.
  700. * MediaElement tries to pull the audio/video tag out of
  701. * its container and re-add it to the DOM.
  702. *
  703. * @since 4.2.0
  704. *
  705. * @return {void}
  706. */
  707. removePlayer: function(t) {
  708. var featureIndex, feature;
  709. if ( ! t.options ) {
  710. return;
  711. }
  712. // Invoke features cleanup.
  713. for ( featureIndex in t.options.features ) {
  714. feature = t.options.features[featureIndex];
  715. if ( t['clean' + feature] ) {
  716. try {
  717. t['clean' + feature](t);
  718. } catch (e) {}
  719. }
  720. }
  721. if ( ! t.isDynamic ) {
  722. t.node.remove();
  723. }
  724. if ( 'html5' !== t.media.rendererName ) {
  725. t.media.remove();
  726. }
  727. delete window.mejs.players[t.id];
  728. t.container.remove();
  729. t.globalUnbind('resize', t.globalResizeCallback);
  730. t.globalUnbind('keydown', t.globalKeydownCallback);
  731. t.globalUnbind('click', t.globalClickCallback);
  732. delete t.media.player;
  733. },
  734. /**
  735. *
  736. * Removes and resets all players.
  737. *
  738. * Allows any class that has set 'player' to a MediaElementPlayer
  739. * instance to remove the player when listening to events.
  740. *
  741. * Examples: modal closes, shortcode properties are removed, etc.
  742. *
  743. * @since 4.2.0
  744. */
  745. unsetPlayers : function() {
  746. if ( this.players && this.players.length ) {
  747. _.each( this.players, function (player) {
  748. player.pause();
  749. wp.media.mixin.removePlayer( player );
  750. } );
  751. this.players = [];
  752. }
  753. }
  754. };
  755. /**
  756. * Shortcode modeling for playlists.
  757. *
  758. * @since 4.2.0
  759. */
  760. wp.media.playlist = new wp.media.collection({
  761. tag: 'playlist',
  762. editTitle : l10n.editPlaylistTitle,
  763. defaults : {
  764. id: wp.media.view.settings.post.id,
  765. style: 'light',
  766. tracklist: true,
  767. tracknumbers: true,
  768. images: true,
  769. artists: true,
  770. type: 'audio'
  771. }
  772. });
  773. /**
  774. * Shortcode modeling for audio.
  775. *
  776. * `edit()` prepares the shortcode for the media modal.
  777. * `shortcode()` builds the new shortcode after an update.
  778. *
  779. * @namespace
  780. *
  781. * @since 4.2.0
  782. */
  783. wp.media.audio = {
  784. coerce : wp.media.coerce,
  785. defaults : {
  786. id : wp.media.view.settings.post.id,
  787. src : '',
  788. loop : false,
  789. autoplay : false,
  790. preload : 'none',
  791. width : 400
  792. },
  793. /**
  794. * Instantiates a new media object with the next matching shortcode.
  795. *
  796. * @since 4.2.0
  797. *
  798. * @param {string} data The text to apply the shortcode on.
  799. * @return {wp.media} The media object.
  800. */
  801. edit : function( data ) {
  802. var frame, shortcode = wp.shortcode.next( 'audio', data ).shortcode;
  803. frame = wp.media({
  804. frame: 'audio',
  805. state: 'audio-details',
  806. metadata: _.defaults( shortcode.attrs.named, this.defaults )
  807. });
  808. return frame;
  809. },
  810. /**
  811. * Generates an audio shortcode.
  812. *
  813. * @since 4.2.0
  814. *
  815. * @param {Array} model Array with attributes for the shortcode.
  816. * @return {wp.shortcode} The audio shortcode object.
  817. */
  818. shortcode : function( model ) {
  819. var content;
  820. _.each( this.defaults, function( value, key ) {
  821. model[ key ] = this.coerce( model, key );
  822. if ( value === model[ key ] ) {
  823. delete model[ key ];
  824. }
  825. }, this );
  826. content = model.content;
  827. delete model.content;
  828. return new wp.shortcode({
  829. tag: 'audio',
  830. attrs: model,
  831. content: content
  832. });
  833. }
  834. };
  835. /**
  836. * Shortcode modeling for video.
  837. *
  838. * `edit()` prepares the shortcode for the media modal.
  839. * `shortcode()` builds the new shortcode after update.
  840. *
  841. * @since 4.2.0
  842. *
  843. * @namespace
  844. */
  845. wp.media.video = {
  846. coerce : wp.media.coerce,
  847. defaults : {
  848. id : wp.media.view.settings.post.id,
  849. src : '',
  850. poster : '',
  851. loop : false,
  852. autoplay : false,
  853. preload : 'metadata',
  854. content : '',
  855. width : 640,
  856. height : 360
  857. },
  858. /**
  859. * Instantiates a new media object with the next matching shortcode.
  860. *
  861. * @since 4.2.0
  862. *
  863. * @param {string} data The text to apply the shortcode on.
  864. * @return {wp.media} The media object.
  865. */
  866. edit : function( data ) {
  867. var frame,
  868. shortcode = wp.shortcode.next( 'video', data ).shortcode,
  869. attrs;
  870. attrs = shortcode.attrs.named;
  871. attrs.content = shortcode.content;
  872. frame = wp.media({
  873. frame: 'video',
  874. state: 'video-details',
  875. metadata: _.defaults( attrs, this.defaults )
  876. });
  877. return frame;
  878. },
  879. /**
  880. * Generates an video shortcode.
  881. *
  882. * @since 4.2.0
  883. *
  884. * @param {Array} model Array with attributes for the shortcode.
  885. * @return {wp.shortcode} The video shortcode object.
  886. */
  887. shortcode : function( model ) {
  888. var content;
  889. _.each( this.defaults, function( value, key ) {
  890. model[ key ] = this.coerce( model, key );
  891. if ( value === model[ key ] ) {
  892. delete model[ key ];
  893. }
  894. }, this );
  895. content = model.content;
  896. delete model.content;
  897. return new wp.shortcode({
  898. tag: 'video',
  899. attrs: model,
  900. content: content
  901. });
  902. }
  903. };
  904. media.model.PostMedia = __webpack_require__( 6615 );
  905. media.controller.AudioDetails = __webpack_require__( 6045 );
  906. media.controller.VideoDetails = __webpack_require__( 580 );
  907. media.view.MediaFrame.MediaDetails = __webpack_require__( 6445 );
  908. media.view.MediaFrame.AudioDetails = __webpack_require__( 5262 );
  909. media.view.MediaFrame.VideoDetails = __webpack_require__( 2075 );
  910. media.view.MediaDetails = __webpack_require__( 8867 );
  911. media.view.AudioDetails = __webpack_require__( 1764 );
  912. media.view.VideoDetails = __webpack_require__( 7697 );
  913. }();
  914. /******/ })()
  915. ;