home *** CD-ROM | disk | FTP | other *** search
/ HTML Examples / WP.iso / wordpress2 / wp-includes / js / media-audiovideo.js < prev    next >
Encoding:
JavaScript  |  2017-10-06  |  25.6 KB  |  1,105 lines

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