Small performance tweaks

This commit is contained in:
Ilya Ig. Petrov 2017-06-03 21:13:19 +05:00
parent 8a9ce3df9c
commit 9006135e2c
4 changed files with 24 additions and 19 deletions

View File

@ -83,6 +83,8 @@ export default function getExcEditor(theState) {
sortedListOfOptions: this.modsToOpts(pacMods),
isHostHidden: {}
};
this.handleRadioClick = this.handleRadioClick.bind(this);
this.handleInputOrClick = this.handleInputOrClick.bind(this);
}
@ -289,9 +291,6 @@ export default function getExcEditor(theState) {
}, undefined);
const onradio = this.handleRadioClick.bind(this);
const oninput = this.handleInputOrClick.bind(this);
return (
<section style="padding-bottom: 1em;">
<div>Проксировать указанный сайт?</div>
@ -301,8 +300,8 @@ export default function getExcEditor(theState) {
value={this.state.trimmedInputValueOrSpace}
ref={(inputNode) => { this.rawInput = inputNode; }}
onKeyDown={this.handleKeyDown.bind(this)}
onInput={oninput}
onClick={oninput}
onInput={this.handleInputOrClick}
onClick={this.handleInputOrClick}
/>
</div>
{/*<a href class="emoji">⇄</a>*/}
@ -325,13 +324,13 @@ export default function getExcEditor(theState) {
}
</datalist>
<ol class="horizontalList middledChildren" id="exc-radio">
<li><input id="this-auto" type="radio" checked name="if-proxy-this-site" onClick={onradio}/>{' '}
<li><input id="this-auto" type="radio" checked name="if-proxy-this-site" onClick={this.handleRadioClick}/>{' '}
<label for="this-auto">{/*<span class="emoji">🔄(looks fat)</span>*/}<svg
class="icon"
style="position: relative; top: 0.15em;"><use xlink:href="#iconLoopRound"></use></svg>&nbsp;авто</label>
</li>
<li>
<input id="this-yes" type="radio" name="if-proxy-this-site" checked={inputProxyingState === true} onClick={onradio}/>
<input id="this-yes" type="radio" name="if-proxy-this-site" checked={inputProxyingState === true} onClick={this.handleRadioClick}/>
{' '}<label for="this-yes">
<span
class="emoji____buggy"
@ -339,7 +338,7 @@ export default function getExcEditor(theState) {
</label>
</li>
<li>
<input id="this-no" type="radio" name="if-proxy-this-site" checked={inputProxyingState === false} onClick={onradio}/>
<input id="this-no" type="radio" name="if-proxy-this-site" checked={inputProxyingState === false} onClick={this.handleRadioClick}/>
{' '}<label for="this-no"><span class="emoji"></span>&nbsp;нет</label></li>
</ol>
</section>

View File

@ -107,12 +107,12 @@ export default function getInfoLi() {
};
return function InfoLi(props) {
return function InfoLi(originalProps) {
props = Object.assign({}, {
const props = Object.assign({}, {
idPrefix: '',
ifDashify: false,
}, props);
}, originalProps);
const iddy = props.idPrefix + ( props.ifDashify ? camelToDash(props.conf.key) : props.conf.key );
@ -124,6 +124,7 @@ export default function getInfoLi() {
onClick: props.onClick,
onChange: props.onChange,
class: props.class,
disabled: props.ifInputsDisabled,
};
delete inputProps.children;

View File

@ -64,6 +64,7 @@ export default function getModList(theState) {
checked={this.state.checks[index]}
key={index}
onChange={(event) => this.handleCheck(confMeta, event.target.checked)}
ifInputsDisabled={props.ifInputsDisabled}
>
{child}
</InfoLi>);

View File

@ -68,6 +68,8 @@ export default function getPacChooser(theState) {
onSuccess
);
};
this.radioClickHandler = this.radioClickHandler.bind(this);
this.updateClickHandler = this.updateClickHandler.bind(this);
}
@ -77,6 +79,13 @@ export default function getPacChooser(theState) {
}
updateClickHandler(event) {
event.preventDefault();
this.updatePac();
}
radioClickHandler(event) {
const checkChosenProvider = () =>
@ -120,18 +129,13 @@ export default function getPacChooser(theState) {
{
[...props.apis.antiCensorRu.getSortedEntriesForProviders(), {key: 'none', label: 'Отключить'}].map((provConf) =>
(<InfoLi
onClick={this.radioClickHandler.bind(this)}
onClick={this.radioClickHandler}
conf={provConf}
type="radio"
name="pacProvider"
checked={iddyToCheck === provConf.key}
disabled={props.ifInputsDisabled}
nodeAfterLabel={<a href="" class={scopedCss.updateButton} onClick={(evt) => {
evt.preventDefault();
this.updatePac();
}}>[обновить]</a>}
ifInputsDisabled={props.ifInputsDisabled}
nodeAfterLabel={<a href="" class={scopedCss.updateButton} onClick={this.updateClickHandler}>[обновить]</a>}
/>)
)
}