Skip to content
This repository has been archived by the owner on Jun 28, 2021. It is now read-only.

Local support #523

Merged
merged 21 commits into from
Dec 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
src/components/SurahInfo/htmls/*
6 changes: 4 additions & 2 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ module.exports = function(config) {
'karma-sinon',
'karma-webpack',
'karma-chrome-launcher',
'karma-phantomjs-launcher'
'karma-phantomjs-launcher',
'karma-intl-shim'
],

// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha', 'chai-sinon', 'sinon'],
frameworks: ['mocha', 'chai-sinon', 'sinon', 'intl-shim'],

// list of files / patterns to load in the browser
files: [
'./node_modules/phantomjs-polyfill/bind-polyfill.js',
'./tests/polyfill/Event.js',
'./node_modules/Intl/locale-data/jsonp/en-US.js',
{pattern: 'static/images/*', watched: false, included: false, served: true},

// Actual tests here
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
"url-loader": "0.5.7",
"webpack": "2.1.0-beta.20",
"webpack-isomorphic-tools": "2.5.7",
"react-intl": "2.1.5",
"winston": "1.1.2",
"react-inlinesvg": "0.5.4"
},
Expand All @@ -135,6 +136,7 @@
"karma-chai": "0.1.0",
"karma-chai-sinon": "0.1.5",
"karma-chrome-launcher": "0.2.0",
"karma-intl-shim": "1.0.3",
"karma-junit-reporter": "0.3.4",
"karma-mocha": "0.2.0",
"karma-phantomjs-launcher": "~0.2.1",
Expand Down
11 changes: 9 additions & 2 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ import applyRouterMiddleware from 'react-router/lib/applyRouterMiddleware';
import useScroll from 'react-router-scroll';
import { ReduxAsyncConnect } from 'redux-connect';
import { syncHistoryWithStore } from 'react-router-redux';
import { IntlProvider } from 'react-intl';

import debug from 'debug';

import config from './config';
import ApiClient from './helpers/ApiClient';
import createStore from './redux/create';
import routes from './routes';
import {getLocalMessages} from './helpers/setLocal';
Copy link
Contributor

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 :)


const client = new ApiClient();
const store = createStore(browserHistory, client, window.reduxData);
Expand All @@ -38,6 +40,9 @@ window.clearCookies = () => {
reactCookie.remove('content');
reactCookie.remove('audio');
reactCookie.remove('isFirstTime');
reactCookie.remove('currentLocale');
reactCookie.remove('smartbanner-closed');
reactCookie.remove('smartbanner-installed');
};

match({ history, routes: routes(store) }, (error, redirectLocation, renderProps) => {
Expand All @@ -60,9 +65,11 @@ match({ history, routes: routes(store) }, (error, redirectLocation, renderProps)
debug('client', 'React Rendering');

ReactDOM.render(
<Provider store={store} key="provider">
<IntlProvider locale='en' messages={getLocalMessages()}>
<Provider store={store} key="provider">
{component}
</Provider>, mountNode, () => {
</Provider>
</IntlProvider>, mountNode, () => {
debug('client', 'React Rendered');
}
);
Expand Down
53 changes: 42 additions & 11 deletions src/components/Audioplayer/RepeatDropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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 = () => {
Expand Down Expand Up @@ -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}
Expand All @@ -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}
Expand All @@ -107,7 +119,10 @@ export default class RepeatButton extends Component {

return (
<Col md={12} style={{paddingTop: 15}}>
Ayah: <br />
<LocaleFormattedMessage
id={ "player.currentAyah" }
Copy link
Contributor

Choose a reason for hiding this comment

The 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 {}. id="player.currentAyah" will suffice. Inshallah once I put more eslint it will catch these

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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}
Expand Down Expand Up @@ -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>
Expand All @@ -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}
Expand All @@ -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) => (
Expand All @@ -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}
Expand Down Expand Up @@ -237,3 +266,5 @@ export default class RepeatButton extends Component {
);
}
}

export default injectIntl(RepeatButton);
6 changes: 3 additions & 3 deletions src/components/Audioplayer/RepeatDropdown/spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { mount } from 'enzyme';
import { mountWithIntl } from '../../../../tests/helpers/intl-enzyme-test-helper.js';

import RepeatDropdown from './index';

Expand All @@ -11,7 +11,7 @@ const surah = {
makeComponent = (repeat) => {
setRepeat = sinon.stub();

component = mount(
component = mountWithIntl(
<RepeatDropdown
repeat={repeat}
setRepeat={setRepeat}
Expand All @@ -20,7 +20,7 @@ makeComponent = (repeat) => {
/>
);

overlay = mount(component.find('OverlayTrigger').first().props().overlay);
overlay = mountWithIntl(component.find('OverlayTrigger').first().props().overlay);
}

describe('<RepeatDropdown />', () => {
Expand Down
6 changes: 5 additions & 1 deletion src/components/Audioplayer/ScrollButton/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import React, { PropTypes } from 'react';
import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger';
import Tooltip from 'react-bootstrap/lib/Tooltip';
import LocaleFormattedMessage from 'components/LocaleFormattedMessage';

const style = require('../style.scss');

const ScrollButton = ({ shouldScroll, onScrollToggle }) => {
const tooltip = (
<Tooltip id="scroll-button-tooltip">
Automatically scrolls to the currently playing ayah on transitions...
<LocaleFormattedMessage
id={ "player.scrollButtonTip" }
defaultMessage={'Automatically scrolls to the currently playing ayah on transitions...'}
/>
</Tooltip>
);

Expand Down
13 changes: 11 additions & 2 deletions src/components/Audioplayer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Track from './Track';
import Segments from './Segments';
import ScrollButton from './ScrollButton';
import RepeatDropdown from './RepeatDropdown';
import LocaleFormattedMessage from 'components/LocaleFormattedMessage';

// Helpers
import debug from 'helpers/debug';
Expand Down Expand Up @@ -392,7 +393,12 @@ export class Audioplayer extends Component {
if (isLoading || !currentAyah) {
return (
<li className={`${style.container} ${className}`}>
<div>Loading...</div>
<div>
<LocaleFormattedMessage
id='app.loading'
defaultMessage={ 'Loading...' }
/>
</div>
</li>
);
}
Expand All @@ -419,7 +425,10 @@ export class Audioplayer extends Component {
</div>
<ul className={`list-inline ${style.controls}`}>
<li className={style.controlItem}>
Ayah: {currentAyah.split(':')[1]}
<LocaleFormattedMessage
id='player.currentAyah'
defaultMessage={ 'Ayah' }
/>: {currentAyah.split(':')[1]}
</li>
<li className={style.controlItem}>
{this.renderPreviousButton()}
Expand Down
Loading