This repository was archived by the owner on Jun 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 370
Audioplayer repeats #388
Merged
Merged
Audioplayer repeats #388
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,239 @@ | ||
| import React, { Component, PropTypes } from 'react'; | ||
| import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger'; | ||
| import Popover from 'react-bootstrap/lib/Popover'; | ||
| import Nav from 'react-bootstrap/lib/Nav'; | ||
| 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 SwitchToggle from 'components/SwitchToggle'; | ||
|
|
||
| const style = require('../style.scss'); | ||
|
|
||
| export default class RepeatButton extends Component { | ||
| static propTypes = { | ||
| surah: PropTypes.object.isRequired, | ||
| repeat: PropTypes.shape({ | ||
| from: PropTypes.number, | ||
| to: PropTypes.number, | ||
| times: PropTypes.number | ||
| }).isRequired, | ||
| setRepeat: PropTypes.func.isRequired, | ||
| current: PropTypes.number.isRequired | ||
| }; | ||
|
|
||
| handleToggle = () => { | ||
| const { repeat, setRepeat, current } = this.props; | ||
|
|
||
| if (repeat.from) { | ||
| return setRepeat({}); | ||
| } | ||
|
|
||
| return setRepeat({ | ||
| from: current, | ||
| to: current | ||
| }); | ||
| } | ||
|
|
||
| handleNavChange = (nav) => { | ||
| const { setRepeat, current } = this.props; | ||
|
|
||
| if (nav === 1) { | ||
| // Should set single ayah | ||
| return setRepeat({ | ||
| from: current, | ||
| to: current | ||
| }); | ||
| } | ||
|
|
||
| return setRepeat({ | ||
| from: current, | ||
| to: current + 3 | ||
| }); | ||
| } | ||
|
|
||
| renderRangeAyahs() { | ||
| const { surah, repeat, setRepeat } = this.props; | ||
| const array = Array(surah.ayat).join().split(','); | ||
|
|
||
| return ( | ||
| <Col md={12} style={{paddingTop: 15}}> | ||
| From - To: <br /> | ||
| <ul className="list-inline" style={{marginBottom: 0}}> | ||
| <li> | ||
| <FormControl | ||
| componentClass="select" | ||
| value={repeat.from} | ||
| onChange={(event) => setRepeat({ | ||
| ...repeat, | ||
| from: parseInt(event.target.value, 10), | ||
| to: parseInt(event.target.value, 10) | ||
| })} | ||
| > | ||
| { | ||
| array.map((ayah, index) => ( | ||
| <option key={index} value={index + 1}> | ||
| {index + 1} | ||
| </option> | ||
| )) | ||
| } | ||
| </FormControl> | ||
| </li> | ||
| <li> - </li> | ||
| <li> | ||
| <FormControl | ||
| componentClass="select" | ||
| value={repeat.to} | ||
| onChange={(event) => setRepeat({ ...repeat, to: parseInt(event.target.value, 10)})} | ||
| > | ||
| { | ||
| array.map((ayah, index) => ( | ||
| <option key={index} value={repeat.from ? index + 1 + repeat.from : index + 1}> | ||
| {repeat.from ? index + 1 + repeat.from : index + 1} | ||
| </option> | ||
| )) | ||
| } | ||
| </FormControl> | ||
| </li> | ||
| </ul> | ||
| </Col> | ||
| ); | ||
| } | ||
|
|
||
| renderSingleAyah() { | ||
| const { repeat, setRepeat, surah } = this.props; | ||
| const array = Array(surah.ayat).join().split(','); | ||
|
|
||
| return ( | ||
| <Col md={12} style={{paddingTop: 15}}> | ||
| Ayah: <br /> | ||
| <FormControl | ||
| componentClass="select" | ||
| value={repeat.from} | ||
| onChange={(event) => setRepeat({ | ||
| ...repeat, | ||
| from: parseInt(event.target.value, 10), | ||
| to: parseInt(event.target.value, 10) | ||
| })} | ||
| > | ||
| { | ||
| array.map((ayah, index) => ( | ||
| <option key={index} value={index + 1}> | ||
| {index + 1} | ||
| </option> | ||
| )) | ||
| } | ||
| </FormControl> | ||
| </Col> | ||
| ); | ||
| } | ||
|
|
||
| renderNav() { | ||
| const { repeat } = this.props; | ||
|
|
||
| return ( | ||
| <Row className={!repeat.from && style.disabled}> | ||
| <Col md={12}> | ||
| <Nav | ||
| bsStyle="pills" | ||
| activeKey={repeat.from === repeat.to ? 1 : 2} | ||
| onSelect={this.handleNavChange} | ||
| > | ||
| <NavItem eventKey={1} title="Single Ayah" className={style.pill}> | ||
| Single | ||
| </NavItem> | ||
| <NavItem eventKey={2} title="Range" className={style.pill}> | ||
| Range | ||
| </NavItem> | ||
| </Nav> | ||
| </Col> | ||
| </Row> | ||
| ); | ||
| } | ||
|
|
||
| renderOptions() { | ||
| const { repeat } = this.props; | ||
|
|
||
| return ( | ||
| <Row className={!repeat.from && style.disabled}> | ||
| {repeat.from === repeat.to ? this.renderSingleAyah() : this.renderRangeAyahs()} | ||
| </Row> | ||
| ); | ||
| } | ||
|
|
||
| renderTimes() { | ||
| const { repeat, setRepeat } = this.props; | ||
| const times = Array(10).join().split(','); | ||
|
|
||
| return ( | ||
| <Row className={!repeat.from && style.disabled}> | ||
| <Col md={12} style={{paddingTop: 15}}> | ||
| Times: <br /> | ||
| <FormControl | ||
| componentClass="select" | ||
| value={repeat.times} | ||
| onChange={(event) => setRepeat({ | ||
| ...repeat, | ||
| times: parseInt(event.target.value, 10) | ||
| })} | ||
| > | ||
| <option value={Infinity}> | ||
| Loop | ||
| </option> | ||
| { | ||
| times.map((ayah, index) => ( | ||
| <option key={index} value={index + 1}> | ||
| {index + 1} | ||
| </option> | ||
| )) | ||
| } | ||
| </FormControl> | ||
| </Col> | ||
| </Row> | ||
| ); | ||
| } | ||
|
|
||
| render() { | ||
| const { repeat } = this.props; | ||
|
|
||
| const popover = ( | ||
| <Popover | ||
| id="FontSizeDropdown" | ||
| className={style.popover} | ||
| title={ | ||
| <Row> | ||
| <Col md={12} className="text-center"> | ||
| Toggle repeat{' '} | ||
| <SwitchToggle | ||
| checked={!!repeat.from} | ||
| onToggle={this.handleToggle} | ||
| id="repeat-toggle" | ||
| flat | ||
| /> | ||
| </Col> | ||
| </Row> | ||
| } | ||
| > | ||
| {this.renderNav()} | ||
| {this.renderOptions()} | ||
| {this.renderTimes()} | ||
| </Popover> | ||
| ); | ||
|
|
||
| return ( | ||
| <div className="text-center"> | ||
| <OverlayTrigger | ||
| overlay={popover} | ||
| placement="bottom" | ||
| trigger="click" | ||
| rootClose | ||
| > | ||
| <i | ||
| className={`pointer ss-icon ss-repeat ${style.buttons} ${repeat.from && style.repeat}`} | ||
| /> | ||
| </OverlayTrigger> | ||
| </div> | ||
| ); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
minor: place Ayah in a
<p>tag