Fix SubscriptionMenu button title

This commit is contained in:
Toby Zerner 2016-04-08 13:47:22 +09:30
parent 60e6cfdbbd
commit a0779cbdef
2 changed files with 23 additions and 16 deletions

View File

@ -214,8 +214,8 @@ System.register('flarum/subscriptions/components/NewPostNotification', ['flarum/
});;
'use strict';
System.register('flarum/subscriptions/components/SubscriptionMenu', ['flarum/components/Dropdown', 'flarum/components/Button', 'flarum/helpers/icon', 'flarum/subscriptions/components/SubscriptionMenuItem'], function (_export, _context) {
var Dropdown, Button, icon, SubscriptionMenuItem, SubscriptionMenu;
System.register('flarum/subscriptions/components/SubscriptionMenu', ['flarum/components/Dropdown', 'flarum/components/Button', 'flarum/helpers/icon', 'flarum/utils/extractText', 'flarum/subscriptions/components/SubscriptionMenuItem'], function (_export, _context) {
var Dropdown, Button, icon, extractText, SubscriptionMenuItem, SubscriptionMenu;
return {
setters: [function (_flarumComponentsDropdown) {
Dropdown = _flarumComponentsDropdown.default;
@ -223,6 +223,8 @@ System.register('flarum/subscriptions/components/SubscriptionMenu', ['flarum/com
Button = _flarumComponentsButton.default;
}, function (_flarumHelpersIcon) {
icon = _flarumHelpersIcon.default;
}, function (_flarumUtilsExtractText) {
extractText = _flarumUtilsExtractText.default;
}, function (_flarumSubscriptionsComponentsSubscriptionMenuItem) {
SubscriptionMenuItem = _flarumSubscriptionsComponentsSubscriptionMenuItem.default;
}],
@ -282,24 +284,26 @@ System.register('flarum/subscriptions/components/SubscriptionMenu', ['flarum/com
// no default
}
var preferences = app.session.user.preferences();
var notifyEmail = preferences['notify_newPost_email'];
var notifyAlert = preferences['notify_newPost_alert'];
var title = extractText(app.translator.trans(notifyEmail ? 'flarum-subscriptions.forum.sub_controls.notify_email_tooltip' : 'flarum-subscriptions.forum.sub_controls.notify_alert_tooltip'));
var buttonProps = {
className: 'Button SubscriptionMenu-button ' + buttonClass,
icon: buttonIcon,
children: buttonLabel,
onclick: this.saveSubscription.bind(this, discussion, ['follow', 'ignore'].indexOf(subscription) !== -1 ? false : 'follow')
onclick: this.saveSubscription.bind(this, discussion, ['follow', 'ignore'].indexOf(subscription) !== -1 ? false : 'follow'),
title: title
};
var preferences = app.session.user.preferences();
var notifyEmail = preferences['notify_newPost_email'];
var notifyAlert = preferences['notify_newPost_alert'];
if ((notifyEmail || notifyAlert) && subscription === false) {
buttonProps.config = function (element) {
$(element).tooltip({
container: '.SubscriptionMenu',
placement: 'bottom',
delay: 250,
title: app.translator.trans(notifyEmail ? 'flarum-subscriptions.forum.sub_controls.notify_email_tooltip' : 'flarum-subscriptions.forum.sub_controls.notify_alert_tooltip')
title: title
});
};
} else {

View File

@ -1,6 +1,7 @@
import Dropdown from 'flarum/components/Dropdown';
import Button from 'flarum/components/Button';
import icon from 'flarum/helpers/icon';
import extractText from 'flarum/utils/extractText';
import SubscriptionMenuItem from 'flarum/subscriptions/components/SubscriptionMenuItem';
@ -51,26 +52,28 @@ export default class SubscriptionMenu extends Dropdown {
// no default
}
const preferences = app.session.user.preferences();
const notifyEmail = preferences['notify_newPost_email'];
const notifyAlert = preferences['notify_newPost_alert'];
const title = extractText(app.translator.trans(notifyEmail
? 'flarum-subscriptions.forum.sub_controls.notify_email_tooltip'
: 'flarum-subscriptions.forum.sub_controls.notify_alert_tooltip'));
const buttonProps = {
className: 'Button SubscriptionMenu-button ' + buttonClass,
icon: buttonIcon,
children: buttonLabel,
onclick: this.saveSubscription.bind(this, discussion, ['follow', 'ignore'].indexOf(subscription) !== -1 ? false : 'follow')
onclick: this.saveSubscription.bind(this, discussion, ['follow', 'ignore'].indexOf(subscription) !== -1 ? false : 'follow'),
title: title
};
const preferences = app.session.user.preferences();
const notifyEmail = preferences['notify_newPost_email'];
const notifyAlert = preferences['notify_newPost_alert'];
if ((notifyEmail || notifyAlert) && subscription === false) {
buttonProps.config = element => {
$(element).tooltip({
container: '.SubscriptionMenu',
placement: 'bottom',
delay: 250,
title: app.translator.trans(notifyEmail
? 'flarum-subscriptions.forum.sub_controls.notify_email_tooltip'
: 'flarum-subscriptions.forum.sub_controls.notify_alert_tooltip')
title
});
}
} else {