import React from 'react';
import * as commonFuncs from '../../services/common-functions';
class BoxTool extends React.Component {
constructor(props){
super(props);
this.toggleCollapse = this.toggleCollapse.bind(this);
this.removeBox = this.removeBox.bind(this);
}
toggleCollapse(e) {
let box = commonFuncs.findClosestElement(e.currentTarget, this.props.containerClass);
let boxBody = box.children[1];
let icon = e.currentTarget.children[0];
commonFuncs.toggleBoxCollapse(box, boxBody, icon);
}
removeBox(e) {
let box = commonFuncs.findClosestElement(e.currentTarget, this.props.containerClass);
commonFuncs.removeBox(box);
}
render() {
let button = '';
let self = this;
switch(this.props.toolType){
case('expand'):
return (<button className="btn btn-box-tool" data-widget="expand" onClick={self.toggleCollapse}><i className="fa fa-plus"></i></button>);
case('collapse'):
return (<button className="btn btn-box-tool" data-widget="collapse" onClick={self.toggleCollapse}><i className="fa fa-minus"></i></button>);
case('remove'):
return (<button className="btn btn-box-tool" data-widget="remove" onClick={self.removeBox}><i className="fa fa-times"></i></button>);
}
}
}
export default BoxTool;
|