subscriptions: stylize invite_only streams with a lock icon.

(imported from commit afa99dbc61ba66a6e9662780ef8daaa3d4f9e543)
This commit is contained in:
Jessica McKellar 2013-01-31 15:13:28 -05:00
parent dc66d6290b
commit 4d170530cc
2 changed files with 30 additions and 0 deletions

View File

@ -6,6 +6,7 @@
<div class="subscription_table_elem subscription_header" data-toggle="collapse" data-target="#subscription_settings_{{id}}">
<span class="color_swatch fade {{#subscribed}}in{{/subscribed}}" style="background-color: {{color}}"></span>
<span class="subscription_name">{{name}}</span>
<i class="icon-lock invisible"></i>
<button class="btn sub_unsub_button {{^subscribed}}btn-primary{{/subscribed}}"
type="button" name="subscription">
{{#subscribed}}

View File

@ -224,6 +224,22 @@ function fetch_colors() {
});
}
function get_disjoint_list(list1, list2) {
return $.grep(list1, function (elt) {
return $.inArray(elt, list2) === -1;
});
}
function add_lock_to_rows(subscription_rows) {
subscription_rows.parent().children(".icon-lock").removeClass("invisible");
}
function style_invite_only_streams(invite_only_streams) {
add_lock_to_rows($(".subscription_name").filter(function () {
return $.inArray($(this).text(), invite_only_streams) === -1;
}));
}
exports.setup_page = function () {
util.make_loading_indicator($('#subs_page_loading_indicator'));
@ -259,6 +275,8 @@ exports.setup_page = function () {
$('#subscriptions_table tr:gt(0)').remove();
$('#subscriptions_table').append(templates.subscription({subscriptions: sub_rows}));
style_invite_only_streams(get_disjoint_list(all_streams, our_subs));
util.destroy_loading_indicator($('#subs_page_loading_indicator'));
$('#create_stream_name').focus().select();
}
@ -403,6 +421,11 @@ function ajaxSubscribeForCreation(stream, principals, invite_only) {
$('#stream-creation').modal("hide");
mark_subscribed(stream);
if (invite_only) {
add_lock_to_rows($(".subscription_name").filter(function () {
return $(this).text() === stream;
}));
}
},
error: function (xhr) {
ui.report_error("Error creating stream", xhr, $("#subscriptions-status"));
@ -445,6 +468,12 @@ $(function () {
$("#add_new_subscription").on("submit", function (e) {
e.preventDefault();
if (!should_list_all_streams()) {
ajaxSubscribe($("#create_stream_name").val());
return;
}
var stream = $.trim($("#create_stream_name").val());
var stream_status = compose.check_stream_existence(stream)[0];
if (stream_status === "does-not-exist") {