Make WordPress Core


Ignore:
Timestamp:
03/19/2014 05:30:27 AM (12 years ago)
Author:
wonderboymusic
Message:

Create a new file, media-audiovideo.js, to house all of the audio and video JS code in core.

UX Changes:

  • Don't add a menu item for "Add Audio|Video Source"
  • In the Audio|Video Details modal, add buttons and some suggestive text for adding alternate playback sources
  • Don't show "Create Audio|Video Playlist" menu items until the user has uploaded audio or video files

See #27437.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/media-template.php

    r27580 r27608  
    766766
    767767    <script type="text/html" id="tmpl-audio-details">
     768        <# var ext, html5types = { mp3: true, ogg: true }; #>
     769
    768770        <?php $audio_types = wp_get_audio_extensions(); ?>
    769771        <div class="media-embed media-embed-details">
    770772            <div class="embed-media-settings embed-audio-settings">
    771                 <div class="instructions media-instructions">{{{ wp.media.view.l10n.audioDetailsText }}}</div>
    772 
    773773                <?php wp_underscore_audio_template() ?>
    774774
    775                 <# if ( ! _.isEmpty( data.model.src ) ) { #>
     775                <# if ( ! _.isEmpty( data.model.src ) ) {
     776                    ext = data.model.src.split('.').pop();
     777                    if ( html5types[ ext ] ) {
     778                        delete html5types[ ext ];
     779                    }
     780                #>
    776781                <label class="setting">
    777782                    <span>SRC</span>
     
    783788
    784789                foreach ( $audio_types as $type ):
    785                 ?><# if ( ! _.isEmpty( data.model.<?php echo $type ?> ) ) { #>
     790                ?><# if ( ! _.isEmpty( data.model.<?php echo $type ?> ) ) {
     791                    if ( ! _.isUndefined( html5types.<?php echo $type ?> ) ) {
     792                        delete html5types.<?php echo $type ?>;
     793                    }
     794                #>
    786795                <label class="setting">
    787796                    <span><?php echo strtoupper( $type ) ?></span>
     
    791800                <# } #>
    792801                <?php endforeach ?>
     802
     803                <# if ( ! _.isEmpty( html5types ) ) { #>
     804                <div class="setting">
     805                    <span>{{{ wp.media.view.l10n.mediaHTML5Text }}}</span>
     806                    <div class="button-large">
     807                    <# _.each( html5types, function (value, type) { #>
     808                    <button class="button add-media-source">{{ type }}</button>
     809                    <# } ) #>
     810                    </div>
     811                </div>
     812                <# } #>
    793813
    794814                <div class="setting preload">
     
    816836
    817837    <script type="text/html" id="tmpl-video-details">
     838        <# var ext, html5types = { mp4: true, ogv: true, webm: true }; #>
     839
    818840        <?php $video_types = wp_get_video_extensions(); ?>
    819841        <div class="media-embed media-embed-details">
    820842            <div class="embed-media-settings embed-video-settings">
    821                 <div class="instructions media-instructions">{{{ wp.media.view.l10n.videoDetailsText }}}</div>
    822843                <div class="wp-video-holder">
    823844                <#
     
    833854                <?php wp_underscore_video_template() ?>
    834855
    835                 <# if ( ! _.isEmpty( data.model.src ) ) { #>
     856                <# if ( ! _.isEmpty( data.model.src ) ) {
     857                    ext = data.model.src.split('.').pop();
     858                    if ( html5types[ ext ] ) {
     859                        delete html5types[ ext ];
     860                    }
     861                #>
    836862                <label class="setting">
    837863                    <span>SRC</span>
     
    841867                <# } #>
    842868                <?php foreach ( $video_types as $type ):
    843                 ?><# if ( ! _.isEmpty( data.model.<?php echo $type ?> ) ) { #>
     869                ?><# if ( ! _.isEmpty( data.model.<?php echo $type ?> ) ) {
     870                    if ( ! _.isUndefined( html5types.<?php echo $type ?> ) ) {
     871                        delete html5types.<?php echo $type ?>;
     872                    }
     873                #>
    844874                <label class="setting">
    845875                    <span><?php echo strtoupper( $type ) ?></span>
     
    850880                <?php endforeach ?>
    851881                </div>
     882
     883                <# if ( ! _.isEmpty( html5types ) ) { #>
     884                <div class="setting">
     885                    <span>{{{ wp.media.view.l10n.mediaHTML5Text }}}</span>
     886                    <div class="button-large">
     887                    <# _.each( html5types, function (value, type) { #>
     888                    <button class="button add-media-source">{{ type }}</button>
     889                    <# } ) #>
     890                    </div>
     891                </div>
     892                <# } #>
     893
    852894                <# if ( ! _.isEmpty( data.model.poster ) ) { #>
    853895                <label class="setting">
Note: See TracChangeset for help on using the changeset viewer.