From 214b011bb5fcd581459c066f0216ad1bfd92afb8 Mon Sep 17 00:00:00 2001 From: Brock Whittaker Date: Thu, 26 Jan 2017 15:40:42 -0800 Subject: [PATCH] Add subscribe button inside subscription settings. This adds a subscribe/unsubscribe button inside the subscription settings container for a stream right next to the stream name. --- static/js/subs.js | 10 ++++++++++ static/styles/components.css | 4 ++++ static/styles/subscriptions.css | 17 ++++++++++++++++- .../templates/subscription_settings.handlebars | 2 ++ 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/static/js/subs.js b/static/js/subs.js index b40fc62d80..2eea909c64 100644 --- a/static/js/subs.js +++ b/static/js/subs.js @@ -17,6 +17,11 @@ function button_for_sub(sub) { return $(".stream-row[data-stream-id='" + id + "'] .check"); } +function settings_button_for_sub(sub) { + var id = parseInt(sub.stream_id, 10); + return $(".subscription_settings[data-stream-id='" + id + "'] .subscribe-button"); +} + function get_color() { var used_colors = stream_data.get_colors(); var color = stream_color.pick_color(used_colors); @@ -404,11 +409,13 @@ exports.mark_subscribed = function (stream_name, attrs) { } var settings = settings_for_sub(sub); var button = button_for_sub(sub); + var settings_button = settings_button_for_sub(sub).removeClass("unsubscribed"); if (button.length !== 0) { exports.rerender_subscribers_count(sub); button.toggleClass("checked"); + settings_button.text(i18n.t("Unsubscribe")); // Add the user to the member list if they're currently // viewing the members of this stream if (sub.render_subscribers && settings.hasClass('in')) { @@ -448,7 +455,10 @@ exports.mark_sub_unsubscribed = function (sub) { stream_data.unsubscribe_myself(sub); var button = button_for_sub(sub); + var settings_button = settings_button_for_sub(sub).addClass("unsubscribed"); + button.toggleClass("checked"); + settings_button.text(i18n.t("Subscribe")); var settings = settings_for_sub(sub); if (settings.hasClass('in')) { diff --git a/static/styles/components.css b/static/styles/components.css index 8aa109857b..5b1e074aa1 100644 --- a/static/styles/components.css +++ b/static/styles/components.css @@ -83,6 +83,10 @@ box-shadow: none !important; } +.new-style .button.rounded { + border-radius: 4px; +} + .new-style .button.green { background-color: #64ad89; } diff --git a/static/styles/subscriptions.css b/static/styles/subscriptions.css index 8067fcb1fb..7514fd8a35 100644 --- a/static/styles/subscriptions.css +++ b/static/styles/subscriptions.css @@ -202,7 +202,7 @@ border: 1px solid #adadad; } -.btn.sub_unsub_button { +.stream-row .btn.sub_unsub_button { display: inline-block; min-width: 140px; float: right; @@ -679,6 +679,21 @@ form#add_new_subscription { display: inline-block; font-size: 1.5em; font-weight: 600; + margin-left: -3px; +} + +#subscription_overlay .stream-header .subscribe-button { + float: right; + margin-top: -5px; +} + +#subscription_overlay .stream-header .subscribe-button.unsubscribed { + color: #5bb792; + border-color: #addcc9; +} + +#subscription_overlay .stream-header .subscribe-button.unsubscribed:active { + background-color: rgba(91,183,146,0.2); } #subscription_overlay .stream-header .large-icon { diff --git a/static/templates/subscription_settings.handlebars b/static/templates/subscription_settings.handlebars index fa8181f5ce..b598eb390b 100644 --- a/static/templates/subscription_settings.handlebars +++ b/static/templates/subscription_settings.handlebars @@ -12,6 +12,8 @@
{{name}}
+
{{description}}