[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/js/ -> media-audiovideo.js (source)

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


Generated: Sat Jun 12 01:00:05 2021 Cross-referenced by PHPXref 0.7.1