mirror of https://github.com/zulip/zulip.git
refactor: Split out functions for opening edit panel.
While they can share some code, opening the edit panel for a stream and clearing the panel are pretty different actions, so we simplify the API for each thing. You no longer have to pass in booleans, and for the clear case, you don't have to pass in a bogus node that just gets ignored.
This commit is contained in:
parent
43f25eb4a5
commit
bea328b8b6
|
@ -78,18 +78,22 @@ exports.show_sub_settings = function (sub) {
|
||||||
$settings.find(".regular_subscription_settings").addClass('in');
|
$settings.find(".regular_subscription_settings").addClass('in');
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.show_stream_row = function (node, show_settings) {
|
function clear_edit_panel() {
|
||||||
$(".display-type #add_new_stream_title").hide();
|
$(".display-type #add_new_stream_title").hide();
|
||||||
$(".display-type #stream_settings_title, .right .settings").show();
|
$(".display-type #stream_settings_title, .right .settings").show();
|
||||||
$(".stream-row.active").removeClass("active");
|
$(".stream-row.active").removeClass("active");
|
||||||
if (show_settings) {
|
}
|
||||||
subs.show_subs_pane.settings();
|
|
||||||
|
|
||||||
$(node).addClass("active");
|
exports.open_edit_panel_for_row = function (stream_row) {
|
||||||
stream_edit.show_settings_for(node);
|
clear_edit_panel();
|
||||||
} else {
|
subs.show_subs_pane.settings();
|
||||||
subs.show_subs_pane.nothing_selected();
|
$(stream_row).addClass("active");
|
||||||
}
|
stream_edit.show_settings_for(stream_row);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.open_edit_panel_empty = function () {
|
||||||
|
clear_edit_panel();
|
||||||
|
subs.show_subs_pane.nothing_selected();
|
||||||
};
|
};
|
||||||
|
|
||||||
function format_member_list_elem(email) {
|
function format_member_list_elem(email) {
|
||||||
|
@ -636,7 +640,7 @@ exports.initialize = function () {
|
||||||
var regular_sub_settings = sub_settings.find(".regular_subscription_settings");
|
var regular_sub_settings = sub_settings.find(".regular_subscription_settings");
|
||||||
if (!sub.subscribed) {
|
if (!sub.subscribed) {
|
||||||
regular_sub_settings.addClass("in");
|
regular_sub_settings.addClass("in");
|
||||||
exports.show_stream_row(stream_row, true);
|
exports.open_edit_panel_for_row(stream_row);
|
||||||
} else {
|
} else {
|
||||||
regular_sub_settings.removeClass("in");
|
regular_sub_settings.removeClass("in");
|
||||||
}
|
}
|
||||||
|
@ -679,7 +683,7 @@ exports.initialize = function () {
|
||||||
|
|
||||||
$("#subscriptions_table").on("click", ".stream-row", function (e) {
|
$("#subscriptions_table").on("click", ".stream-row", function (e) {
|
||||||
if ($(e.target).closest(".check, .subscription_settings").length === 0) {
|
if ($(e.target).closest(".check, .subscription_settings").length === 0) {
|
||||||
exports.show_stream_row(this, true);
|
exports.open_edit_panel_for_row(this);
|
||||||
var stream_id = $(this).attr("data-stream-id");
|
var stream_id = $(this).attr("data-stream-id");
|
||||||
var sub = stream_data.get_sub_by_id(stream_id);
|
var sub = stream_data.get_sub_by_id(stream_id);
|
||||||
setup_subscriptions_stream_hash(sub);
|
setup_subscriptions_stream_hash(sub);
|
||||||
|
|
|
@ -881,7 +881,7 @@ exports.initialize = function () {
|
||||||
|
|
||||||
$("#subscriptions_table").on("click", sel, function (e) {
|
$("#subscriptions_table").on("click", sel, function (e) {
|
||||||
if ($(e.target).is(sel)) {
|
if ($(e.target).is(sel)) {
|
||||||
stream_edit.show_stream_row(this, false);
|
stream_edit.open_edit_panel_empty();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}());
|
}());
|
||||||
|
|
Loading…
Reference in New Issue