[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

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

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


Generated: Thu Apr 18 01:00:02 2024 Cross-referenced by PHPXref 0.7.1