_ = require 'underscore' React = require "react" classNames = require 'classnames' class MessageParticipants extends React.Component @displayName: 'MessageParticipants' render: => classSet = classNames "participants": true "message-participants": true "collapsed": not @props.isDetailed
{if @props.isDetailed then @_renderExpanded() else @_renderCollapsed()}
_renderCollapsed: => childSpans = [ {@_shortNames(@props.from)} ] if @props.to?.length > 0 childSpans.push( To:  {@_shortNames(@props.to)} ) if @props.cc?.length > 0 childSpans.push( Cc:  {@_shortNames(@props.cc)} ) if @props.bcc?.length > 0 childSpans.push( Bcc:  {@_shortNames(@props.bcc)} ) {childSpans} _renderExpanded: =>
{@_fullContact(@props.from)}
To: 
{@_fullContact(@props.to)}
0 then display:"block" else display:"none"}>
Cc: 
{@_fullContact(@props.cc)}
0 then display:"block" else display:"none"}>
Bcc: 
{@_fullContact(@props.bcc)}
_shortNames: (contacts=[]) => _.map(contacts, (c) -> c.displayFirstName()).join(", ") _fullContact: (contacts=[]) => if contacts.length is 0 # This is necessary to make the floats work properly
 
else _.map(contacts, (c, i) => if contacts.length is 1 then comma = "" else if i is contacts.length-1 then comma = "" else comma = "," if c.name?.length > 0 and c.name isnt c.email
{c.name}  <{c.email}>{comma} 
else
{c.email}{comma} 
) _selectPlainText: (e) => textNode = e.currentTarget.childNodes[0] @_selectText(textNode) _selectCommaText: (e) => textNode = e.currentTarget.childNodes[0].childNodes[0] @_selectText(textNode) _selectBracketedText: (e) => textNode = e.currentTarget.childNodes[1].childNodes[0] # because of React rendering @_selectText(textNode) _selectText: (textNode) => range = document.createRange() range.setStart(textNode, 0) range.setEnd(textNode, textNode.length) selection = document.getSelection() selection.removeAllRanges() selection.addRange(range) module.exports = MessageParticipants