From 060c2ab0ecbafe7ff4d7012eb87a65cf381ddca4 Mon Sep 17 00:00:00 2001 From: Alexei Stukov Date: Sun, 30 Apr 2017 14:16:29 +0300 Subject: [PATCH] Fix for pluginpanel crashing --- js/main.min.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/js/main.min.js b/js/main.min.js index 4c966d2..e959327 100644 --- a/js/main.min.js +++ b/js/main.min.js @@ -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"}))))}