-
Notifications
You must be signed in to change notification settings - Fork 362
Local support #523
Local support #523
Changes from 8 commits
ef3acc2
465ef5a
c7e1f1f
ff4c393
e722edc
d5102a5
564a3e4
8d77638
9058a4f
70d0276
161ff10
b87506b
2bf0186
11afb12
dbfeeb8
1002dde
85f7eeb
2979a75
18f3a01
18c392a
aae5118
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,12 +6,14 @@ import NavItem from 'react-bootstrap/lib/NavItem'; | |
import FormControl from 'react-bootstrap/lib/FormControl'; | ||
import Row from 'react-bootstrap/lib/Row'; | ||
import Col from 'react-bootstrap/lib/Col'; | ||
import { intlShape, injectIntl } from 'react-intl'; | ||
|
||
import SwitchToggle from 'components/SwitchToggle'; | ||
import LocaleFormattedMessage from 'components/LocaleFormattedMessage'; | ||
|
||
const style = require('../style.scss'); | ||
|
||
export default class RepeatButton extends Component { | ||
class RepeatButton extends Component { | ||
static propTypes = { | ||
surah: PropTypes.object.isRequired, | ||
repeat: PropTypes.shape({ | ||
|
@@ -20,7 +22,8 @@ export default class RepeatButton extends Component { | |
times: PropTypes.number | ||
}).isRequired, | ||
setRepeat: PropTypes.func.isRequired, | ||
current: PropTypes.number.isRequired | ||
current: PropTypes.number.isRequired, | ||
intl: intlShape.isRequired | ||
}; | ||
|
||
handleToggle = () => { | ||
|
@@ -59,9 +62,13 @@ export default class RepeatButton extends Component { | |
|
||
return ( | ||
<Col md={12} style={{paddingTop: 15}}> | ||
From - To: <br /> | ||
<ul className="list-inline" style={{marginBottom: 0}}> | ||
<li> | ||
<LocaleFormattedMessage | ||
id={ "player.repeat.rangeStart" } | ||
defaultMessage={'From'} | ||
/>{' '}: | ||
<br /> | ||
<FormControl | ||
componentClass="select" | ||
value={repeat.from} | ||
|
@@ -82,6 +89,11 @@ export default class RepeatButton extends Component { | |
</li> | ||
<li> - </li> | ||
<li> | ||
<LocaleFormattedMessage | ||
id={ "player.repeat.rangeEnd" } | ||
defaultMessage={'To'} | ||
/>{' '}: | ||
<br /> | ||
<FormControl | ||
componentClass="select" | ||
value={repeat.to} | ||
|
@@ -107,7 +119,10 @@ export default class RepeatButton extends Component { | |
|
||
return ( | ||
<Col md={12} style={{paddingTop: 15}}> | ||
Ayah: <br /> | ||
<LocaleFormattedMessage | ||
id={ "player.currentAyah" } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. youll hate me for this, but technically you don't need the surrounding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, Ill love to learn and follow best practices. So we don't need {} for string literals |
||
defaultMessage={'Ayah'} | ||
/>{' '}: <br /> | ||
<FormControl | ||
componentClass="select" | ||
value={repeat.from} | ||
|
@@ -141,10 +156,16 @@ export default class RepeatButton extends Component { | |
onSelect={this.handleNavChange} | ||
> | ||
<NavItem eventKey={1} title="Single Ayah" className={style.pill}> | ||
Single | ||
<LocaleFormattedMessage | ||
id={ "player.repeat.single" } | ||
defaultMessage={'Single'} | ||
/> | ||
</NavItem> | ||
<NavItem eventKey={2} title="Range" className={style.pill}> | ||
Range | ||
<LocaleFormattedMessage | ||
id={ "player.repeat.range" } | ||
defaultMessage={'Range'} | ||
/> | ||
</NavItem> | ||
</Nav> | ||
</Col> | ||
|
@@ -163,13 +184,16 @@ export default class RepeatButton extends Component { | |
} | ||
|
||
renderTimes() { | ||
const { repeat, setRepeat } = this.props; | ||
const { repeat, setRepeat, intl } = this.props; | ||
const times = Array(10).join().split(','); | ||
|
||
return ( | ||
<Row className={!repeat.from && style.disabled}> | ||
<Col md={12} style={{paddingTop: 15}}> | ||
Times: <br /> | ||
<LocaleFormattedMessage | ||
id={ "player.repeat.title" } | ||
defaultMessage={'Repeat'} | ||
/>: <br /> | ||
<FormControl | ||
componentClass="select" | ||
value={repeat.times} | ||
|
@@ -178,8 +202,10 @@ export default class RepeatButton extends Component { | |
times: parseInt(event.target.value, 10) | ||
})} | ||
> | ||
<option value={Infinity}> | ||
Loop | ||
<option value={'Infinity'}> | ||
{ | ||
intl.formatMessage({id: "player.repeat.loop", defaultMessage: 'Loop'}) | ||
} | ||
</option> | ||
{ | ||
times.map((ayah, index) => ( | ||
|
@@ -204,7 +230,10 @@ export default class RepeatButton extends Component { | |
title={ | ||
<Row> | ||
<Col md={12} className="text-center"> | ||
Toggle repeat{' '} | ||
<LocaleFormattedMessage | ||
id={ "player.repeat.title" } | ||
defaultMessage={'TOGGLE REPEAT'} | ||
/>{' '} | ||
<SwitchToggle | ||
checked={!!repeat.from} | ||
onToggle={this.handleToggle} | ||
|
@@ -225,7 +254,7 @@ export default class RepeatButton extends Component { | |
<div className="text-center"> | ||
<OverlayTrigger | ||
overlay={popover} | ||
placement="bottom" | ||
placement="top" | ||
trigger="click" | ||
rootClose | ||
> | ||
|
@@ -237,3 +266,5 @@ export default class RepeatButton extends Component { | |
); | ||
} | ||
} | ||
|
||
export default injectIntl(RepeatButton); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ import Link from 'react-router/lib/Link'; | |
import { Element } from 'react-scroll'; | ||
|
||
import Copy from 'components/Copy'; | ||
import LocaleFormattedMessage from 'components/LocaleFormattedMessage'; | ||
|
||
import debug from 'helpers/debug'; | ||
|
||
|
@@ -50,7 +51,8 @@ export default class Ayah extends Component { | |
this.props.bookmarked !== nextProps.bookmarked, | ||
this.props.tooltip !== nextProps.tooltip, | ||
this.props.currentWord !== nextProps.currentWord, | ||
this.props.currentAyah !== nextProps.currentAyah | ||
this.props.currentAyah !== nextProps.currentAyah, | ||
this.props.isPlaying !== nextProps.isPlaying | ||
]; | ||
|
||
if (this.props.match) { | ||
|
@@ -61,12 +63,12 @@ export default class Ayah extends Component { | |
} | ||
|
||
handlePlay(ayah) { | ||
const { isPlaying, audioActions } = this.props; | ||
const { isPlaying, audioActions, currentAyah } = this.props; | ||
const { pause, setAyah, play } = audioActions; | ||
const isPreviouslyPlaying = isPlaying; | ||
|
||
if (isPlaying) { | ||
if (isPlaying) | ||
pause(); | ||
} | ||
setAyah(ayah); | ||
play(); | ||
} | ||
|
@@ -89,17 +91,17 @@ export default class Ayah extends Component { | |
> | ||
<h4 className="montserrat">{content.name || content.resource.name}</h4> | ||
<h2 className={`${isArabic ? 'text-right' : 'text-left'} text-translation times-new`}> | ||
<small dangerouslySetInnerHTML={{__html: content.text}} className={`${styles[lang] || 'times-new'}`} /> | ||
<small dangerouslySetInnerHTML={{__html: content.text}} className={lang} /> | ||
</h2> | ||
</div> | ||
); | ||
}); | ||
} | ||
|
||
renderMedia() { | ||
const { ayah, mediaActions } = this.props; | ||
const { ayah, mediaActions, isSearched } = this.props; | ||
|
||
if (!!ayah.mediaContent) return false; | ||
if (isSearched || !!ayah.mediaContent) return false; | ||
|
||
return ( | ||
<div> | ||
|
@@ -119,7 +121,11 @@ export default class Ayah extends Component { | |
data-metrics-media-content-id={content.id} | ||
data-metrics-media-content-ayah-key={ayah.ayahKey} | ||
> | ||
Watch lecture by {content.resource.name} | ||
<LocaleFormattedMessage | ||
id={'ayah.media.lectureFrom'} | ||
defaultMessage={"Watch lecture by {from}"} | ||
values={{from: content.resource.name}} | ||
/> | ||
</a> | ||
</small> | ||
</h2> | ||
|
@@ -131,7 +137,7 @@ export default class Ayah extends Component { | |
} | ||
|
||
renderText() { | ||
const { ayah, audioActions: { setCurrentWord }, tooltip } = this.props; | ||
const { ayah, audioActions, tooltip, isSearched } = this.props; | ||
|
||
if (!ayah.words[0].code) { | ||
return false; | ||
|
@@ -159,20 +165,19 @@ export default class Ayah extends Component { | |
key={word.code} | ||
id={id} | ||
rel="tooltip" | ||
onClick={(event) => setCurrentWord(event.target.dataset.key)} | ||
onClick={(event) => isSearched ? '' : audioActions.setCurrentWord(event.target.dataset.key)} | ||
data-key={`${word.ayahKey}:${position}`} | ||
className={`${className}`} | ||
title={tooltipContent} | ||
dangerouslySetInnerHTML={{__html: word.code}} | ||
/> | ||
); | ||
} | ||
|
||
const label = isLast ? {'title': `Verse ${ayah.ayahNum}`} : {} | ||
return ( | ||
<b | ||
id={id} | ||
onClick={(event) => setCurrentWord(event.target.dataset.key)} | ||
onClick={(event) => isSearched? '' : audioActions.setCurrentWord(event.target.dataset.key)} | ||
data-key={`${word.ayahKey}:${position}`} | ||
rel="tooltip" | ||
className={`${className} ${isLast} pointer`} | ||
|
@@ -197,15 +202,25 @@ export default class Ayah extends Component { | |
} | ||
|
||
renderPlayLink() { | ||
const { isSearched, ayah } = this.props; | ||
const { isSearched, ayah, currentAyah, isPlaying } = this.props; | ||
const playing = ayah.ayahKey == currentAyah && isPlaying; | ||
let icon = <i className="ss-icon ss-play" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✂️ |
||
|
||
if (playing) { | ||
icon = <i className="ss-icon ss-pause" />; | ||
} | ||
|
||
if (!isSearched) { | ||
return ( | ||
<a | ||
onClick={() => this.handlePlay(ayah.ayahKey)} | ||
className="text-muted" | ||
> | ||
<i className="ss-icon ss-play" /> Play | ||
{icon} | ||
<LocaleFormattedMessage | ||
id={ playing ? 'actions.pause' : 'actions.play' } | ||
defaultMessage={ playing ? 'Pause' : 'Play'} | ||
/> | ||
</a> | ||
); | ||
} | ||
|
@@ -226,17 +241,17 @@ export default class Ayah extends Component { | |
} | ||
|
||
renderBookmark() { | ||
const { ayah, bookmarked, isAuthenticated, bookmarkActions } = this.props; | ||
const { ayah, bookmarked, isAuthenticated, bookmarkActions, isSearched } = this.props; | ||
|
||
if (!isAuthenticated) return false; | ||
if (isSearched || !isAuthenticated) return false; | ||
|
||
if (bookmarked) { | ||
return ( | ||
<a | ||
onClick={() => bookmarkActions.removeBookmark(ayah.ayahKey)} | ||
className="text-muted" | ||
> | ||
<strong><i className="ss-icon ss-bookmark" /> Bookmarked</strong> | ||
<strong><i className="ss-icon ss-bookmark" /> Bookmarked </strong> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. localized this as well |
||
</a> | ||
); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spaces! don't forget your spaces :)