Expand subscription settings of newly created streams

(imported from commit 6171014fd712b60d83b2a0ac2953d8065c00a585)
This commit is contained in:
Zev Benjamin 2013-01-23 13:43:11 -05:00
parent 2e7d411ef8
commit e03fe9e3f1
1 changed files with 12 additions and 2 deletions

View File

@ -104,20 +104,30 @@ function button_for_sub(sub) {
return $("#subscription_" + id + " .sub_unsub_button"); 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) { function mark_subscribed(stream_name) {
var lstream_name = stream_name.toLowerCase(); var lstream_name = stream_name.toLowerCase();
var sub = stream_info[lstream_name]; var sub = stream_info[lstream_name];
if (sub === undefined) { if (sub === undefined) {
sub = create_sub(stream_name, {}); sub = create_sub(stream_name, {});
$('#create_stream_row').after(templates.subscription({subscriptions: [sub]})); add_sub_to_table(sub);
} else if (! sub.subscribed) { } else if (! sub.subscribed) {
sub.subscribed = true; sub.subscribed = true;
var button = button_for_sub(sub); var button = button_for_sub(sub);
if (button.length !== 0) { if (button.length !== 0) {
button.text("Unsubscribe").removeClass("btn-primary"); button.text("Unsubscribe").removeClass("btn-primary");
} else { } else {
$('#create_stream_row').after(templates.subscription({subscriptions: [sub]})); add_sub_to_table(sub);
} }
} else { } else {
// Already subscribed // Already subscribed