Make WordPress Core

Changeset 27489


Ignore:
Timestamp:
03/10/2014 12:14:42 AM (12 years ago)
Author:
wonderboymusic
Message:

Add a class, wp-playlist-playing, to the currently loaded track when tracks are displayed. Add some subtle styles for light and dark playlist themes.

See #27321.

Location:
trunk/src/wp-includes/js/mediaelement
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/mediaelement/wp-mediaelement.css

    r27481 r27489  
    125125.wp-playlist-item-length {
    126126        position: absolute;
    127         right: 0;
     127        right: 3px;
    128128        top: 0;
    129129}
     
    137137        position: relative;
    138138        cursor: pointer;
     139        padding: 0 3px;
    139140        border-bottom: 1px solid #ccc;
     141}
     142
     143.wp-playlist-dark .wp-playlist-item {
     144        color: #dedede;
     145}
     146
     147.wp-playlist-playing {
     148        font-weight: bold;
     149        background: #f7f7f7;
     150}
     151
     152.wp-playlist-dark .wp-playlist-playing {
     153        background: #000;
     154        color: #fff;
    140155}
    141156
  • trunk/src/wp-includes/js/mediaelement/wp-playlist.js

    r27320 r27489  
    2626
    2727                        if ( this.data.tracklist ) {
     28                                this.playingClass = 'wp-playlist-playing';
    2829                                this.renderTracks();
    2930                        }
     
    5859
    5960                renderTracks : function () {
    60                         var that = this, i = 1, tracklist = $( '<div class="wp-playlist-tracks"></div>' );
     61                        var self = this, i = 1, tracklist = $( '<div class="wp-playlist-tracks"></div>' );
    6162                        this.tracks.each(function (model) {
    62                                 if ( ! that.data.images ) {
     63                                if ( ! self.data.images ) {
    6364                                        model.set( 'image', false );
    6465                                }
    65                                 model.set( 'artists', that.data.artists );
    66                                 model.set( 'index', that.data.tracknumbers ? i : false );
    67                                 tracklist.append( that.itemTemplate( model.toJSON() ) );
     66                                model.set( 'artists', self.data.artists );
     67                                model.set( 'index', self.data.tracknumbers ? i : false );
     68                                tracklist.append( self.itemTemplate( model.toJSON() ) );
    6869                                i += 1;
    6970                        });
    7071                        this.$el.append( tracklist );
     72
     73                        this.$( '.wp-playlist-item' ).eq(0).addClass( this.playingClass );
    7174                },
    7275
     
    116119                setCurrent : function () {
    117120                        this.current = this.tracks.at( this.index );
     121
     122                        if ( this.data.tracklist ) {
     123                                this.$( '.wp-playlist-item' )
     124                                        .removeClass( this.playingClass )
     125                                        .eq( this.index )
     126                                                .addClass( this.playingClass );
     127                        }
     128
    118129                        this.loadCurrent();
    119130                        this.player.play();
Note: See TracChangeset for help on using the changeset viewer.