Ticket #28458: 28458.2.patch
File 28458.2.patch, 2.9 KB (added by , 10 years ago) |
---|
-
src/wp-includes/js/mce-view.js
270 270 }; 271 271 }, 272 272 View: wp.mce.View.extend({ 273 className: 'editor-gallery',274 273 template: media.template('editor-gallery'), 275 274 276 275 // The fallback post ID to use as a parent for galleries that don't … … 489 488 shortcode: 'video', 490 489 state: 'video-details', 491 490 View: wp.mce.media.View.extend({ 492 className: 'editor-video',493 491 template: media.template('editor-video') 494 492 }) 495 493 } ); … … 504 502 shortcode: 'audio', 505 503 state: 'audio-details', 506 504 View: wp.mce.media.View.extend({ 507 className: 'editor-audio',508 505 template: media.template('editor-audio') 509 506 }) 510 507 } ); … … 518 515 * @mixes wp.media.mixin 519 516 */ 520 517 wp.mce.media.PlaylistView = wp.mce.View.extend({ 521 className: 'editor-playlist',522 518 template: media.template('editor-playlist'), 523 519 524 520 initialize: function( options ) { … … 531 527 $( document ).on( 'media:edit', this.pausePlayers ); 532 528 533 529 this.fetch(); 530 531 $( this ).on( 'ready', this.setPlaylist ); 534 532 }, 535 533 536 534 /** … … 540 538 this.attachments = wp.media.playlist.attachments( this.shortcode ); 541 539 this.dfd = this.attachments.more().done( _.bind( this.render, this ) ); 542 540 }, 541 542 setPlaylist: function( event, element ) { 543 if ( ! this.data.tracks ) { 544 return; 545 } 543 546 544 /** 545 * Get the HTML for the view (which also set's the data), replace the 546 * current HTML, and then invoke the WPPlaylistView instance to render 547 * the playlist in the editor 548 * 549 * @global WPPlaylistView 550 * @global tinymce.editors 551 */ 552 render: function() { 553 var html = this.getHtml(), self = this; 554 555 _.each( tinymce.editors, function( editor ) { 556 var doc; 557 if ( editor.plugins.wpview ) { 558 doc = editor.getDoc(); 559 $( doc ).find( '[data-wpview-text="' + this.encodedText + '"]' ).each(function (i, elem) { 560 var node = $( elem ); 561 562 // The <ins> is used to mark the end of the wrapper div. Needed when comparing 563 // the content as string for preventing extra undo levels. 564 node.html( html ).append( '<ins data-wpview-end="1"></ins>' ); 565 566 if ( ! self.data.tracks ) { 567 return; 568 } 569 570 self.players.push( new WPPlaylistView({ 571 el: $( elem ).find( '.wp-playlist' ).get(0), 572 metadata: self.data 573 }).player ); 574 }); 575 } 576 }, this ); 547 this.players.push( new WPPlaylistView( { 548 el: $( element ).find( '.wp-playlist' ).get( 0 ), 549 metadata: this.data 550 } ).player ); 577 551 }, 578 552 579 553 /** … … 684 658 shortcode: 'embed', 685 659 toView: wp.mce.gallery.toView, 686 660 View: wp.mce.View.extend( { 687 className: 'editor-embed',688 661 template: media.template( 'editor-embed' ), 689 662 initialize: function( options ) { 690 663 this.players = [];