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), sortedListOfOptions: this.modsToOpts(pacMods),
isHostHidden: {} isHostHidden: {}
}; };
this.handleRadioClick = this.handleRadioClick.bind(this);
this.handleInputOrClick = this.handleInputOrClick.bind(this);
} }
@ -289,9 +291,6 @@ export default function getExcEditor(theState) {
}, undefined); }, undefined);
const onradio = this.handleRadioClick.bind(this);
const oninput = this.handleInputOrClick.bind(this);
return ( return (
<section style="padding-bottom: 1em;"> <section style="padding-bottom: 1em;">
<div>Проксировать указанный сайт?</div> <div>Проксировать указанный сайт?</div>
@ -301,8 +300,8 @@ export default function getExcEditor(theState) {
value={this.state.trimmedInputValueOrSpace} value={this.state.trimmedInputValueOrSpace}
ref={(inputNode) => { this.rawInput = inputNode; }} ref={(inputNode) => { this.rawInput = inputNode; }}
onKeyDown={this.handleKeyDown.bind(this)} onKeyDown={this.handleKeyDown.bind(this)}
onInput={oninput} onInput={this.handleInputOrClick}
onClick={oninput} onClick={this.handleInputOrClick}
/> />
</div> </div>
{/*<a href class="emoji">⇄</a>*/} {/*<a href class="emoji">⇄</a>*/}
@ -325,13 +324,13 @@ export default function getExcEditor(theState) {
} }
</datalist> </datalist>
<ol class="horizontalList middledChildren" id="exc-radio"> <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 <label for="this-auto">{/*<span class="emoji">🔄(looks fat)</span>*/}<svg
class="icon" class="icon"
style="position: relative; top: 0.15em;"><use xlink:href="#iconLoopRound"></use></svg>&nbsp;авто</label> style="position: relative; top: 0.15em;"><use xlink:href="#iconLoopRound"></use></svg>&nbsp;авто</label>
</li> </li>
<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"> {' '}<label for="this-yes">
<span <span
class="emoji____buggy" class="emoji____buggy"
@ -339,7 +338,7 @@ export default function getExcEditor(theState) {
</label> </label>
</li> </li>
<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> {' '}<label for="this-no"><span class="emoji"></span>&nbsp;нет</label></li>
</ol> </ol>
</section> </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: '', idPrefix: '',
ifDashify: false, ifDashify: false,
}, props); }, originalProps);
const iddy = props.idPrefix + ( props.ifDashify ? camelToDash(props.conf.key) : props.conf.key ); const iddy = props.idPrefix + ( props.ifDashify ? camelToDash(props.conf.key) : props.conf.key );
@ -124,6 +124,7 @@ export default function getInfoLi() {
onClick: props.onClick, onClick: props.onClick,
onChange: props.onChange, onChange: props.onChange,
class: props.class, class: props.class,
disabled: props.ifInputsDisabled,
}; };
delete inputProps.children; delete inputProps.children;

View File

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

View File

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