2016-05-06 05:14:39 +08:00
|
|
|
import React from 'react';
|
|
|
|
import Modal from 'react-modal';
|
2016-05-20 21:37:19 +08:00
|
|
|
import Icon from '/imports/ui/components/icon/component';
|
|
|
|
import Button from '/imports/ui/components/button/component';
|
2016-08-25 07:00:38 +08:00
|
|
|
import BaseMenu from '../base/component';
|
2016-05-06 05:14:39 +08:00
|
|
|
import ReactDOM from 'react-dom';
|
2017-01-27 23:41:11 +08:00
|
|
|
import cx from 'classnames';
|
2016-09-01 21:56:41 +08:00
|
|
|
import styles from '../styles.scss';
|
2017-01-27 23:41:11 +08:00
|
|
|
import Toggle from '/imports/ui/components/switch/component';
|
2016-12-14 11:40:32 +08:00
|
|
|
|
2017-02-25 04:19:53 +08:00
|
|
|
const MIN_FONTSIZE = 0;
|
|
|
|
const MAX_FONTSIZE = 4;
|
|
|
|
|
2016-05-06 05:14:39 +08:00
|
|
|
export default class ApplicationMenu extends BaseMenu {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
2017-02-22 04:29:36 +08:00
|
|
|
|
2017-02-25 04:19:53 +08:00
|
|
|
this.state = {
|
|
|
|
settingsName: 'application',
|
|
|
|
settings: props.settings,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
handleUpdateFontSize(size) {
|
|
|
|
let obj = this.state;
|
|
|
|
obj.settings.fontSize = size;
|
|
|
|
this.handleUpdateSettings(this.state.settingsName, obj.settings);
|
|
|
|
}
|
|
|
|
|
|
|
|
setHtmlFontSize(size) {
|
|
|
|
document.getElementsByTagName('html')[0].style.fontSize = size;
|
|
|
|
};
|
|
|
|
|
|
|
|
changeFontSize(size) {
|
|
|
|
let obj = this.state;
|
|
|
|
obj.settings.fontSize = size;
|
|
|
|
this.setState(obj, () => {
|
|
|
|
this.setHtmlFontSize(this.state.settings.fontSize);
|
|
|
|
this.handleUpdateFontSize(this.state.settings.fontSize);
|
|
|
|
});
|
2016-05-06 05:14:39 +08:00
|
|
|
}
|
|
|
|
|
2017-02-25 04:19:53 +08:00
|
|
|
handleIncreaseFontSize() {
|
|
|
|
const currentFontSize = this.state.settings.fontSize;
|
|
|
|
const availableFontSizes = this.props.fontSizes;
|
|
|
|
const canIncreaseFontSize = availableFontSizes.indexOf(currentFontSize) < MAX_FONTSIZE;
|
|
|
|
let fs = (canIncreaseFontSize) ? availableFontSizes.indexOf(currentFontSize) + 1 : MAX_FONTSIZE;
|
|
|
|
this.changeFontSize(availableFontSizes[fs]);
|
|
|
|
};
|
|
|
|
|
|
|
|
handleDecreaseFontSize() {
|
|
|
|
const currentFontSize = this.state.settings.fontSize;
|
|
|
|
const availableFontSizes = this.props.fontSizes;
|
|
|
|
const canDecreaseFontSize = availableFontSizes.indexOf(currentFontSize) > MIN_FONTSIZE;
|
|
|
|
let fs = (canDecreaseFontSize) ? availableFontSizes.indexOf(currentFontSize) - 1 : MIN_FONTSIZE;
|
|
|
|
this.changeFontSize(availableFontSizes[fs]);
|
|
|
|
};
|
|
|
|
|
2017-01-27 23:41:11 +08:00
|
|
|
render() {
|
2016-05-06 05:14:39 +08:00
|
|
|
return (
|
2017-01-27 23:41:11 +08:00
|
|
|
<div className={styles.tabContent}>
|
|
|
|
<div className={styles.header}>
|
|
|
|
<h3 className={styles.title}>Application</h3>
|
|
|
|
</div>
|
|
|
|
<div className={styles.form}>
|
|
|
|
<div className={styles.row}>
|
|
|
|
<div className={styles.col}>
|
|
|
|
<div className={styles.formElement}>
|
|
|
|
<label className={styles.label}>
|
|
|
|
Audio notifications for chat
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className={styles.col}>
|
|
|
|
<div className={cx(styles.formElement, styles.pullContentRight)}>
|
|
|
|
<Toggle
|
|
|
|
icons={false}
|
2017-02-25 04:19:53 +08:00
|
|
|
defaultChecked={this.state.settings.chatAudioNotifications}
|
|
|
|
onChange={() => this.handleToggle('chatAudioNotifications')} />
|
2017-01-27 23:41:11 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
2016-06-07 03:52:03 +08:00
|
|
|
</div>
|
2017-01-27 23:41:11 +08:00
|
|
|
<div className={styles.row}>
|
|
|
|
<div className={styles.col}>
|
|
|
|
<div className={styles.formElement}>
|
|
|
|
<label className={styles.label}>
|
|
|
|
Push notifications for chat
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className={styles.col}>
|
|
|
|
<div className={cx(styles.formElement, styles.pullContentRight)}>
|
|
|
|
<Toggle
|
|
|
|
icons={false}
|
2017-02-25 04:19:53 +08:00
|
|
|
defaultChecked={this.state.settings.chatPushNotifications}
|
|
|
|
onChange={() => this.handleToggle('chatPushNotifications')} />
|
2017-01-27 23:41:11 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
2016-06-07 03:52:03 +08:00
|
|
|
</div>
|
2017-01-27 23:41:11 +08:00
|
|
|
<hr className={styles.separator}/>
|
|
|
|
<div className={styles.row}>
|
|
|
|
<div className={styles.col}>
|
|
|
|
<div className={styles.formElement}>
|
|
|
|
<label className={styles.label}>
|
|
|
|
Font size
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className={styles.col}>
|
|
|
|
<div className={cx(styles.formElement, styles.pullContentCenter)}>
|
|
|
|
<label className={cx(styles.label, styles.bold)}>
|
2017-03-02 01:37:55 +08:00
|
|
|
{this.state.settings.fontSize}
|
2017-01-27 23:41:11 +08:00
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className={styles.col}>
|
|
|
|
<div className={cx(styles.formElement, styles.pullContentRight)}>
|
2017-03-09 22:34:33 +08:00
|
|
|
<div className={styles.pullContentRight}>
|
|
|
|
<div className={styles.col}>
|
|
|
|
<Button
|
|
|
|
onClick={() => this.handleIncreaseFontSize()}
|
|
|
|
color={'success'}
|
2017-03-10 00:49:28 +08:00
|
|
|
icon={'add'}
|
2017-03-09 22:34:33 +08:00
|
|
|
circle={true}
|
|
|
|
tabIndex='0'
|
|
|
|
hideLabel={true}
|
|
|
|
label={'Increase Font'}
|
|
|
|
aria-labelledby={'sizeUpLabel'}
|
|
|
|
aria-describedby={'sizeUpDesc'}
|
|
|
|
/>
|
|
|
|
<div id='sizeUpLabel' hidden>Font size up</div>
|
|
|
|
</div>
|
|
|
|
<div className={styles.col}>
|
|
|
|
<Button
|
|
|
|
onClick={() => this.handleDecreaseFontSize()}
|
|
|
|
color={'success'}
|
2017-03-10 00:49:28 +08:00
|
|
|
icon={'substract'}
|
2017-03-09 22:34:33 +08:00
|
|
|
circle={true}
|
|
|
|
tabIndex='0'
|
|
|
|
hideLabel={true}
|
|
|
|
label={'Decrease Font'}
|
|
|
|
aria-labelledby={'sizeDownLabel'}
|
|
|
|
aria-describedby={'sizeDownDesc'}
|
|
|
|
/>
|
|
|
|
<div id='sizeUpDesc' hidden>Increases the font size of the application.</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2017-01-27 23:41:11 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
2016-05-06 05:14:39 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|