4 * Copyright 2016 RIFT.IO Inc
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 var React = require('react');
20 var Slider = require('react-slick');
21 //import SkyquakeCarousel from './skyquakeCarousel.jsx';
22 //This componenet should not be coupled with launchpad
24 import button from 'widgets/button/rw.button.js'
25 var LaunchpadFleetStore = require('../launchpadFleetStore.js');
26 var LaunchpadFleetActions = require('../launchpadFleetActions.js');
28 require('./carousel.css');
29 var SimpleSlider = React.createClass({
31 component_list: React.PropTypes.array.isRequired,
32 slideno: React.PropTypes.number,
33 externalChangeSlide: React.PropTypes.bool
35 handleClick: function() {
38 getDefaultProps: function() {
39 this.externalChangeSlide = false;
41 externalChangeSlide: false
44 getInitialState: function() {
49 changeSlide: function(data) {
50 if (data.slideChange > 0) {
52 for (var i = 0; i < this.props.component_list.length; i++) {
53 var component = this.props.component_list[i].component;
54 if (Object.prototype.toString.call(component) === "[object Array]") {
55 for (var j = 0; j < component.length; j++) {
56 var subcomponent = component[j];
57 if (subcomponent.props.mp === data.dropdownSlide[0]) {
62 if (component.props.mp === data.dropdownSlide[0]) {
70 this.externalChangeSlide = true;
71 this.setState({slideno: parseFloat(setSlide)});
74 componentDidMount: function() {
75 // LaunchpadFleetStore.listen(this.changeSlide);
77 componentWillUnmount: function() {
79 shouldComponentUpdate: function(nextProps) {
82 // This prevents things in the carousel from updating which makes no sense because we're displaying metrics that need to update
83 // if (nextProps.slideno != this.props.slideno) {
88 componentDidUpdate: function(prevProps, prevState) {
89 if (this.externalChangeSlide > 0) {
90 this.externalChangeSlide = false;
91 // LaunchpadFleetActions.slideNoStateChangeSuccess();
94 handleResize: function(e) {
103 // slidesToScroll: 1,
105 // initialSlide: this.props.slideno || 2
114 changeSlide: this.externalChangeSlide,
115 initialSlide: this.state.slideno || 0
117 if (this.externalChangeSlide) {
118 settings.initialSlide = this.state.slideno;
120 setTimeout(function() {
121 window.dispatchEvent(new Event('resize'));
124 if (this.props.component_list !== undefined) {
125 for (var i = 0; i < this.props.component_list.length; i++) {
126 let title = this.props.component_list[i].title;
127 let displayTitle = title ? 'inherit' : 'none';
128 list.push(<div key={i} className={"component"}><h2 style={{flex: '0 1 auto', justifyContent: 'center', alignSelf: 'center', display: displayTitle, padding: '0.5rem'}}>{title}</h2><div className="componentWrapper">{this.props.component_list[i].component}</div></div>);
132 <div className={list.length > 1 ? '' : 'hideButtons'}>
133 <Slider {...settings}>
140 module.exports = SimpleSlider;