bigbluebutton-Github/bigbluebutton-html5/app/client/views/whiteboard/EmojiContainer.jsx

82 lines
2.5 KiB
React
Raw Normal View History

2016-03-23 05:50:44 +08:00
EmojiContainer = React.createClass ({
2016-03-24 05:31:13 +08:00
mixins: [ReactMeteorData],
2016-03-23 05:50:44 +08:00
getMeteorData() {
2016-03-24 05:31:13 +08:00
let user, emoji_status, current_presentation;
user = BBB.getCurrentUser();
if(user != null) {
emoji_status = user.user.emoji_status;
} else {
emoji_status = "none";
}
current_presentation = Meteor.Presentations.findOne({
2016-03-23 05:50:44 +08:00
'presentation.current': true
});
2016-03-24 05:31:13 +08:00
current_presentation ? current_presentation = true : current_presentation = false;
return {
emoji_status: emoji_status,
current_presentation: current_presentation
};
2016-03-23 05:50:44 +08:00
},
getCurrentUserEmojiStatus(name) {
2016-03-24 05:31:13 +08:00
return name == this.data.emoji_status;
2016-03-23 05:50:44 +08:00
},
emojiIcons() {
return [
{ name: 'sad', icon: 'sad-face', title: ''},
{ name: 'happy', icon: 'happy-face', title: ''},
{ name: 'confused', icon: 'confused-face', title: ''},
{ name: 'neutral', icon: 'neutral-face', title: ''},
{ name: 'away', icon: 'clock', title: ''},
{ name: 'raiseHand', icon: 'hand', title: 'Lower your Hand'}
];
},
2016-03-24 05:31:13 +08:00
handleInactive(name, event) {
2016-03-23 05:50:44 +08:00
if($(event.target).css('opacity') === '1') {
BBB.setEmojiStatus(
BBB.getMeetingId(),
getInSession('userId'),
getInSession('userId'),
getInSession('authToken'),
2016-03-24 05:31:13 +08:00
name
2016-03-23 05:50:44 +08:00
);
$('.FABTriggerButton').blur();
return toggleEmojisFAB();
}
},
2016-03-24 05:40:49 +08:00
2016-03-23 05:50:44 +08:00
handleActive(event) {
if($('.activeEmojiButton').css('opacity') === '1') {
BBB.setEmojiStatus(
BBB.getMeetingId(),
getInSession('userId'),
getInSession('userId'),
getInSession('authToken'),
"none"
);
$('.FABTriggerButton').blur();
return toggleEmojisFAB();
}
},
2016-03-24 05:40:49 +08:00
2016-03-23 05:50:44 +08:00
handleFABTriggerButton(event) {
$('.FABTriggerButton').blur();
return toggleEmojisFAB();
},
render() {
2016-03-24 05:40:49 +08:00
return (
2016-03-24 05:31:13 +08:00
<div className={ classNames('FABContainer', !this.data.current_presentation ? 'noPresentation' : '' ) }>
2016-03-23 05:50:44 +08:00
<Button onClick={ this.handleFABTriggerButton } btn_class="FABTriggerButton" i_class="ion-android-hand"/>
{this.emojiIcons().map((emoji) =>
<Button btn_class={ classNames(' ' + emoji.name + 'EmojiButton', this.getCurrentUserEmojiStatus(emoji.name) ? 'activeEmojiButton' : 'inactiveEmojiButton') }
2016-03-24 05:31:13 +08:00
onClick={ this.getCurrentUserEmojiStatus(emoji.name) ? this.handleActive : this.handleInactive.bind(null, emoji.name) }
2016-03-23 05:50:44 +08:00
key={emoji.name} emoji={ emoji.icon }/>
)}
</div>
);
}
2016-03-24 05:40:49 +08:00
});