Fix for pluginpanel crashing

This commit is contained in:
Alexei Stukov 2017-04-30 14:16:29 +03:00 committed by GitHub
parent 91dd2e6ee7
commit 060c2ab0ec
1 changed files with 4 additions and 3 deletions

7
js/main.min.js vendored
View File

@ -491,13 +491,14 @@ class V2C_List extends BDV2.reactComponent{constructor(props){super(props)}
render(){return BDV2.react.createElement("ul",{className:this.props.className},this.props.children)}}
class V2C_ContentColumn extends BDV2.reactComponent{constructor(props){super(props)}
render(){return BDV2.react.createElement("div",{className:"content-column default"},BDV2.react.createElement("h2",{className:"ui-form-title h2 margin-reset margin-bottom-20"},this.props.title),this.props.children)}}
class V2C_PluginCard extends BDV2.reactComponent{constructor(props){super(props);let self=this;self.settingsPanel=self.props.plugin.getSettingsPanel();self.onChange=self.onChange.bind(self);self.showSettings=self.showSettings.bind(self);self.setInitialState()}
class V2C_PluginCard extends BDV2.reactComponent{constructor(props){super(props);let self=this;if(typeof self.props.plugin.getSettingsPanel==="function"){self.settingsPanel=self.props.plugin.getSettingsPanel()}
self.onChange=self.onChange.bind(self);self.showSettings=self.showSettings.bind(self);self.setInitialState()}
setInitialState(){this.state={'checked':pluginCookie[this.props.plugin.getName()],'settings':!1}}
componentDidUpdate(){if(this.state.settings){if(typeof this.settingsPanel==="object"){this.refs.settingspanel.appendChild(this.settingsPanel)}}}
render(){let self=this;let{plugin}=this.props;let name=plugin.getName();let author=plugin.getAuthor();let description=plugin.getDescription();let version=plugin.getVersion();let{settingsPanel}=this;if(this.state.settings){return BDV2.react.createElement("li",{style:{maxHeight:"500px",overflow:"auto"}},BDV2.react.createElement("div",{style:{float:"right",cursor:"pointer"},onClick:()=>{this.refs.settingspanel.innerHTML="";self.setState({'settings':!1})}},BDV2.react.createElement(V2Components.XSvg,null)),typeof settingsPanel==='object'&&BDV2.react.createElement("div",{ref:"settingspanel"}),typeof settingsPanel!=='object'&&BDV2.react.createElement("div",{ref:"settingspanel",dangerouslySetInnerHTML:{__html:plugin.getSettingsPanel()}}))}
return BDV2.react.createElement("li",null,BDV2.react.createElement("div",{className:"bda-left"},BDV2.react.createElement("span",{className:"bda-name"},name," v",version," by ",author),BDV2.react.createElement("div",{className:"scroller-wrap fade"},BDV2.react.createElement("div",{className:"scroller bda-description"},description))),BDV2.react.createElement("div",{className:"bda-right"},BDV2.react.createElement("label",{className:"ui-switch-wrapper ui-flex-child",style:{flex:'0 0 auto'}},BDV2.react.createElement("input",{checked:this.state.checked,onChange:this.onChange,className:"ui-switch-checkbox",type:"checkbox"}),BDV2.react.createElement("div",{className:"ui-switch"})),BDV2.react.createElement("button",{onClick:this.showSettings},"Settings")))}
return BDV2.react.createElement("li",null,BDV2.react.createElement("div",{className:"bda-left"},BDV2.react.createElement("span",{className:"bda-name"},name," v",version," by ",author),BDV2.react.createElement("div",{className:"scroller-wrap fade"},BDV2.react.createElement("div",{className:"scroller bda-description"},description))),BDV2.react.createElement("div",{className:"bda-right"},BDV2.react.createElement("label",{className:"ui-switch-wrapper ui-flex-child",style:{flex:'0 0 auto'}},BDV2.react.createElement("input",{checked:this.state.checked,onChange:this.onChange,className:"ui-switch-checkbox",type:"checkbox"}),BDV2.react.createElement("div",{className:"ui-switch"})),this.settingsPanel&&BDV2.react.createElement("button",{onClick:this.showSettings},"Settings")))}
onChange(){let self=this;self.setState({'checked':!self.state.checked});pluginCookie[self.props.plugin.getName()]=!self.state.checked;if(!self.state.checked){self.props.plugin.start()}else{self.props.plugin.stop()}}
showSettings(){this.setState({'settings':!0})}}
showSettings(){if(!this.settingsPanel)return;this.setState({'settings':!0})}}
class V2C_ThemeCard extends BDV2.reactComponent{constructor(props){super(props);this.setInitialState();this.onChange=this.onChange.bind(this)}
setInitialState(){this.state={'checked':themeCookie[this.props.theme.name]}}
render(){let{theme}=this.props;let name=theme.name.replace('_',' ');let description=theme.description;let version=theme.version;let author=theme.author;return BDV2.react.createElement("li",null,BDV2.react.createElement("div",{className:"bda-left"},BDV2.react.createElement("span",{className:"bda-name"},name," v",version," by ",author),BDV2.react.createElement("div",{className:"scroller-wrap fade"},BDV2.react.createElement("div",{className:"scroller bda-description"},description))),BDV2.react.createElement("div",{className:"bda-right"},BDV2.react.createElement("label",{className:"ui-switch-wrapper ui-flex-child",style:{flex:'0 0 auto'}},BDV2.react.createElement("input",{checked:this.state.checked,onChange:this.onChange,className:"ui-switch-checkbox",type:"checkbox"}),BDV2.react.createElement("div",{className:"ui-switch"}))))}