Changeset 30642
- Timestamp:
- 11/30/2014 08:44:21 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/js/mce-view.js
r29779 r30642 15 15 instances = {}, 16 16 media = wp.media, 17 mediaWindows = [], 18 windowIdx = 0, 19 waitInterval = 50, 17 20 viewOptions = ['encodedText']; 18 21 … … 229 232 }); 230 233 } 231 }, 50);234 }, waitInterval ); 232 235 }); 233 236 } else { … … 592 595 593 596 this.getEditors( function( editor ) { 594 editor.on( 'hide', self.stopPlayers ); 597 editor.on( 'hide', function () { 598 mediaWindows = []; 599 windowIdx = 0; 600 self.stopPlayers(); 601 } ); 595 602 }); 603 }, 604 605 pauseOtherWindows: function ( win ) { 606 _.each( mediaWindows, function ( mediaWindow ) { 607 if ( mediaWindow.sandboxId !== win.sandboxId ) { 608 _.each( mediaWindow.mejs.players, function ( player ) { 609 player.pause(); 610 } ); 611 } 612 } ); 613 }, 614 615 iframeLoaded: function (win) { 616 return _.bind( function () { 617 var callback; 618 if ( ! win.mejs || _.isEmpty( win.mejs.players ) ) { 619 return; 620 } 621 622 win.sandboxId = windowIdx; 623 windowIdx++; 624 mediaWindows.push( win ); 625 626 callback = _.bind( function () { 627 this.pauseOtherWindows( win ); 628 }, this ); 629 630 if ( ! _.isEmpty( win.mejs.MediaPluginBridge.pluginMediaElements ) ) { 631 _.each( win.mejs.MediaPluginBridge.pluginMediaElements, function ( mediaElement ) { 632 mediaElement.addEventListener( 'play', callback ); 633 } ); 634 } 635 636 _.each( win.mejs.players, function ( player ) { 637 $( player.node ).on( 'play', callback ); 638 }, this ); 639 }, this ); 640 }, 641 642 listenToSandboxes: function () { 643 _.each( this.getNodes(), function ( node ) { 644 var win, iframe = $( '.wpview-sandbox', node ).get( 0 ); 645 if ( iframe && ( win = iframe.contentWindow ) ) { 646 $( win ).load( _.bind( this.iframeLoaded( win ), this ) ); 647 } 648 }, this ); 649 }, 650 651 deferredListen: function () { 652 window.setTimeout( _.bind( this.listenToSandboxes, this ), this.getNodes().length * waitInterval ); 596 653 }, 597 654 … … 599 656 if ( this.parsed ) { 600 657 this.setIframes( this.parsed.head, this.parsed.body ); 658 this.deferredListen(); 601 659 } else { 602 660 this.fail(); … … 618 676 self.parsed = response; 619 677 self.setIframes( response.head, response.body ); 678 self.deferredListen(); 620 679 } else { 621 680 self.fail( true );
Note: See TracChangeset
for help on using the changeset viewer.