bigbluebutton-Github/bigbluebutton-html5/imports/ui/whiteboard/Polling.jsx

55 lines
1.5 KiB
React
Raw Normal View History

2016-04-22 05:30:54 +08:00
import React from 'react';
import { Button } from '../shared/Button.jsx';
2016-04-22 05:30:54 +08:00
export let Polling = React.createClass({
2016-03-12 07:09:59 +08:00
//#TODO Move this to parent later?
mixins: [ReactMeteorData],
getMeteorData() {
let poll;
poll = BBB.getCurrentPoll(getInSession('userId'));
return {
poll: poll
};
},
componentDidMount: function() {
return scaleWhiteboard();
},
componentWillUnmount: function() {
setTimeout(scaleWhiteboard, 0);
},
getStyledAnswers(poll) {
let number, buttonStyle, answers;
if(poll != null) {
number = poll.poll_info.poll.answers.length;
buttonStyle = {
width: 'calc(75%/' + number + ')',
marginLeft: 'calc(25%/' + number * 2 + ')',
marginRight: 'calc(25%/ ' + number * 2 + ')'
};
answers = poll.poll_info.poll.answers;
for(j = 0; j < number; j++) {
answers[j].style = buttonStyle;
}
return answers;
}
},
handleClick: function(label, answer) {
return BBB.sendPollResponseMessage(label, answer);
},
render(){
return (
<div className="polling">
2016-04-21 00:08:23 +08:00
{this.data.poll ? this.getStyledAnswers(this.data.poll).map((question) =>
<Button onClick={this.handleClick.bind(null, question.key, question.id)} btn_class=" pollButtons" rel="tooltip" data_placement="top"
label={question.key} style={question.style} key={question.id}/>
2016-04-21 00:08:23 +08:00
) : null }
2016-03-12 07:09:59 +08:00
</div>
)
}
});