Changeset 27785
- Timestamp:
- 03/27/2014 05:57:30 PM (11 years ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/js/mce-view.js
r27750 r27785 365 365 var media = wp.media[ this.shortcode ], 366 366 self = this, 367 frame, data ;367 frame, data, callback; 368 368 369 369 wp.media.mixin.pauseAllPlayers(); … … 374 374 frame.detach(); 375 375 } ); 376 frame.state( self.state ).on( 'update', function( selection ) { 376 377 callback = function( selection ) { 377 378 var shortcode = wp.media[ self.shortcode ].shortcode( selection ).string(); 378 379 $( node ).attr( 'data-wpview-text', window.encodeURIComponent( shortcode ) ); 379 380 wp.mce.views.refreshView( self, shortcode ); 380 381 frame.detach(); 381 } ); 382 }; 383 if ( _.isArray( self.state ) ) { 384 _.each( self.state, function (state) { 385 frame.state( state ).on( 'update', callback ); 386 } ); 387 } else { 388 frame.state( self.state ).on( 'update', callback ); 389 } 382 390 frame.open(); 383 391 } … … 532 540 */ 533 541 fetch: function() { 534 this.attachments = wp.media [ this.shortcode.tag ].attachments( this.shortcode );542 this.attachments = wp.media.playlist.attachments( this.shortcode ); 535 543 this.attachments.more().done( this.setPlayer ); 536 544 }, … … 580 588 getHtml: function() { 581 589 var data = this.shortcode.attrs.named, 582 model = wp.media[ this.shortcode.tag ], 583 type = 'playlist' === this.shortcode.tag ? 'audio' : 'video', 590 model = wp.media.playlist, 584 591 options, 585 592 attachments, … … 597 604 598 605 options = { 599 type: type,606 type: data.type, 600 607 style: data.style, 601 608 tracklist: data.tracklist, … … 615 622 }; 616 623 617 if ( 'video' === type ) {624 if ( 'video' === data.type ) { 618 625 size.width = attachment.width; 619 626 size.height = attachment.height; … … 660 667 wp.mce.playlist = _.extend( {}, wp.mce.media, { 661 668 shortcode: 'playlist', 662 state: 'playlist-edit',669 state: ['playlist-edit', 'video-playlist-edit'], 663 670 View: wp.mce.media.PlaylistView 664 671 } ); 665 672 wp.mce.views.register( 'playlist', wp.mce.playlist ); 666 667 /**668 * TinyMCE handler for the video-playlist shortcode669 *670 * @mixes wp.mce.media671 */672 wp.mce['video-playlist'] = _.extend( {}, wp.mce.media, {673 shortcode: 'video-playlist',674 state: 'video-playlist-edit',675 View: wp.mce.media.PlaylistView676 } );677 wp.mce.views.register( 'video-playlist', wp.mce['video-playlist'] );678 673 }(jQuery)); -
trunk/src/wp-includes/js/media-audiovideo.js
r27750 r27785 177 177 wp.media.playlist = new wp.media.collection({ 178 178 tag: 'playlist', 179 type : 'audio',180 179 editTitle : l10n.editPlaylistTitle, 181 180 defaults : { … … 185 184 tracknumbers: true, 186 185 images: true, 187 artists: true 188 } 189 }); 190 191 wp.media['video-playlist'] = new wp.media.collection({ 192 tag: 'video-playlist', 193 type : 'video', 194 editTitle : l10n.editVideoPlaylistTitle, 195 defaults : { 196 id: wp.media.view.settings.post.id, 197 style: 'light', 198 tracklist: false, 199 tracknumbers: false, 200 images: true 186 artists: true, 187 type: 'audio' 201 188 } 202 189 }); … … 954 941 counts.audio = a; 955 942 counts.video = v; 956 943 957 944 return counts; 958 945 }; 959 }(media.view.settings)), 960 961 /** 962 * Return the playlist states for MediaFrame.Post 963 * 964 * @param {Object} options 965 * @returns {Array} 966 */ 967 states : function(options) { 968 return [ 969 new media.controller.Library({ 970 id: 'playlist', 971 title: l10n.createPlaylistTitle, 972 priority: 60, 973 toolbar: 'main-playlist', 974 filterable: 'uploaded', 975 multiple: 'add', 976 editable: false, 977 978 library: media.query( _.defaults({ 979 type: 'audio' 980 }, options.library ) ) 981 }), 982 983 // Playlist states. 984 new media.controller.CollectionEdit({ 985 type: 'audio', 986 collectionType: 'playlist', 987 title: l10n.editPlaylistTitle, 988 SettingsView: media.view.Settings.Playlist, 989 library: options.selection, 990 editing: options.editing, 991 menu: 'playlist', 992 dragInfoText: l10n.playlistDragInfo, 993 dragInfo: false 994 }), 995 996 new media.controller.CollectionAdd({ 997 type: 'audio', 998 collectionType: 'playlist', 999 title: l10n.addToPlaylistTitle 1000 }) 1001 ]; 1002 }, 1003 1004 /** 1005 * Return the video-playlist states for MediaFrame.Post 1006 * 1007 * @param {Object} options 1008 * @returns {Array} 1009 */ 1010 videoStates : function(options) { 1011 return [ 1012 new media.controller.Library({ 1013 id: 'video-playlist', 1014 title: l10n.createVideoPlaylistTitle, 1015 priority: 60, 1016 toolbar: 'main-video-playlist', 1017 filterable: 'uploaded', 1018 multiple: 'add', 1019 editable: false, 1020 1021 library: media.query( _.defaults({ 1022 type: 'video' 1023 }, options.library ) ) 1024 }), 1025 1026 // Video Playlist states. 1027 new media.controller.CollectionEdit({ 1028 type: 'video', 1029 collectionType: 'video-playlist', 1030 title: l10n.editVideoPlaylistTitle, 1031 SettingsView: media.view.Settings.Playlist, 1032 library: options.selection, 1033 editing: options.editing, 1034 menu: 'video-playlist', 1035 dragInfoText: l10n.videoPlaylistDragInfo, 1036 dragInfo: false 1037 }), 1038 1039 new media.controller.CollectionAdd({ 1040 type: 'video', 1041 collectionType: 'video-playlist', 1042 title: l10n.addToVideoPlaylistTitle 1043 }) 1044 ]; 1045 } 946 }(media.view.settings)) 1046 947 } ); 1047 948 -
trunk/src/wp-includes/js/media-editor.js
r27659 r27785 406 406 shortcode, clone, self = this; 407 407 408 if ( attachments.type ) { 409 attrs.type = attachments.type; 410 delete attachments.type; 411 } 412 408 413 if ( attachments[this.tag] ) { 409 414 _.extend( attrs, attachments[this.tag].toJSON() ); … … 478 483 var shortcode = wp.shortcode.next( this.tag, content ), 479 484 defaultPostId = this.defaults.id, 480 attachments, selection ;485 attachments, selection, state; 481 486 482 487 // Bail if we didn't match the shortcode or all of the content. … … 515 520 } 516 521 517 // Store the current gallery frame. 522 if ( shortcode.attrs.named.type && 'video' === shortcode.attrs.named.type ) { 523 state = 'video-' + this.tag + '-edit'; 524 } else { 525 state = this.tag + '-edit'; 526 } 527 528 // Store the current frame. 518 529 this.frame = wp.media({ 519 530 frame: 'post', 520 state: this.tag + '-edit',531 state: state, 521 532 title: this.editTitle, 522 533 editing: true, … … 787 798 * @this wp.media.editor 788 799 */ 789 this.insert( wp.media ['video-playlist'].shortcode( selection ).string() );800 this.insert( wp.media.playlist.shortcode( selection ).string() ); 790 801 }, this ); 791 802 -
trunk/src/wp-includes/js/media-views.js
r27756 r27785 793 793 initialize: function() { 794 794 var collectionType = this.get('collectionType'); 795 796 if ( 'video' === this.get( 'type' ) ) { 797 collectionType = 'video-' + collectionType; 798 } 795 799 796 800 this.set( 'id', collectionType + '-edit' ); … … 1887 1891 1888 1892 createStates: function() { 1889 var options = this.options , counts;1893 var options = this.options; 1890 1894 1891 1895 // Add the default states. … … 1947 1951 collectionType: 'gallery', 1948 1952 title: l10n.addToGalleryTitle 1953 }), 1954 1955 new media.controller.Library({ 1956 id: 'playlist', 1957 title: l10n.createPlaylistTitle, 1958 priority: 60, 1959 toolbar: 'main-playlist', 1960 filterable: 'uploaded', 1961 multiple: 'add', 1962 editable: false, 1963 1964 library: media.query( _.defaults({ 1965 type: 'audio' 1966 }, options.library ) ) 1967 }), 1968 1969 // Playlist states. 1970 new media.controller.CollectionEdit({ 1971 type: 'audio', 1972 collectionType: 'playlist', 1973 title: l10n.editPlaylistTitle, 1974 SettingsView: media.view.Settings.Playlist, 1975 library: options.selection, 1976 editing: options.editing, 1977 menu: 'playlist', 1978 dragInfoText: l10n.playlistDragInfo, 1979 dragInfo: false 1980 }), 1981 1982 new media.controller.CollectionAdd({ 1983 type: 'audio', 1984 collectionType: 'playlist', 1985 title: l10n.addToPlaylistTitle 1986 }), 1987 1988 new media.controller.Library({ 1989 id: 'video-playlist', 1990 title: l10n.createVideoPlaylistTitle, 1991 priority: 60, 1992 toolbar: 'main-video-playlist', 1993 filterable: 'uploaded', 1994 multiple: 'add', 1995 editable: false, 1996 1997 library: media.query( _.defaults({ 1998 type: 'video' 1999 }, options.library ) ) 2000 }), 2001 2002 new media.controller.CollectionEdit({ 2003 type: 'video', 2004 collectionType: 'playlist', 2005 title: l10n.editVideoPlaylistTitle, 2006 SettingsView: media.view.Settings.Playlist, 2007 library: options.selection, 2008 editing: options.editing, 2009 menu: 'video-playlist', 2010 dragInfoText: l10n.playlistDragInfo, 2011 dragInfo: false 2012 }), 2013 2014 new media.controller.CollectionAdd({ 2015 type: 'video', 2016 collectionType: 'playlist', 2017 title: l10n.addToVideoPlaylistTitle 1949 2018 }) 1950 2019 ]); 1951 1952 counts = media.playlist.counts();1953 1954 if ( counts.audio ) {1955 this.states.add( media.playlist.states(options) );1956 }1957 1958 if ( counts.video ) {1959 this.states.add( media.playlist.videoStates(options) );1960 }1961 2020 1962 2021 if ( media.view.settings.post.featuredImageId ) { … … 2423 2482 click: function() { 2424 2483 var controller = this.controller, 2425 state = controller.state(); 2484 state = controller.state(), 2485 library = state.get('library'); 2486 2487 library.type = 'video'; 2426 2488 2427 2489 controller.close(); 2428 state.trigger( 'update', state.get('library'));2490 state.trigger( 'update', library ); 2429 2491 2430 2492 // Restore and reset the default state. -
trunk/src/wp-includes/js/mediaelement/wp-mediaelement.js
r27450 r27785 7 7 $(function () { 8 8 var settings = {}; 9 10 if ( $( document.body ).hasClass( 'mce-content-body' ) ) { 11 return; 12 } 9 13 10 14 if ( typeof _wpmejsSettings !== 'undefined' ) { -
trunk/src/wp-includes/media-template.php
r27777 r27785 518 518 <h3><?php _e( 'Playlist Settings' ); ?></h3> 519 519 520 <?php 521 $playlist_styles = array( 522 'light' => _x( 'Light', 'playlist theme' ), 523 'dark' => _x( 'Dark', 'playlist theme' ) 524 ); 525 526 /** This filter is documented in wp-includes/media.php */ 527 $styles = apply_filters( 'playlist_styles', $playlist_styles ); 528 529 if ( ! empty( $styles ) ): ?> 520 <# var emptyModel = _.isEmpty( data.model ); #> 521 530 522 <label class="setting"> 531 <span><?php _e( 'Style' ); ?></span> 532 <select class="style" data-setting="style"> 533 <?php foreach ( $styles as $slug => $label ): ?> 534 <option value="<?php echo esc_attr( $slug ) ?>"> 535 <?php echo $label ?> 536 </option> 537 <?php endforeach ?> 538 </select> 539 </label> 540 <?php endif; ?> 541 542 <# 543 var playlist = 'playlist-edit' === data.controller.id, emptyModel = _.isEmpty(data.model); 544 #> 545 <label class="setting"> 546 <input type="checkbox" data-setting="_orderbyRandom" /> 547 <span><?php _e( 'Random Order' ); ?></span> 548 </label> 549 550 <label class="setting"> 551 <input type="checkbox" data-setting="tracklist" <# if ( playlist && emptyModel ) { #> 523 <input type="checkbox" data-setting="tracklist" <# if ( emptyModel ) { #> 552 524 checked="checked" 553 525 <# } #> /> … … 556 528 557 529 <label class="setting"> 558 <input type="checkbox" data-setting="tracknumbers" <# if ( playlist &&emptyModel ) { #>530 <input type="checkbox" data-setting="tracknumbers" <# if ( emptyModel ) { #> 559 531 checked="checked" 560 532 <# } #> /> … … 562 534 </label> 563 535 564 <# if ( playlist) { #>536 <# if ( 'audio' === data.model.type ) { #> 565 537 <label class="setting"> 566 <input type="checkbox" data-setting="artists" <# if ( playlist &&emptyModel ) { #>538 <input type="checkbox" data-setting="artists" <# if ( emptyModel ) { #> 567 539 checked="checked" 568 540 <# } #> /> -
trunk/src/wp-includes/media.php
r27735 r27785 1073 1073 * 1074 1074 * @param array $attr Attributes of the shortcode. 1075 * @param string $type Type of playlist. Accepts 'audio' and 'video'.1076 1075 * @return string Playlist output. Empty string if the passed type is unsupported. 1077 1076 */ 1078 function wp_ get_playlist( $attr, $type) {1077 function wp_playlist_shortcode( $attr ) { 1079 1078 global $content_width; 1080 1079 $post = get_post(); 1081 1082 if ( ! in_array( $type, array( 'audio', 'video' ) ) ) {1083 return '';1084 }1085 1080 1086 1081 static $instance = 0; … … 1107 1102 * @param string $type Type of playlist to generate output for. 1108 1103 */ 1109 $output = apply_filters( 'post_playlist', '', $attr , $type);1104 $output = apply_filters( 'post_playlist', '', $attr ); 1110 1105 if ( $output != '' ) { 1111 1106 return $output; … … 1123 1118 1124 1119 extract( shortcode_atts( array( 1120 'type' => 'audio', 1125 1121 'order' => 'ASC', 1126 1122 'orderby' => 'menu_order ID', … … 1129 1125 'exclude' => '', 1130 1126 'style' => 'light', 1131 'tracklist' => 'audio' === $type,1132 'tracknumbers' => 'audio' === $type,1127 'tracklist' => true, 1128 'tracknumbers' => true, 1133 1129 'images' => true, 1134 1130 'artists' => true … … 1138 1134 if ( 'RAND' == $order ) { 1139 1135 $orderby = 'none'; 1140 }1141 1142 $playlist_styles = array(1143 'light' => _x( 'Light', 'playlist theme' ),1144 'dark' => _x( 'Dark', 'playlist theme' )1145 );1146 1147 /**1148 * Filter the available playlist styles.1149 *1150 * @since 3.9.01151 *1152 * @param array $playlist_styles Array of playlist styles. Defaults are 'light' and 'dark'.1153 */1154 $styles = apply_filters( 'playlist_styles', $playlist_styles );1155 1156 if ( ! in_array( $style, array_keys( $styles ), true ) ) {1157 $style = 'light';1158 1136 } 1159 1137 … … 1203 1181 $theme_height = empty( $content_width ) ? $default_height : round( ( $default_height * $theme_width ) / $default_width ); 1204 1182 1205 $data = compact( 'type' , 'style');1183 $data = compact( 'type' ); 1206 1184 1207 1185 // don't pass strings to JSON, will be truthy in JS … … 1312 1290 return ob_get_clean(); 1313 1291 } 1314 1315 /**1316 * Playlist shortcode handler1317 *1318 * @since 3.9.01319 *1320 * @param array $attr Parsed shortcode attributes.1321 * @return string The resolved playlist shortcode markup.1322 */1323 function wp_playlist_shortcode( $attr ) {1324 return wp_get_playlist( $attr, 'audio' );1325 }1326 1292 add_shortcode( 'playlist', 'wp_playlist_shortcode' ); 1327 1328 /**1329 * Video playlist shortcode handler1330 *1331 * @since 3.9.01332 *1333 * @param array $attr Parsed shortcode attributes.1334 * @return string The resolved video playlist shortcode markup.1335 */1336 function wp_video_playlist_shortcode( $attr ) {1337 return wp_get_playlist( $attr, 'video' );1338 }1339 add_shortcode( 'video-playlist', 'wp_video_playlist_shortcode' );1340 1293 1341 1294 /**
Note: See TracChangeset
for help on using the changeset viewer.