Add a tooltip to the "Follow" button

This commit is contained in:
Toby Zerner 2015-11-03 17:17:46 +10:30
parent 1e49c46d51
commit 8785baf1a1

View File

@ -51,14 +51,33 @@ export default class SubscriptionMenu extends Component {
// no default // no default
} }
const buttonProps = {
className: 'Button SubscriptionMenu-button ' + buttonClass,
icon: buttonIcon,
children: buttonLabel,
onclick: this.saveSubscription.bind(this, discussion, ['follow', 'ignore'].indexOf(subscription) !== -1 ? false : 'follow')
};
const preferences = app.session.user.preferences();
const notifyEmail = preferences['notify_newPost_email'];
const notifyAlert = preferences['notify_newPost_alert'];
if ((notifyEmail || notifyAlert) && subscription === false) {
buttonProps.title = app.translator.trans(notifyEmail
? 'flarum-subscriptions.forum.sub_controls.notify_email_tooltip'
: 'flarum-subscriptions.forum.sub_controls.notify_alert_tooltip');
buttonProps.config = element => $(element).tooltip({
container: '.SubscriptionMenu',
placement: 'bottom',
delay: 250
});
} else {
buttonProps.config = element => $(element).tooltip('destroy');
}
return ( return (
<div className="Dropdown ButtonGroup SubscriptionMenu"> <div className="Dropdown ButtonGroup SubscriptionMenu">
{Button.component({ {Button.component(buttonProps)}
className: 'Button SubscriptionMenu-button ' + buttonClass,
icon: buttonIcon,
children: buttonLabel,
onclick: this.saveSubscription.bind(this, discussion, ['follow', 'ignore'].indexOf(subscription) !== -1 ? false : 'follow')
})}
<button className={'Dropdown-toggle Button Button--icon ' + buttonClass} data-toggle="dropdown"> <button className={'Dropdown-toggle Button Button--icon ' + buttonClass} data-toggle="dropdown">
{icon('caret-down', {className: 'Button-icon'})} {icon('caret-down', {className: 'Button-icon'})}
@ -78,5 +97,7 @@ export default class SubscriptionMenu extends Component {
saveSubscription(discussion, subscription) { saveSubscription(discussion, subscription) {
discussion.save({subscription}); discussion.save({subscription});
this.$('.SubscriptionMenu-button').tooltip('hide');
} }
} }