From e03fe9e3f1f783633dfc87865534324e6c2b5064 Mon Sep 17 00:00:00 2001 From: Zev Benjamin Date: Wed, 23 Jan 2013 13:43:11 -0500 Subject: [PATCH] Expand subscription settings of newly created streams (imported from commit 6171014fd712b60d83b2a0ac2953d8065c00a585) --- zephyr/static/js/subs.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/zephyr/static/js/subs.js b/zephyr/static/js/subs.js index 249ba03251..c2fda21bda 100644 --- a/zephyr/static/js/subs.js +++ b/zephyr/static/js/subs.js @@ -104,20 +104,30 @@ function button_for_sub(sub) { return $("#subscription_" + id + " .sub_unsub_button"); } +function settings_for_sub(sub) { + var id = parseInt(sub.id, 10); + return $("#subscription_settings_" + id); +} + +function add_sub_to_table(sub) { + $('#create_stream_row').after(templates.subscription({subscriptions: [sub]})); + settings_for_sub(sub).collapse('show'); +} + function mark_subscribed(stream_name) { var lstream_name = stream_name.toLowerCase(); var sub = stream_info[lstream_name]; if (sub === undefined) { sub = create_sub(stream_name, {}); - $('#create_stream_row').after(templates.subscription({subscriptions: [sub]})); + add_sub_to_table(sub); } else if (! sub.subscribed) { sub.subscribed = true; var button = button_for_sub(sub); if (button.length !== 0) { button.text("Unsubscribe").removeClass("btn-primary"); } else { - $('#create_stream_row').after(templates.subscription({subscriptions: [sub]})); + add_sub_to_table(sub); } } else { // Already subscribed