Skip to content

Commit

Permalink
Release v0.1.0-beta.4
Browse files Browse the repository at this point in the history
  • Loading branch information
tobyzerner committed Nov 5, 2015
1 parent de95219 commit e2f919e
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 23 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Change Log
All notable changes to the Subscriptions extension will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [0.1.0-beta.4] - 2015-11-05
### Added
- Add a tooltip to the Follow button

[0.1.0-beta.4]: https://github.com/flarum/subscriptions/compare/v0.1.0-beta.3...v0.1.0-beta.4
72 changes: 49 additions & 23 deletions js/forum/dist/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,26 @@ System.register('flarum/subscriptions/components/SubscriptionMenu', ['flarum/Com
}

babelHelpers.createClass(SubscriptionMenu, [{
key: 'init',
value: function init() {
this.options = [{
subscription: false,
icon: 'star-o',
label: app.translator.trans('flarum-subscriptions.forum.sub_controls.not_following_button'),
description: app.translator.trans('flarum-subscriptions.forum.sub_controls.not_following_text')
}, {
subscription: 'follow',
icon: 'star',
label: app.translator.trans('flarum-subscriptions.forum.sub_controls.following_button'),
description: app.translator.trans('flarum-subscriptions.forum.sub_controls.following_text')
}, {
subscription: 'ignore',
icon: 'eye-slash',
label: app.translator.trans('flarum-subscriptions.forum.sub_controls.ignoring_button'),
description: app.translator.trans('flarum-subscriptions.forum.sub_controls.ignoring_text')
}];
}
}, {
key: 'view',
value: function view() {
var _this = this;
Expand All @@ -235,32 +255,36 @@ System.register('flarum/subscriptions/components/SubscriptionMenu', ['flarum/Com
// no default
}

var options = [{
subscription: false,
icon: 'star-o',
label: app.translator.trans('flarum-subscriptions.forum.sub_controls.not_following_button'),
description: app.translator.trans('flarum-subscriptions.forum.sub_controls.not_following_text')
}, {
subscription: 'follow',
icon: 'star',
label: app.translator.trans('flarum-subscriptions.forum.sub_controls.following_button'),
description: app.translator.trans('flarum-subscriptions.forum.sub_controls.following_text')
}, {
subscription: 'ignore',
icon: 'eye-slash',
label: app.translator.trans('flarum-subscriptions.forum.sub_controls.ignoring_button'),
description: app.translator.trans('flarum-subscriptions.forum.sub_controls.ignoring_text')
}];
var buttonProps = {
className: 'Button SubscriptionMenu-button ' + buttonClass,
icon: buttonIcon,
children: buttonLabel,
onclick: this.saveSubscription.bind(this, discussion, ['follow', 'ignore'].indexOf(subscription) !== -1 ? false : 'follow')
};

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')
});
};
} else {
buttonProps.config = function (element) {
return $(element).tooltip('destroy');
};
}

return m(
'div',
{ className: 'Dropdown ButtonGroup SubscriptionMenu' },
Button.component({
className: 'Button SubscriptionMenu-button ' + buttonClass,
icon: buttonIcon,
children: buttonLabel,
onclick: this.saveSubscription.bind(this, discussion, ['follow', 'ignore'].indexOf(subscription) !== -1 ? false : 'follow')
}),
Button.component(buttonProps),
m(
'button',
{ className: 'Dropdown-toggle Button Button--icon ' + buttonClass, 'data-toggle': 'dropdown' },
Expand All @@ -269,7 +293,7 @@ System.register('flarum/subscriptions/components/SubscriptionMenu', ['flarum/Com
m(
'ul',
{ className: 'Dropdown-menu dropdown-menu Dropdown-menu--right' },
options.map(function (props) {
this.options.map(function (props) {
props.onclick = _this.saveSubscription.bind(_this, discussion, props.subscription);
props.active = subscription === props.subscription;

Expand All @@ -286,6 +310,8 @@ System.register('flarum/subscriptions/components/SubscriptionMenu', ['flarum/Com
key: 'saveSubscription',
value: function saveSubscription(discussion, subscription) {
discussion.save({ subscription: subscription });

this.$('.SubscriptionMenu-button').tooltip('hide');
}
}]);
return SubscriptionMenu;
Expand Down

0 comments on commit e2f919e

Please sign in to comment.