/* * * Copyright 2016 RIFT.IO Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ import React from 'react'; import RWslider from 'widgets/input-range-slider/input-range-slider.jsx'; import {Tab, Tabs, TabList, TabPanel} from 'react-tabs'; import CardActions from './launchpadCardActions.js'; let currentID, lastSelected; function isTabNode(node) { return node.nodeName === 'LI' && node.getAttribute('role') === 'tab'; } class launchpadControls extends React.Component { constructor(props, context) { super(props, context); this.state = { controlSets: this.props.controlSets, selectedIndex: 0, currentId: 0 }; this.handleInputUpdate = this.handleInputUpdate.bind(this); this.handleSelected = this.handleSelected.bind(this); this.handleSameTab = this.handleSameTab.bind(this); } handleSelected(index,last) { this.state.selectedIndex = index; } //If same Tab is clicked, default to empty tab contents handleSameTab(e) { var node = e.target.parentNode; var isTab = isTabNode(node); if(isTab) { if(node.id == currentID) { this.state.selectedIndex = 0; currentID = null; this.forceUpdate(); } else { currentID = node.id } } } componentWillReceiveProps(nextProps) { if((!this.state.controlSets && nextProps.controlSets) || this.state.controlSets && !nextProps.controlSets) { this.state.controlSets = nextProps.controlSets; }; } shouldComponentUpdate(nextProps, nextState) { // console.log(this.props, nextProps); // console.log(this.state, nextState) return true; } handleInputUpdate(gIndex, groupID, cIndex, options, value) { this.state.controlSets[gIndex][groupID]['control-param'][cIndex].value = value; CardActions.updateControlInput(options, value) } render() { let self = this; if(!this.state.controlSets) { return (
) } else { return (