import React, { PropTypes } from 'react' import { Link } from 'react-router' import FontAwesome from 'react-fontawesome' import ArtistSentence from './ArtistSentence' import Dater from './Dater' import * as helpers from '../helpers' export default class Track extends React.Component{ constructor(props) { super(props); } handleMouseDown(e){ var target = $(e.target); if( !target.is('a') && target.closest('a').length <= 0 ){ this.props.handleMouseDown(e); } } handleTouchEnd(e){ var target = $(e.target); if( !target.is('a') && target.closest('a').length <= 0 ){ this.props.handleTouchEnd(e); } } handleContextMenu(e){ e.preventDefault(); this.props.handleContextMenu(e); } render(){ if( !this.props.track ) return null var track = this.props.track; var className = 'list-item track'; if( typeof(track.selected) !== 'undefined' && track.selected ) className += ' selected'; if( track.playing ) className += ' playing'; var album = '-' if( track.album ){ if( track.album.uri ){ album = {track.album.name} } else { album = {track.album.name} } } return (
this.props.handleTouchStart(e) } onTouchEnd={ e => this.handleTouchEnd(e) } onMouseDown={ e => this.handleMouseDown(e) } onMouseUp={ e => this.props.handleMouseUp(e) } onDoubleClick={ e => this.props.handleDoubleClick(e) } onContextMenu={ e => this.handleContextMenu(e) }> { this.props.track.selected ? : null } { track.name ? track.name : {track.uri} } { track.artists ? : '-' } {album} { track.duration_ms ? : null } { track.length ? : null } { this.props.show_source_icon ? : null }
); } }