Нет описания

media-audiovideo.js 27KB

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