2016-03-12 07:09:59 +08:00
|
|
|
Polling = React.createClass({
|
|
|
|
//#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 (
|
2016-03-13 08:27:29 +08:00
|
|
|
<div className="polling">
|
2016-03-12 07:09:59 +08:00
|
|
|
{this.getStyledAnswers(this.data.poll).map((question) =>
|
2016-03-13 08:27:29 +08:00
|
|
|
<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-03-12 07:09:59 +08:00
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
});
|