You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1082 lines
24 KiB

1 year ago
  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. _ajax_nonce: wp.media.view.settings.nonce.setAttachmentThumbnail,
  427. urls: urls,
  428. thumbnail_id: attachment.get( 'id' )
  429. }
  430. } );
  431. } );
  432. },
  433. renderAddTrackToolbar: function() {
  434. this.setPrimaryButton( l10n.videoAddTrackTitle, function( controller, state ) {
  435. var attachment = state.get( 'selection' ).single(),
  436. content = controller.media.get( 'content' );
  437. if ( -1 === content.indexOf( attachment.get( 'url' ) ) ) {
  438. content += [
  439. '<track srclang="en" label="English" kind="subtitles" src="',
  440. attachment.get( 'url' ),
  441. '" />'
  442. ].join('');
  443. controller.media.set( 'content', content );
  444. }
  445. state.trigger( 'add-track', controller.media.toJSON() );
  446. } );
  447. }
  448. });
  449. module.exports = VideoDetails;
  450. /***/ }),
  451. /***/ 8867:
  452. /***/ (function(module) {
  453. /* global MediaElementPlayer */
  454. var AttachmentDisplay = wp.media.view.Settings.AttachmentDisplay,
  455. $ = jQuery,
  456. MediaDetails;
  457. /**
  458. * wp.media.view.MediaDetails
  459. *
  460. * @memberOf wp.media.view
  461. *
  462. * @class
  463. * @augments wp.media.view.Settings.AttachmentDisplay
  464. * @augments wp.media.view.Settings
  465. * @augments wp.media.View
  466. * @augments wp.Backbone.View
  467. * @augments Backbone.View
  468. */
  469. MediaDetails = AttachmentDisplay.extend(/** @lends wp.media.view.MediaDetails.prototype */{
  470. initialize: function() {
  471. _.bindAll(this, 'success');
  472. this.players = [];
  473. this.listenTo( this.controller.states, 'close', wp.media.mixin.unsetPlayers );
  474. this.on( 'ready', this.setPlayer );
  475. this.on( 'media:setting:remove', wp.media.mixin.unsetPlayers, this );
  476. this.on( 'media:setting:remove', this.render );
  477. this.on( 'media:setting:remove', this.setPlayer );
  478. AttachmentDisplay.prototype.initialize.apply( this, arguments );
  479. },
  480. events: function(){
  481. return _.extend( {
  482. 'click .remove-setting' : 'removeSetting',
  483. 'change .content-track' : 'setTracks',
  484. 'click .remove-track' : 'setTracks',
  485. 'click .add-media-source' : 'addSource'
  486. }, AttachmentDisplay.prototype.events );
  487. },
  488. prepare: function() {
  489. return _.defaults({
  490. model: this.model.toJSON()
  491. }, this.options );
  492. },
  493. /**
  494. * Remove a setting's UI when the model unsets it
  495. *
  496. * @fires wp.media.view.MediaDetails#media:setting:remove
  497. *
  498. * @param {Event} e
  499. */
  500. removeSetting : function(e) {
  501. var wrap = $( e.currentTarget ).parent(), setting;
  502. setting = wrap.find( 'input' ).data( 'setting' );
  503. if ( setting ) {
  504. this.model.unset( setting );
  505. this.trigger( 'media:setting:remove', this );
  506. }
  507. wrap.remove();
  508. },
  509. /**
  510. *
  511. * @fires wp.media.view.MediaDetails#media:setting:remove
  512. */
  513. setTracks : function() {
  514. var tracks = '';
  515. _.each( this.$('.content-track'), function(track) {
  516. tracks += $( track ).val();
  517. } );
  518. this.model.set( 'content', tracks );
  519. this.trigger( 'media:setting:remove', this );
  520. },
  521. addSource : function( e ) {
  522. this.controller.lastMime = $( e.currentTarget ).data( 'mime' );
  523. this.controller.setState( 'add-' + this.controller.defaults.id + '-source' );
  524. },
  525. loadPlayer: function () {
  526. this.players.push( new MediaElementPlayer( this.media, this.settings ) );
  527. this.scriptXhr = false;
  528. },
  529. setPlayer : function() {
  530. var src;
  531. if ( this.players.length || ! this.media || this.scriptXhr ) {
  532. return;
  533. }
  534. src = this.model.get( 'src' );
  535. if ( src && src.indexOf( 'vimeo' ) > -1 && ! ( 'Vimeo' in window ) ) {
  536. this.scriptXhr = $.getScript( 'https://player.vimeo.com/api/player.js', _.bind( this.loadPlayer, this ) );
  537. } else {
  538. this.loadPlayer();
  539. }
  540. },
  541. /**
  542. * @abstract
  543. */
  544. setMedia : function() {
  545. return this;
  546. },
  547. success : function(mejs) {
  548. var autoplay = mejs.attributes.autoplay && 'false' !== mejs.attributes.autoplay;
  549. if ( 'flash' === mejs.pluginType && autoplay ) {
  550. mejs.addEventListener( 'canplay', function() {
  551. mejs.play();
  552. }, false );
  553. }
  554. this.mejs = mejs;
  555. },
  556. /**
  557. * @return {media.view.MediaDetails} Returns itself to allow chaining.
  558. */
  559. render: function() {
  560. AttachmentDisplay.prototype.render.apply( this, arguments );
  561. setTimeout( _.bind( function() {
  562. this.scrollToTop();
  563. }, this ), 10 );
  564. this.settings = _.defaults( {
  565. success : this.success
  566. }, wp.media.mixin.mejsSettings );
  567. return this.setMedia();
  568. },
  569. scrollToTop: function() {
  570. this.$( '.embed-media-settings' ).scrollTop( 0 );
  571. }
  572. },/** @lends wp.media.view.MediaDetails */{
  573. instances : 0,
  574. /**
  575. * When multiple players in the DOM contain the same src, things get weird.
  576. *
  577. * @param {HTMLElement} elem
  578. * @return {HTMLElement}
  579. */
  580. prepareSrc : function( elem ) {
  581. var i = MediaDetails.instances++;
  582. _.each( $( elem ).find( 'source' ), function( source ) {
  583. source.src = [
  584. source.src,
  585. source.src.indexOf('?') > -1 ? '&' : '?',
  586. '_=',
  587. i
  588. ].join('');
  589. } );
  590. return elem;
  591. }
  592. });
  593. module.exports = MediaDetails;
  594. /***/ }),
  595. /***/ 7697:
  596. /***/ (function(module) {
  597. var MediaDetails = wp.media.view.MediaDetails,
  598. VideoDetails;
  599. /**
  600. * wp.media.view.VideoDetails
  601. *
  602. * @memberOf wp.media.view
  603. *
  604. * @class
  605. * @augments wp.media.view.MediaDetails
  606. * @augments wp.media.view.Settings.AttachmentDisplay
  607. * @augments wp.media.view.Settings
  608. * @augments wp.media.View
  609. * @augments wp.Backbone.View
  610. * @augments Backbone.View
  611. */
  612. VideoDetails = MediaDetails.extend(/** @lends wp.media.view.VideoDetails.prototype */{
  613. className: 'video-details',
  614. template: wp.template('video-details'),
  615. setMedia: function() {
  616. var video = this.$('.wp-video-shortcode');
  617. if ( video.find( 'source' ).length ) {
  618. if ( video.is(':hidden') ) {
  619. video.show();
  620. }
  621. if ( ! video.hasClass( 'youtube-video' ) && ! video.hasClass( 'vimeo-video' ) ) {
  622. this.media = MediaDetails.prepareSrc( video.get(0) );
  623. } else {
  624. this.media = video.get(0);
  625. }
  626. } else {
  627. video.hide();
  628. this.media = false;
  629. }
  630. return this;
  631. }
  632. });
  633. module.exports = VideoDetails;
  634. /***/ })
  635. /******/ });
  636. /************************************************************************/
  637. /******/ // The module cache
  638. /******/ var __webpack_module_cache__ = {};
  639. /******/
  640. /******/ // The require function
  641. /******/ function __webpack_require__(moduleId) {
  642. /******/ // Check if module is in cache
  643. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  644. /******/ if (cachedModule !== undefined) {
  645. /******/ return cachedModule.exports;
  646. /******/ }
  647. /******/ // Create a new module (and put it into the cache)
  648. /******/ var module = __webpack_module_cache__[moduleId] = {
  649. /******/ // no module.id needed
  650. /******/ // no module.loaded needed
  651. /******/ exports: {}
  652. /******/ };
  653. /******/
  654. /******/ // Execute the module function
  655. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  656. /******/
  657. /******/ // Return the exports of the module
  658. /******/ return module.exports;
  659. /******/ }
  660. /******/
  661. /************************************************************************/
  662. var __webpack_exports__ = {};
  663. // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
  664. !function() {
  665. /**
  666. * @output wp-includes/js/media-audiovideo.js
  667. */
  668. var media = wp.media,
  669. baseSettings = window._wpmejsSettings || {},
  670. l10n = window._wpMediaViewsL10n || {};
  671. /**
  672. *
  673. * Defines the wp.media.mixin object.
  674. *
  675. * @mixin
  676. *
  677. * @since 4.2.0
  678. */
  679. wp.media.mixin = {
  680. mejsSettings: baseSettings,
  681. /**
  682. * Pauses and removes all players.
  683. *
  684. * @since 4.2.0
  685. *
  686. * @return {void}
  687. */
  688. removeAllPlayers: function() {
  689. var p;
  690. if ( window.mejs && window.mejs.players ) {
  691. for ( p in window.mejs.players ) {
  692. window.mejs.players[p].pause();
  693. this.removePlayer( window.mejs.players[p] );
  694. }
  695. }
  696. },
  697. /**
  698. * Removes the player.
  699. *
  700. * Override the MediaElement method for removing a player.
  701. * MediaElement tries to pull the audio/video tag out of
  702. * its container and re-add it to the DOM.
  703. *
  704. * @since 4.2.0
  705. *
  706. * @return {void}
  707. */
  708. removePlayer: function(t) {
  709. var featureIndex, feature;
  710. if ( ! t.options ) {
  711. return;
  712. }
  713. // Invoke features cleanup.
  714. for ( featureIndex in t.options.features ) {
  715. feature = t.options.features[featureIndex];
  716. if ( t['clean' + feature] ) {
  717. try {
  718. t['clean' + feature](t);
  719. } catch (e) {}
  720. }
  721. }
  722. if ( ! t.isDynamic ) {
  723. t.node.remove();
  724. }
  725. if ( 'html5' !== t.media.rendererName ) {
  726. t.media.remove();
  727. }
  728. delete window.mejs.players[t.id];
  729. t.container.remove();
  730. t.globalUnbind('resize', t.globalResizeCallback);
  731. t.globalUnbind('keydown', t.globalKeydownCallback);
  732. t.globalUnbind('click', t.globalClickCallback);
  733. delete t.media.player;
  734. },
  735. /**
  736. *
  737. * Removes and resets all players.
  738. *
  739. * Allows any class that has set 'player' to a MediaElementPlayer
  740. * instance to remove the player when listening to events.
  741. *
  742. * Examples: modal closes, shortcode properties are removed, etc.
  743. *
  744. * @since 4.2.0
  745. */
  746. unsetPlayers : function() {
  747. if ( this.players && this.players.length ) {
  748. _.each( this.players, function (player) {
  749. player.pause();
  750. wp.media.mixin.removePlayer( player );
  751. } );
  752. this.players = [];
  753. }
  754. }
  755. };
  756. /**
  757. * Shortcode modeling for playlists.
  758. *
  759. * @since 4.2.0
  760. */
  761. wp.media.playlist = new wp.media.collection({
  762. tag: 'playlist',
  763. editTitle : l10n.editPlaylistTitle,
  764. defaults : {
  765. id: wp.media.view.settings.post.id,
  766. style: 'light',
  767. tracklist: true,
  768. tracknumbers: true,
  769. images: true,
  770. artists: true,
  771. type: 'audio'
  772. }
  773. });
  774. /**
  775. * Shortcode modeling for audio.
  776. *
  777. * `edit()` prepares the shortcode for the media modal.
  778. * `shortcode()` builds the new shortcode after an update.
  779. *
  780. * @namespace
  781. *
  782. * @since 4.2.0
  783. */
  784. wp.media.audio = {
  785. coerce : wp.media.coerce,
  786. defaults : {
  787. id : wp.media.view.settings.post.id,
  788. src : '',
  789. loop : false,
  790. autoplay : false,
  791. preload : 'none',
  792. width : 400
  793. },
  794. /**
  795. * Instantiates a new media object with the next matching shortcode.
  796. *
  797. * @since 4.2.0
  798. *
  799. * @param {string} data The text to apply the shortcode on.
  800. * @return {wp.media} The media object.
  801. */
  802. edit : function( data ) {
  803. var frame, shortcode = wp.shortcode.next( 'audio', data ).shortcode;
  804. frame = wp.media({
  805. frame: 'audio',
  806. state: 'audio-details',
  807. metadata: _.defaults( shortcode.attrs.named, this.defaults )
  808. });
  809. return frame;
  810. },
  811. /**
  812. * Generates an audio shortcode.
  813. *
  814. * @since 4.2.0
  815. *
  816. * @param {Array} model Array with attributes for the shortcode.
  817. * @return {wp.shortcode} The audio shortcode object.
  818. */
  819. shortcode : function( model ) {
  820. var content;
  821. _.each( this.defaults, function( value, key ) {
  822. model[ key ] = this.coerce( model, key );
  823. if ( value === model[ key ] ) {
  824. delete model[ key ];
  825. }
  826. }, this );
  827. content = model.content;
  828. delete model.content;
  829. return new wp.shortcode({
  830. tag: 'audio',
  831. attrs: model,
  832. content: content
  833. });
  834. }
  835. };
  836. /**
  837. * Shortcode modeling for video.
  838. *
  839. * `edit()` prepares the shortcode for the media modal.
  840. * `shortcode()` builds the new shortcode after update.
  841. *
  842. * @since 4.2.0
  843. *
  844. * @namespace
  845. */
  846. wp.media.video = {
  847. coerce : wp.media.coerce,
  848. defaults : {
  849. id : wp.media.view.settings.post.id,
  850. src : '',
  851. poster : '',
  852. loop : false,
  853. autoplay : false,
  854. preload : 'metadata',
  855. content : '',
  856. width : 640,
  857. height : 360
  858. },
  859. /**
  860. * Instantiates a new media object with the next matching shortcode.
  861. *
  862. * @since 4.2.0
  863. *
  864. * @param {string} data The text to apply the shortcode on.
  865. * @return {wp.media} The media object.
  866. */
  867. edit : function( data ) {
  868. var frame,
  869. shortcode = wp.shortcode.next( 'video', data ).shortcode,
  870. attrs;
  871. attrs = shortcode.attrs.named;
  872. attrs.content = shortcode.content;
  873. frame = wp.media({
  874. frame: 'video',
  875. state: 'video-details',
  876. metadata: _.defaults( attrs, this.defaults )
  877. });
  878. return frame;
  879. },
  880. /**
  881. * Generates an video shortcode.
  882. *
  883. * @since 4.2.0
  884. *
  885. * @param {Array} model Array with attributes for the shortcode.
  886. * @return {wp.shortcode} The video shortcode object.
  887. */
  888. shortcode : function( model ) {
  889. var content;
  890. _.each( this.defaults, function( value, key ) {
  891. model[ key ] = this.coerce( model, key );
  892. if ( value === model[ key ] ) {
  893. delete model[ key ];
  894. }
  895. }, this );
  896. content = model.content;
  897. delete model.content;
  898. return new wp.shortcode({
  899. tag: 'video',
  900. attrs: model,
  901. content: content
  902. });
  903. }
  904. };
  905. media.model.PostMedia = __webpack_require__( 6615 );
  906. media.controller.AudioDetails = __webpack_require__( 6045 );
  907. media.controller.VideoDetails = __webpack_require__( 580 );
  908. media.view.MediaFrame.MediaDetails = __webpack_require__( 6445 );
  909. media.view.MediaFrame.AudioDetails = __webpack_require__( 5262 );
  910. media.view.MediaFrame.VideoDetails = __webpack_require__( 2075 );
  911. media.view.MediaDetails = __webpack_require__( 8867 );
  912. media.view.AudioDetails = __webpack_require__( 1764 );
  913. media.view.VideoDetails = __webpack_require__( 7697 );
  914. }();
  915. /******/ })()
  916. ;