From 6e24d620005a36d1e9ee52857b61f12079a93de9 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Thu, 5 Nov 2015 16:34:30 +1030 Subject: [PATCH] Release v0.1.0-beta.4 --- extensions/subscriptions/CHANGELOG.md | 9 +++ .../subscriptions/js/forum/dist/extension.js | 72 +++++++++++++------ 2 files changed, 58 insertions(+), 23 deletions(-) create mode 100644 extensions/subscriptions/CHANGELOG.md diff --git a/extensions/subscriptions/CHANGELOG.md b/extensions/subscriptions/CHANGELOG.md new file mode 100644 index 000000000..83226e356 --- /dev/null +++ b/extensions/subscriptions/CHANGELOG.md @@ -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 diff --git a/extensions/subscriptions/js/forum/dist/extension.js b/extensions/subscriptions/js/forum/dist/extension.js index 3e9e7c6c2..ad151c66f 100644 --- a/extensions/subscriptions/js/forum/dist/extension.js +++ b/extensions/subscriptions/js/forum/dist/extension.js @@ -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; @@ -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' }, @@ -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; @@ -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;