mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 17:07:07 +00:00
js: Indent case clauses in switch statements.
Prettier would do this anyway, but it’s separated out for a more reviewable diff. Generated by ESLint. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
f3726db89a
commit
6924d501bc
@@ -38,6 +38,7 @@
|
|||||||
"indent": ["error", 4, {
|
"indent": ["error", 4, {
|
||||||
"ArrayExpression": "first",
|
"ArrayExpression": "first",
|
||||||
"ObjectExpression": "first",
|
"ObjectExpression": "first",
|
||||||
|
"SwitchCase": 1,
|
||||||
"CallExpression": {"arguments": "first"},
|
"CallExpression": {"arguments": "first"},
|
||||||
"FunctionExpression": {"parameters": "first"},
|
"FunctionExpression": {"parameters": "first"},
|
||||||
"FunctionDeclaration": {"parameters": "first"}
|
"FunctionDeclaration": {"parameters": "first"}
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"rules": {
|
|
||||||
"indent": ["error", 4, {
|
|
||||||
"ArrayExpression": "first",
|
|
||||||
"ObjectExpression": "first",
|
|
||||||
"SwitchCase": 0,
|
|
||||||
"CallExpression": {"arguments": "first"},
|
|
||||||
"FunctionExpression": {"parameters": "first"},
|
|
||||||
"FunctionDeclaration": {"parameters": "first"}
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -26,15 +26,15 @@ exports.get_user_circle_class = function (user_id) {
|
|||||||
const status = exports.buddy_status(user_id);
|
const status = exports.buddy_status(user_id);
|
||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case "active":
|
case "active":
|
||||||
return "user_circle_green";
|
return "user_circle_green";
|
||||||
case "idle":
|
case "idle":
|
||||||
return "user_circle_orange";
|
return "user_circle_orange";
|
||||||
case "away_them":
|
case "away_them":
|
||||||
case "away_me":
|
case "away_me":
|
||||||
return "user_circle_empty_line";
|
return "user_circle_empty_line";
|
||||||
default:
|
default:
|
||||||
return "user_circle_empty";
|
return "user_circle_empty";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -42,15 +42,15 @@ exports.status_description = function (user_id) {
|
|||||||
const status = exports.buddy_status(user_id);
|
const status = exports.buddy_status(user_id);
|
||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case "active":
|
case "active":
|
||||||
return i18n.t("Active");
|
return i18n.t("Active");
|
||||||
case "idle":
|
case "idle":
|
||||||
return i18n.t("Idle");
|
return i18n.t("Idle");
|
||||||
case "away_them":
|
case "away_them":
|
||||||
case "away_me":
|
case "away_me":
|
||||||
return i18n.t("Unavailable");
|
return i18n.t("Unavailable");
|
||||||
default:
|
default:
|
||||||
return i18n.t("Offline");
|
return i18n.t("Offline");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -63,14 +63,14 @@ exports.level = function (user_id) {
|
|||||||
const status = exports.buddy_status(user_id);
|
const status = exports.buddy_status(user_id);
|
||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case "active":
|
case "active":
|
||||||
return 1;
|
return 1;
|
||||||
case "idle":
|
case "idle":
|
||||||
return 2;
|
return 2;
|
||||||
case "away_them":
|
case "away_them":
|
||||||
return 3;
|
return 3;
|
||||||
default:
|
default:
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -543,21 +543,21 @@ exports.validation_error = function (error_type, stream_name) {
|
|||||||
context.stream_name = Handlebars.Utils.escapeExpression(stream_name);
|
context.stream_name = Handlebars.Utils.escapeExpression(stream_name);
|
||||||
|
|
||||||
switch (error_type) {
|
switch (error_type) {
|
||||||
case "does-not-exist":
|
case "does-not-exist":
|
||||||
response = i18n.t("<p>The stream <b>__stream_name__</b> does not exist.</p><p>Manage your subscriptions <a href='#streams/all'>on your Streams page</a>.</p>", context);
|
response = i18n.t("<p>The stream <b>__stream_name__</b> does not exist.</p><p>Manage your subscriptions <a href='#streams/all'>on your Streams page</a>.</p>", context);
|
||||||
compose_error(response, $("#stream_message_recipient_stream"));
|
compose_error(response, $("#stream_message_recipient_stream"));
|
||||||
return false;
|
return false;
|
||||||
case "error":
|
case "error":
|
||||||
compose_error(i18n.t("Error checking subscription"),
|
compose_error(i18n.t("Error checking subscription"),
|
||||||
$("#stream_message_recipient_stream"));
|
$("#stream_message_recipient_stream"));
|
||||||
return false;
|
return false;
|
||||||
case "not-subscribed": {
|
case "not-subscribed": {
|
||||||
const sub = stream_data.get_sub(stream_name);
|
const sub = stream_data.get_sub(stream_name);
|
||||||
const new_row = render_compose_not_subscribed({
|
const new_row = render_compose_not_subscribed({
|
||||||
should_display_sub_button: sub.should_display_subscription_button});
|
should_display_sub_button: sub.should_display_subscription_button});
|
||||||
compose_not_subscribed_error(new_row, $("#stream_message_recipient_stream"));
|
compose_not_subscribed_error(new_row, $("#stream_message_recipient_stream"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -291,43 +291,43 @@ exports.tokenize_compose_str = function (s) {
|
|||||||
while (i > min_i) {
|
while (i > min_i) {
|
||||||
i -= 1;
|
i -= 1;
|
||||||
switch (s[i]) {
|
switch (s[i]) {
|
||||||
case "`":
|
case "`":
|
||||||
case "~":
|
case "~":
|
||||||
// Code block must start on a new line
|
// Code block must start on a new line
|
||||||
if (i === 2) {
|
if (i === 2) {
|
||||||
return s;
|
return s;
|
||||||
} else if (i > 2 && s[i - 3] === "\n") {
|
} else if (i > 2 && s[i - 3] === "\n") {
|
||||||
return s.slice(i - 2);
|
return s.slice(i - 2);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "/":
|
case "/":
|
||||||
if (i === 0) {
|
if (i === 0) {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "#":
|
case "#":
|
||||||
case "@":
|
case "@":
|
||||||
case ":":
|
case ":":
|
||||||
case "_":
|
case "_":
|
||||||
if (i === 0) {
|
if (i === 0) {
|
||||||
return s;
|
return s;
|
||||||
} else if (/[\s(){}[\]]/.test(s[i - 1])) {
|
} else if (/[\s(){}[\]]/.test(s[i - 1])) {
|
||||||
return s.slice(i);
|
return s.slice(i);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ">":
|
case ">":
|
||||||
// topic_jump
|
// topic_jump
|
||||||
//
|
//
|
||||||
// If you hit `>` immediately after completing the typeahead for mentioning a stream,
|
// If you hit `>` immediately after completing the typeahead for mentioning a stream,
|
||||||
// this will reposition the user from. If | is the cursor, implements:
|
// this will reposition the user from. If | is the cursor, implements:
|
||||||
//
|
//
|
||||||
// `#**stream name** >|` => `#**stream name>|`.
|
// `#**stream name** >|` => `#**stream name>|`.
|
||||||
if (s.substring(i - 2, i) === "**" || s.substring(i - 3, i) === "** ") {
|
if (s.substring(i - 2, i) === "**" || s.substring(i - 3, i) === "** ") {
|
||||||
// return any string as long as its not ''.
|
// return any string as long as its not ''.
|
||||||
return ">topic_jump";
|
return ">topic_jump";
|
||||||
}
|
}
|
||||||
// maybe topic_list; let's let the stream_topic_regex decide later.
|
// maybe topic_list; let's let the stream_topic_regex decide later.
|
||||||
return ">topic_list";
|
return ">topic_list";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -916,44 +916,44 @@ exports.content_typeahead_selected = function (item, event) {
|
|||||||
|
|
||||||
exports.compose_content_matcher = function (completing, token) {
|
exports.compose_content_matcher = function (completing, token) {
|
||||||
switch (completing) {
|
switch (completing) {
|
||||||
case "emoji":
|
case "emoji":
|
||||||
return typeahead.get_emoji_matcher(token);
|
return typeahead.get_emoji_matcher(token);
|
||||||
case "slash":
|
case "slash":
|
||||||
return get_slash_matcher(token);
|
return get_slash_matcher(token);
|
||||||
case "stream":
|
case "stream":
|
||||||
return get_stream_or_user_group_matcher(token);
|
return get_stream_or_user_group_matcher(token);
|
||||||
case "syntax":
|
case "syntax":
|
||||||
return get_language_matcher(token);
|
return get_language_matcher(token);
|
||||||
case "topic_list":
|
case "topic_list":
|
||||||
return get_topic_matcher(token);
|
return get_topic_matcher(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
return function () {
|
return function () {
|
||||||
switch (completing) {
|
switch (completing) {
|
||||||
case "topic_jump":
|
case "topic_jump":
|
||||||
case "time_jump":
|
case "time_jump":
|
||||||
// these don't actually have a typeahead popover, so we return quickly here.
|
// these don't actually have a typeahead popover, so we return quickly here.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.sort_results = function (completing, matches, token) {
|
exports.sort_results = function (completing, matches, token) {
|
||||||
switch (completing) {
|
switch (completing) {
|
||||||
case "emoji":
|
case "emoji":
|
||||||
return typeahead.sort_emojis(matches, token);
|
return typeahead.sort_emojis(matches, token);
|
||||||
case "slash":
|
case "slash":
|
||||||
return typeahead_helper.sort_slash_commands(matches, token);
|
return typeahead_helper.sort_slash_commands(matches, token);
|
||||||
case "stream":
|
case "stream":
|
||||||
return typeahead_helper.sort_streams(matches, token);
|
return typeahead_helper.sort_streams(matches, token);
|
||||||
case "syntax":
|
case "syntax":
|
||||||
return typeahead_helper.sort_languages(matches, token);
|
return typeahead_helper.sort_languages(matches, token);
|
||||||
case "topic_jump":
|
case "topic_jump":
|
||||||
case "time_jump":
|
case "time_jump":
|
||||||
// topic_jump doesn't actually have a typeahead popover, so we return quickly here.
|
// topic_jump doesn't actually have a typeahead popover, so we return quickly here.
|
||||||
return matches;
|
return matches;
|
||||||
case "topic_list":
|
case "topic_list":
|
||||||
return typeahead_helper.sorter(token, matches, (x) => x);
|
return typeahead_helper.sorter(token, matches, (x) => x);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -977,21 +977,21 @@ exports.compose_trigger_selection = function (event) {
|
|||||||
function get_header_text() {
|
function get_header_text() {
|
||||||
let tip_text = "";
|
let tip_text = "";
|
||||||
switch (this.completing) {
|
switch (this.completing) {
|
||||||
case "stream":
|
case "stream":
|
||||||
tip_text = i18n.t("Press > for list of topics");
|
tip_text = i18n.t("Press > for list of topics");
|
||||||
break;
|
|
||||||
case "silent_mention":
|
|
||||||
tip_text = i18n.t("User will not be notified");
|
|
||||||
break;
|
|
||||||
case "syntax":
|
|
||||||
if (page_params.realm_default_code_block_language !== null) {
|
|
||||||
tip_text = i18n.t("Default is __language__. Use 'text' to disable highlighting.",
|
|
||||||
{language: page_params.realm_default_code_block_language});
|
|
||||||
break;
|
break;
|
||||||
}
|
case "silent_mention":
|
||||||
return false;
|
tip_text = i18n.t("User will not be notified");
|
||||||
default:
|
break;
|
||||||
return false;
|
case "syntax":
|
||||||
|
if (page_params.realm_default_code_block_language !== null) {
|
||||||
|
tip_text = i18n.t("Default is __language__. Use 'text' to disable highlighting.",
|
||||||
|
{language: page_params.realm_default_code_block_language});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return "<em>" + tip_text + "</em>";
|
return "<em>" + tip_text + "</em>";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -472,18 +472,18 @@ exports.navigate = function (event_name, e) {
|
|||||||
} else if (!is_filter_focused) {
|
} else if (!is_filter_focused) {
|
||||||
let next_coord = {};
|
let next_coord = {};
|
||||||
switch (event_name) {
|
switch (event_name) {
|
||||||
case "down_arrow":
|
case "down_arrow":
|
||||||
next_coord = get_next_emoji_coordinates(6);
|
next_coord = get_next_emoji_coordinates(6);
|
||||||
break;
|
break;
|
||||||
case "up_arrow":
|
case "up_arrow":
|
||||||
next_coord = get_next_emoji_coordinates(-6);
|
next_coord = get_next_emoji_coordinates(-6);
|
||||||
break;
|
break;
|
||||||
case "left_arrow":
|
case "left_arrow":
|
||||||
next_coord = get_next_emoji_coordinates(-1);
|
next_coord = get_next_emoji_coordinates(-1);
|
||||||
break;
|
break;
|
||||||
case "right_arrow":
|
case "right_arrow":
|
||||||
next_coord = get_next_emoji_coordinates(1);
|
next_coord = get_next_emoji_coordinates(1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return maybe_change_focused_emoji($emoji_map, next_coord.section, next_coord.index);
|
return maybe_change_focused_emoji($emoji_map, next_coord.section, next_coord.index);
|
||||||
|
|||||||
@@ -46,112 +46,112 @@ function message_in_home(message) {
|
|||||||
|
|
||||||
function message_matches_search_term(message, operator, operand) {
|
function message_matches_search_term(message, operator, operand) {
|
||||||
switch (operator) {
|
switch (operator) {
|
||||||
case "has":
|
case "has":
|
||||||
if (operand === "image") {
|
if (operand === "image") {
|
||||||
return message_util.message_has_image(message);
|
return message_util.message_has_image(message);
|
||||||
} else if (operand === "link") {
|
} else if (operand === "link") {
|
||||||
return message_util.message_has_link(message);
|
return message_util.message_has_link(message);
|
||||||
} else if (operand === "attachment") {
|
} else if (operand === "attachment") {
|
||||||
return message_util.message_has_attachment(message);
|
return message_util.message_has_attachment(message);
|
||||||
}
|
}
|
||||||
return false; // has:something_else returns false
|
return false; // has:something_else returns false
|
||||||
case "is":
|
case "is":
|
||||||
if (operand === "private") {
|
if (operand === "private") {
|
||||||
return message.type === "private";
|
return message.type === "private";
|
||||||
} else if (operand === "starred") {
|
} else if (operand === "starred") {
|
||||||
return message.starred;
|
return message.starred;
|
||||||
} else if (operand === "mentioned") {
|
} else if (operand === "mentioned") {
|
||||||
return message.mentioned;
|
return message.mentioned;
|
||||||
} else if (operand === "alerted") {
|
} else if (operand === "alerted") {
|
||||||
return message.alerted;
|
return message.alerted;
|
||||||
} else if (operand === "unread") {
|
} else if (operand === "unread") {
|
||||||
return unread.message_unread(message);
|
return unread.message_unread(message);
|
||||||
}
|
}
|
||||||
return true; // is:whatever returns true
|
return true; // is:whatever returns true
|
||||||
|
|
||||||
case "in":
|
case "in":
|
||||||
if (operand === "home") {
|
if (operand === "home") {
|
||||||
return message_in_home(message);
|
return message_in_home(message);
|
||||||
} else if (operand === "all") {
|
} else if (operand === "all") {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return true; // in:whatever returns true
|
return true; // in:whatever returns true
|
||||||
|
|
||||||
case "near":
|
case "near":
|
||||||
// this is all handled server side
|
// this is all handled server side
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case "id":
|
case "id":
|
||||||
return message.id.toString() === operand;
|
return message.id.toString() === operand;
|
||||||
|
|
||||||
case "stream": {
|
case "stream": {
|
||||||
if (message.type !== "stream") {
|
if (message.type !== "stream") {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
operand = operand.toLowerCase();
|
||||||
|
if (page_params.realm_is_zephyr_mirror_realm) {
|
||||||
|
return zephyr_stream_name_match(message, operand);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to match by stream_id if have a valid sub for
|
||||||
|
// the operand.
|
||||||
|
const stream_id = stream_data.get_stream_id(operand);
|
||||||
|
if (stream_id) {
|
||||||
|
return message.stream_id === stream_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We need this fallback logic in case we have a message
|
||||||
|
// loaded for a stream that we are no longer
|
||||||
|
// subscribed to (or that was deleted).
|
||||||
|
return message.stream.toLowerCase() === operand;
|
||||||
}
|
}
|
||||||
|
|
||||||
operand = operand.toLowerCase();
|
case "topic":
|
||||||
if (page_params.realm_is_zephyr_mirror_realm) {
|
if (message.type !== "stream") {
|
||||||
return zephyr_stream_name_match(message, operand);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to match by stream_id if have a valid sub for
|
operand = operand.toLowerCase();
|
||||||
// the operand.
|
if (page_params.realm_is_zephyr_mirror_realm) {
|
||||||
const stream_id = stream_data.get_stream_id(operand);
|
return zephyr_topic_name_match(message, operand);
|
||||||
if (stream_id) {
|
}
|
||||||
return message.stream_id === stream_id;
|
return message.topic.toLowerCase() === operand;
|
||||||
}
|
|
||||||
|
|
||||||
// We need this fallback logic in case we have a message
|
|
||||||
// loaded for a stream that we are no longer
|
|
||||||
// subscribed to (or that was deleted).
|
|
||||||
return message.stream.toLowerCase() === operand;
|
|
||||||
}
|
|
||||||
|
|
||||||
case "topic":
|
|
||||||
if (message.type !== "stream") {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
operand = operand.toLowerCase();
|
|
||||||
if (page_params.realm_is_zephyr_mirror_realm) {
|
|
||||||
return zephyr_topic_name_match(message, operand);
|
|
||||||
}
|
|
||||||
return message.topic.toLowerCase() === operand;
|
|
||||||
|
|
||||||
|
|
||||||
case "sender":
|
case "sender":
|
||||||
return people.id_matches_email_operand(message.sender_id, operand);
|
return people.id_matches_email_operand(message.sender_id, operand);
|
||||||
|
|
||||||
case "group-pm-with": {
|
case "group-pm-with": {
|
||||||
const operand_ids = people.pm_with_operand_ids(operand);
|
const operand_ids = people.pm_with_operand_ids(operand);
|
||||||
if (!operand_ids) {
|
if (!operand_ids) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const user_ids = people.group_pm_with_user_ids(message);
|
const user_ids = people.group_pm_with_user_ids(message);
|
||||||
if (!user_ids) {
|
if (!user_ids) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return user_ids.includes(operand_ids[0]);
|
return user_ids.includes(operand_ids[0]);
|
||||||
// We should also check if the current user is in the recipient list (user_ids) of the
|
// We should also check if the current user is in the recipient list (user_ids) of the
|
||||||
// message, but it is implicit by the fact that the current user has access to the message.
|
// message, but it is implicit by the fact that the current user has access to the message.
|
||||||
}
|
}
|
||||||
|
|
||||||
case "pm-with": {
|
case "pm-with": {
|
||||||
// TODO: use user_ids, not emails here
|
// TODO: use user_ids, not emails here
|
||||||
if (message.type !== "private") {
|
if (message.type !== "private") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const operand_ids = people.pm_with_operand_ids(operand);
|
const operand_ids = people.pm_with_operand_ids(operand);
|
||||||
if (!operand_ids) {
|
if (!operand_ids) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const user_ids = people.pm_with_user_ids(message);
|
const user_ids = people.pm_with_user_ids(message);
|
||||||
if (!user_ids) {
|
if (!user_ids) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _.isEqual(operand_ids, user_ids);
|
return _.isEqual(operand_ids, user_ids);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true; // unknown operators return true (effectively ignored)
|
return true; // unknown operators return true (effectively ignored)
|
||||||
@@ -196,36 +196,36 @@ Filter.canonicalize_term = function (opts) {
|
|||||||
operator = Filter.canonicalize_operator(operator);
|
operator = Filter.canonicalize_operator(operator);
|
||||||
|
|
||||||
switch (operator) {
|
switch (operator) {
|
||||||
case "has":
|
case "has":
|
||||||
// images -> image, etc.
|
// images -> image, etc.
|
||||||
operand = operand.replace(/s$/, "");
|
operand = operand.replace(/s$/, "");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "stream":
|
case "stream":
|
||||||
operand = stream_data.get_name(operand);
|
operand = stream_data.get_name(operand);
|
||||||
break;
|
break;
|
||||||
case "topic":
|
case "topic":
|
||||||
break;
|
break;
|
||||||
case "sender":
|
case "sender":
|
||||||
case "pm-with":
|
case "pm-with":
|
||||||
operand = operand.toString().toLowerCase();
|
operand = operand.toString().toLowerCase();
|
||||||
if (operand === "me") {
|
if (operand === "me") {
|
||||||
operand = people.my_current_email();
|
operand = people.my_current_email();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "group-pm-with":
|
case "group-pm-with":
|
||||||
operand = operand.toString().toLowerCase();
|
operand = operand.toString().toLowerCase();
|
||||||
break;
|
break;
|
||||||
case "search":
|
case "search":
|
||||||
// The mac app automatically substitutes regular quotes with curly
|
// The mac app automatically substitutes regular quotes with curly
|
||||||
// quotes when typing in the search bar. Curly quotes don't trigger our
|
// quotes when typing in the search bar. Curly quotes don't trigger our
|
||||||
// phrase search behavior, however. So, we replace all instances of
|
// phrase search behavior, however. So, we replace all instances of
|
||||||
// curly quotes with regular quotes when doing a search. This is
|
// curly quotes with regular quotes when doing a search. This is
|
||||||
// unlikely to cause any problems and is probably what the user wants.
|
// unlikely to cause any problems and is probably what the user wants.
|
||||||
operand = operand.toString().toLowerCase().replace(/[\u201c\u201d]/g, '"');
|
operand = operand.toString().toLowerCase().replace(/[\u201c\u201d]/g, '"');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
operand = operand.toString().toLowerCase();
|
operand = operand.toString().toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
// We may want to consider allowing mixed-case operators at some point
|
// We may want to consider allowing mixed-case operators at some point
|
||||||
@@ -504,27 +504,27 @@ Filter.prototype = {
|
|||||||
|
|
||||||
if (term_types[1] === "search") {
|
if (term_types[1] === "search") {
|
||||||
switch (term_types[0]) {
|
switch (term_types[0]) {
|
||||||
case "stream":
|
case "stream":
|
||||||
// if stream does not exist, redirect to All
|
// if stream does not exist, redirect to All
|
||||||
if (!this._sub) {
|
if (!this._sub) {
|
||||||
return "#";
|
return "#";
|
||||||
}
|
}
|
||||||
return "/#narrow/stream/" + stream_data.name_to_slug(this.operands("stream")[0]);
|
return "/#narrow/stream/" + stream_data.name_to_slug(this.operands("stream")[0]);
|
||||||
case "is-private":
|
case "is-private":
|
||||||
return "/#narrow/is/private";
|
return "/#narrow/is/private";
|
||||||
case "is-starred":
|
case "is-starred":
|
||||||
return "/#narrow/is/starred";
|
return "/#narrow/is/starred";
|
||||||
case "is-mentioned":
|
case "is-mentioned":
|
||||||
return "/#narrow/is/mentioned";
|
return "/#narrow/is/mentioned";
|
||||||
case "streams-public":
|
case "streams-public":
|
||||||
return "/#narrow/streams/public";
|
return "/#narrow/streams/public";
|
||||||
case "pm-with":
|
case "pm-with":
|
||||||
// join is used to transform the array to a comma separated string
|
// join is used to transform the array to a comma separated string
|
||||||
return "/#narrow/pm-with/" + people.emails_to_slug(this.operands("pm-with").join());
|
return "/#narrow/pm-with/" + people.emails_to_slug(this.operands("pm-with").join());
|
||||||
// TODO: It is ambiguous how we want to handle the 'sender' case,
|
// TODO: It is ambiguous how we want to handle the 'sender' case,
|
||||||
// we may remove it in the future based on design decisions
|
// we may remove it in the future based on design decisions
|
||||||
case "sender":
|
case "sender":
|
||||||
return "/#narrow/sender/" + people.emails_to_slug(this.operands("sender")[0]);
|
return "/#narrow/sender/" + people.emails_to_slug(this.operands("sender")[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -535,28 +535,28 @@ Filter.prototype = {
|
|||||||
// We have special icons for the simple narrows available for the via sidebars.
|
// We have special icons for the simple narrows available for the via sidebars.
|
||||||
const term_types = this.sorted_term_types();
|
const term_types = this.sorted_term_types();
|
||||||
switch (term_types[0]) {
|
switch (term_types[0]) {
|
||||||
case "in-home":
|
case "in-home":
|
||||||
case "in-all":
|
case "in-all":
|
||||||
return "home";
|
return "home";
|
||||||
case "stream":
|
case "stream":
|
||||||
if (!this._sub) {
|
if (!this._sub) {
|
||||||
return "question-circle-o";
|
return "question-circle-o";
|
||||||
}
|
}
|
||||||
if (this._sub.invite_only) {
|
if (this._sub.invite_only) {
|
||||||
return "lock";
|
return "lock";
|
||||||
}
|
}
|
||||||
if (this._sub.is_web_public) {
|
if (this._sub.is_web_public) {
|
||||||
return "globe";
|
return "globe";
|
||||||
}
|
}
|
||||||
return "hashtag";
|
return "hashtag";
|
||||||
case "is-private":
|
case "is-private":
|
||||||
return "envelope";
|
return "envelope";
|
||||||
case "is-starred":
|
case "is-starred":
|
||||||
return "star";
|
return "star";
|
||||||
case "is-mentioned":
|
case "is-mentioned":
|
||||||
return "at";
|
return "at";
|
||||||
case "pm-with":
|
case "pm-with":
|
||||||
return "envelope";
|
return "envelope";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -572,37 +572,37 @@ Filter.prototype = {
|
|||||||
}
|
}
|
||||||
if (term_types.length === 1 || term_types.length === 2 && term_types[1] === "search") {
|
if (term_types.length === 1 || term_types.length === 2 && term_types[1] === "search") {
|
||||||
switch (term_types[0]) {
|
switch (term_types[0]) {
|
||||||
case "in-home":
|
case "in-home":
|
||||||
return i18n.t("All messages");
|
return i18n.t("All messages");
|
||||||
case "in-all":
|
case "in-all":
|
||||||
return i18n.t("All messages including muted streams");
|
return i18n.t("All messages including muted streams");
|
||||||
case "streams-public":
|
case "streams-public":
|
||||||
return i18n.t("Public stream messages in organization");
|
return i18n.t("Public stream messages in organization");
|
||||||
case "stream":
|
case "stream":
|
||||||
if (!this._sub) {
|
if (!this._sub) {
|
||||||
return i18n.t("Unknown stream");
|
return i18n.t("Unknown stream");
|
||||||
}
|
|
||||||
return this._sub.name;
|
|
||||||
case "is-starred":
|
|
||||||
return i18n.t("Starred messages");
|
|
||||||
case "is-mentioned":
|
|
||||||
return i18n.t("Mentions");
|
|
||||||
case "is-private":
|
|
||||||
return i18n.t("Private messages");
|
|
||||||
case "pm-with": {
|
|
||||||
const emails = this.operands("pm-with")[0].split(",");
|
|
||||||
const names = emails.map((email) => {
|
|
||||||
if (!people.get_by_email(email)) {
|
|
||||||
return email;
|
|
||||||
}
|
}
|
||||||
return people.get_by_email(email).full_name;
|
return this._sub.name;
|
||||||
});
|
case "is-starred":
|
||||||
|
return i18n.t("Starred messages");
|
||||||
|
case "is-mentioned":
|
||||||
|
return i18n.t("Mentions");
|
||||||
|
case "is-private":
|
||||||
|
return i18n.t("Private messages");
|
||||||
|
case "pm-with": {
|
||||||
|
const emails = this.operands("pm-with")[0].split(",");
|
||||||
|
const names = emails.map((email) => {
|
||||||
|
if (!people.get_by_email(email)) {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
return people.get_by_email(email).full_name;
|
||||||
|
});
|
||||||
|
|
||||||
// We use join to handle the addition of a comma and space after every name
|
// We use join to handle the addition of a comma and space after every name
|
||||||
// and also to ensure that we return a string and not an array so that we
|
// and also to ensure that we return a string and not an array so that we
|
||||||
// can have the same return type as other cases.
|
// can have the same return type as other cases.
|
||||||
return names.join(", ");
|
return names.join(", ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -743,15 +743,15 @@ Filter.prototype = {
|
|||||||
update_email: function (user_id, new_email) {
|
update_email: function (user_id, new_email) {
|
||||||
for (const term of this._operators) {
|
for (const term of this._operators) {
|
||||||
switch (term.operator) {
|
switch (term.operator) {
|
||||||
case "group-pm-with":
|
case "group-pm-with":
|
||||||
case "pm-with":
|
case "pm-with":
|
||||||
case "sender":
|
case "sender":
|
||||||
case "from":
|
case "from":
|
||||||
term.operand = people.update_email_in_reply_to(
|
term.operand = people.update_email_in_reply_to(
|
||||||
term.operand,
|
term.operand,
|
||||||
user_id,
|
user_id,
|
||||||
new_email,
|
new_email,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -838,38 +838,38 @@ Filter.operator_to_prefix = function (operator, negated) {
|
|||||||
const verb = negated ? "exclude " : "";
|
const verb = negated ? "exclude " : "";
|
||||||
|
|
||||||
switch (operator) {
|
switch (operator) {
|
||||||
case "stream":
|
case "stream":
|
||||||
return verb + "stream";
|
return verb + "stream";
|
||||||
case "streams":
|
case "streams":
|
||||||
return verb + "streams";
|
return verb + "streams";
|
||||||
case "near":
|
case "near":
|
||||||
return verb + "messages around";
|
return verb + "messages around";
|
||||||
|
|
||||||
// Note: We hack around using this in "describe" below.
|
// Note: We hack around using this in "describe" below.
|
||||||
case "has":
|
case "has":
|
||||||
return verb + "messages with one or more";
|
return verb + "messages with one or more";
|
||||||
|
|
||||||
case "id":
|
case "id":
|
||||||
return verb + "message ID";
|
return verb + "message ID";
|
||||||
|
|
||||||
case "topic":
|
case "topic":
|
||||||
return verb + "topic";
|
return verb + "topic";
|
||||||
|
|
||||||
case "sender":
|
case "sender":
|
||||||
return verb + "sent by";
|
return verb + "sent by";
|
||||||
|
|
||||||
case "pm-with":
|
case "pm-with":
|
||||||
return verb + "private messages with";
|
return verb + "private messages with";
|
||||||
|
|
||||||
case "in":
|
case "in":
|
||||||
return verb + "messages in";
|
return verb + "messages in";
|
||||||
|
|
||||||
// Note: We hack around using this in "describe" below.
|
// Note: We hack around using this in "describe" below.
|
||||||
case "is":
|
case "is":
|
||||||
return verb + "messages that are";
|
return verb + "messages that are";
|
||||||
|
|
||||||
case "group-pm-with":
|
case "group-pm-with":
|
||||||
return verb + "group private messages including";
|
return verb + "group private messages including";
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -77,53 +77,53 @@ function do_hashchange_normal(from_reload) {
|
|||||||
// be #ABCD.
|
// be #ABCD.
|
||||||
const hash = window.location.hash.split("/");
|
const hash = window.location.hash.split("/");
|
||||||
switch (hash[0]) {
|
switch (hash[0]) {
|
||||||
case "#narrow": {
|
case "#narrow": {
|
||||||
ui_util.change_tab_to("#home");
|
ui_util.change_tab_to("#home");
|
||||||
const operators = hash_util.parse_narrow(hash);
|
const operators = hash_util.parse_narrow(hash);
|
||||||
if (operators === undefined) {
|
if (operators === undefined) {
|
||||||
// If the narrow URL didn't parse, clear
|
// If the narrow URL didn't parse, clear
|
||||||
// window.location.hash and send them to the home tab
|
// window.location.hash and send them to the home tab
|
||||||
set_hash("");
|
set_hash("");
|
||||||
activate_home_tab();
|
activate_home_tab();
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
const narrow_opts = {
|
|
||||||
change_hash: false, // already set
|
|
||||||
trigger: "hash change",
|
|
||||||
};
|
|
||||||
if (from_reload) {
|
|
||||||
blueslip.debug("We are narrowing as part of a reload.");
|
|
||||||
if (page_params.initial_narrow_pointer !== undefined) {
|
|
||||||
home_msg_list.pre_narrow_offset = page_params.initial_offset;
|
|
||||||
narrow_opts.then_select_id = page_params.initial_narrow_pointer;
|
|
||||||
narrow_opts.then_select_offset = page_params.initial_narrow_offset;
|
|
||||||
}
|
}
|
||||||
|
const narrow_opts = {
|
||||||
|
change_hash: false, // already set
|
||||||
|
trigger: "hash change",
|
||||||
|
};
|
||||||
|
if (from_reload) {
|
||||||
|
blueslip.debug("We are narrowing as part of a reload.");
|
||||||
|
if (page_params.initial_narrow_pointer !== undefined) {
|
||||||
|
home_msg_list.pre_narrow_offset = page_params.initial_offset;
|
||||||
|
narrow_opts.then_select_id = page_params.initial_narrow_pointer;
|
||||||
|
narrow_opts.then_select_offset = page_params.initial_narrow_offset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
narrow.activate(operators, narrow_opts);
|
||||||
|
floating_recipient_bar.update();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
narrow.activate(operators, narrow_opts);
|
case "":
|
||||||
floating_recipient_bar.update();
|
case "#":
|
||||||
return true;
|
activate_home_tab();
|
||||||
}
|
break;
|
||||||
case "":
|
case "#keyboard-shortcuts":
|
||||||
case "#":
|
info_overlay.show("keyboard-shortcuts");
|
||||||
activate_home_tab();
|
break;
|
||||||
break;
|
case "#message-formatting":
|
||||||
case "#keyboard-shortcuts":
|
info_overlay.show("message-formatting");
|
||||||
info_overlay.show("keyboard-shortcuts");
|
break;
|
||||||
break;
|
case "#search-operators":
|
||||||
case "#message-formatting":
|
info_overlay.show("search-operators");
|
||||||
info_overlay.show("message-formatting");
|
break;
|
||||||
break;
|
case "#drafts":
|
||||||
case "#search-operators":
|
case "#invite":
|
||||||
info_overlay.show("search-operators");
|
case "#streams":
|
||||||
break;
|
case "#organization":
|
||||||
case "#drafts":
|
case "#settings":
|
||||||
case "#invite":
|
case "#recent_topics":
|
||||||
case "#streams":
|
blueslip.error("overlay logic skipped for: " + hash);
|
||||||
case "#organization":
|
break;
|
||||||
case "#settings":
|
|
||||||
case "#recent_topics":
|
|
||||||
blueslip.error("overlay logic skipped for: " + hash);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -423,40 +423,40 @@ exports.process_hotkey = function (e, hotkey) {
|
|||||||
|
|
||||||
// This block needs to be before the `tab` handler.
|
// This block needs to be before the `tab` handler.
|
||||||
switch (event_name) {
|
switch (event_name) {
|
||||||
case "up_arrow":
|
case "up_arrow":
|
||||||
case "down_arrow":
|
case "down_arrow":
|
||||||
case "left_arrow":
|
case "left_arrow":
|
||||||
case "right_arrow":
|
case "right_arrow":
|
||||||
case "tab":
|
case "tab":
|
||||||
case "shift_tab":
|
case "shift_tab":
|
||||||
if (overlays.recent_topics_open()) {
|
if (overlays.recent_topics_open()) {
|
||||||
return recent_topics.change_focused_element(e, event_name);
|
return recent_topics.change_focused_element(e, event_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We handle the most complex keys in their own functions.
|
// We handle the most complex keys in their own functions.
|
||||||
switch (event_name) {
|
switch (event_name) {
|
||||||
case "escape":
|
case "escape":
|
||||||
return exports.process_escape_key(e);
|
return exports.process_escape_key(e);
|
||||||
case "enter":
|
case "enter":
|
||||||
return exports.process_enter_key(e);
|
return exports.process_enter_key(e);
|
||||||
case "tab":
|
case "tab":
|
||||||
return exports.process_tab_key();
|
return exports.process_tab_key();
|
||||||
case "shift_tab":
|
case "shift_tab":
|
||||||
return exports.process_shift_tab_key();
|
return exports.process_shift_tab_key();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: break out specific handlers for up_arrow,
|
// TODO: break out specific handlers for up_arrow,
|
||||||
// down_arrow, and backspace
|
// down_arrow, and backspace
|
||||||
switch (event_name) {
|
switch (event_name) {
|
||||||
case "up_arrow":
|
case "up_arrow":
|
||||||
case "down_arrow":
|
case "down_arrow":
|
||||||
case "backspace":
|
case "backspace":
|
||||||
case "delete":
|
case "delete":
|
||||||
if (overlays.drafts_open()) {
|
if (overlays.drafts_open()) {
|
||||||
drafts.drafts_handle_events(e, event_name);
|
drafts.drafts_handle_events(e, event_name);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hotkey.message_view_only && overlays.is_active()) {
|
if (hotkey.message_view_only && overlays.is_active()) {
|
||||||
@@ -626,64 +626,64 @@ exports.process_hotkey = function (e, hotkey) {
|
|||||||
|
|
||||||
// Shortcuts that don't require a message
|
// Shortcuts that don't require a message
|
||||||
switch (event_name) {
|
switch (event_name) {
|
||||||
case "compose": // 'c': compose
|
case "compose": // 'c': compose
|
||||||
compose_actions.start("stream", {trigger: "compose_hotkey"});
|
compose_actions.start("stream", {trigger: "compose_hotkey"});
|
||||||
return true;
|
return true;
|
||||||
case "compose_private_message":
|
case "compose_private_message":
|
||||||
compose_actions.start("private", {trigger: "compose_hotkey"});
|
compose_actions.start("private", {trigger: "compose_hotkey"});
|
||||||
return true;
|
return true;
|
||||||
case "narrow_private":
|
case "narrow_private":
|
||||||
return do_narrow_action((target, opts) => {
|
return do_narrow_action((target, opts) => {
|
||||||
narrow.by("is", "private", opts);
|
narrow.by("is", "private", opts);
|
||||||
});
|
});
|
||||||
case "query_streams":
|
case "query_streams":
|
||||||
stream_list.initiate_search();
|
stream_list.initiate_search();
|
||||||
return true;
|
return true;
|
||||||
case "query_users":
|
case "query_users":
|
||||||
activity.initiate_search();
|
activity.initiate_search();
|
||||||
return true;
|
return true;
|
||||||
case "search":
|
case "search":
|
||||||
case "search_with_k":
|
case "search_with_k":
|
||||||
search.initiate_search();
|
search.initiate_search();
|
||||||
return true;
|
return true;
|
||||||
case "gear_menu":
|
case "gear_menu":
|
||||||
gear_menu.open();
|
gear_menu.open();
|
||||||
return true;
|
return true;
|
||||||
case "show_shortcuts": // Show keyboard shortcuts page
|
case "show_shortcuts": // Show keyboard shortcuts page
|
||||||
info_overlay.maybe_show_keyboard_shortcuts();
|
info_overlay.maybe_show_keyboard_shortcuts();
|
||||||
return true;
|
return true;
|
||||||
case "stream_cycle_backward":
|
case "stream_cycle_backward":
|
||||||
narrow.stream_cycle_backward();
|
narrow.stream_cycle_backward();
|
||||||
return true;
|
return true;
|
||||||
case "stream_cycle_forward":
|
case "stream_cycle_forward":
|
||||||
narrow.stream_cycle_forward();
|
narrow.stream_cycle_forward();
|
||||||
return true;
|
return true;
|
||||||
case "n_key":
|
case "n_key":
|
||||||
narrow.narrow_to_next_topic();
|
narrow.narrow_to_next_topic();
|
||||||
return true;
|
return true;
|
||||||
case "p_key":
|
case "p_key":
|
||||||
narrow.narrow_to_next_pm_string();
|
narrow.narrow_to_next_pm_string();
|
||||||
return true;
|
return true;
|
||||||
case "open_drafts":
|
case "open_drafts":
|
||||||
drafts.launch();
|
drafts.launch();
|
||||||
return true;
|
return true;
|
||||||
case "reply_message": // 'r': respond to message
|
case "reply_message": // 'r': respond to message
|
||||||
// Note that you can "enter" to respond to messages as well,
|
// Note that you can "enter" to respond to messages as well,
|
||||||
// but that is handled in process_enter_key().
|
// but that is handled in process_enter_key().
|
||||||
compose_actions.respond_to_message({trigger: "hotkey"});
|
compose_actions.respond_to_message({trigger: "hotkey"});
|
||||||
return true;
|
return true;
|
||||||
case "C_deprecated":
|
case "C_deprecated":
|
||||||
ui.maybe_show_deprecation_notice("C");
|
ui.maybe_show_deprecation_notice("C");
|
||||||
return true;
|
return true;
|
||||||
case "star_deprecated":
|
case "star_deprecated":
|
||||||
ui.maybe_show_deprecation_notice("*");
|
ui.maybe_show_deprecation_notice("*");
|
||||||
return true;
|
return true;
|
||||||
case "copy_with_c":
|
case "copy_with_c":
|
||||||
copy_and_paste.copy_handler();
|
copy_and_paste.copy_handler();
|
||||||
return true;
|
return true;
|
||||||
case "open_recent_topics":
|
case "open_recent_topics":
|
||||||
hashchange.go_to_location("recent_topics");
|
hashchange.go_to_location("recent_topics");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current_msg_list.empty()) {
|
if (current_msg_list.empty()) {
|
||||||
@@ -692,81 +692,81 @@ exports.process_hotkey = function (e, hotkey) {
|
|||||||
|
|
||||||
// Navigation shortcuts
|
// Navigation shortcuts
|
||||||
switch (event_name) {
|
switch (event_name) {
|
||||||
case "down_arrow":
|
case "down_arrow":
|
||||||
case "vim_down":
|
case "vim_down":
|
||||||
navigate.down(true); // with_centering
|
navigate.down(true); // with_centering
|
||||||
return true;
|
return true;
|
||||||
case "up_arrow":
|
case "up_arrow":
|
||||||
case "vim_up":
|
case "vim_up":
|
||||||
navigate.up();
|
navigate.up();
|
||||||
return true;
|
return true;
|
||||||
case "home":
|
case "home":
|
||||||
navigate.to_home();
|
navigate.to_home();
|
||||||
return true;
|
return true;
|
||||||
case "end":
|
case "end":
|
||||||
case "G_end":
|
case "G_end":
|
||||||
navigate.to_end();
|
navigate.to_end();
|
||||||
return true;
|
return true;
|
||||||
case "page_up":
|
case "page_up":
|
||||||
case "vim_page_up":
|
case "vim_page_up":
|
||||||
case "shift_spacebar":
|
case "shift_spacebar":
|
||||||
navigate.page_up();
|
navigate.page_up();
|
||||||
return true;
|
return true;
|
||||||
case "page_down":
|
case "page_down":
|
||||||
case "vim_page_down":
|
case "vim_page_down":
|
||||||
case "spacebar":
|
case "spacebar":
|
||||||
navigate.page_down();
|
navigate.page_down();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const msg = current_msg_list.selected_message();
|
const msg = current_msg_list.selected_message();
|
||||||
// Shortcuts that operate on a message
|
// Shortcuts that operate on a message
|
||||||
switch (event_name) {
|
switch (event_name) {
|
||||||
case "message_actions":
|
case "message_actions":
|
||||||
return popovers.open_message_menu(msg);
|
return popovers.open_message_menu(msg);
|
||||||
case "star_message":
|
case "star_message":
|
||||||
message_flags.toggle_starred_and_update_server(msg);
|
message_flags.toggle_starred_and_update_server(msg);
|
||||||
return true;
|
return true;
|
||||||
case "narrow_by_recipient":
|
case "narrow_by_recipient":
|
||||||
return do_narrow_action(narrow.by_recipient);
|
return do_narrow_action(narrow.by_recipient);
|
||||||
case "narrow_by_topic":
|
case "narrow_by_topic":
|
||||||
return do_narrow_action(narrow.by_topic);
|
return do_narrow_action(narrow.by_topic);
|
||||||
case "respond_to_author": // 'R': respond to author
|
case "respond_to_author": // 'R': respond to author
|
||||||
compose_actions.respond_to_message({reply_type: "personal", trigger: "hotkey pm"});
|
compose_actions.respond_to_message({reply_type: "personal", trigger: "hotkey pm"});
|
||||||
return true;
|
return true;
|
||||||
case "compose_reply_with_mention": // '@': respond to message with mention to author
|
case "compose_reply_with_mention": // '@': respond to message with mention to author
|
||||||
compose_actions.reply_with_mention({trigger: "hotkey"});
|
compose_actions.reply_with_mention({trigger: "hotkey"});
|
||||||
return true;
|
return true;
|
||||||
case "show_lightbox":
|
case "show_lightbox":
|
||||||
lightbox.show_from_selected_message();
|
lightbox.show_from_selected_message();
|
||||||
return true;
|
return true;
|
||||||
case "show_sender_info":
|
case "show_sender_info":
|
||||||
popovers.show_sender_info();
|
popovers.show_sender_info();
|
||||||
return true;
|
return true;
|
||||||
case "toggle_reactions_popover": // ':': open reactions to message
|
case "toggle_reactions_popover": // ':': open reactions to message
|
||||||
reactions.open_reactions_popover();
|
reactions.open_reactions_popover();
|
||||||
return true;
|
return true;
|
||||||
case "thumbs_up_emoji": { // '+': reacts with thumbs up emoji on selected message
|
case "thumbs_up_emoji": { // '+': reacts with thumbs up emoji on selected message
|
||||||
// Use canonical name.
|
// Use canonical name.
|
||||||
const thumbs_up_emoji_code = "1f44d";
|
const thumbs_up_emoji_code = "1f44d";
|
||||||
const canonical_name = emoji.get_emoji_name(thumbs_up_emoji_code);
|
const canonical_name = emoji.get_emoji_name(thumbs_up_emoji_code);
|
||||||
reactions.toggle_emoji_reaction(msg.id, canonical_name);
|
reactions.toggle_emoji_reaction(msg.id, canonical_name);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "toggle_mute":
|
case "toggle_mute":
|
||||||
muting_ui.toggle_mute(msg);
|
muting_ui.toggle_mute(msg);
|
||||||
return true;
|
return true;
|
||||||
case "toggle_message_collapse":
|
case "toggle_message_collapse":
|
||||||
condense.toggle_collapse(msg);
|
condense.toggle_collapse(msg);
|
||||||
return true;
|
return true;
|
||||||
case "compose_quote_reply": // > : respond to selected message with quote
|
case "compose_quote_reply": // > : respond to selected message with quote
|
||||||
compose_actions.quote_and_reply({trigger: "hotkey"});
|
compose_actions.quote_and_reply({trigger: "hotkey"});
|
||||||
return true;
|
return true;
|
||||||
case "edit_message": {
|
case "edit_message": {
|
||||||
const row = current_msg_list.get_row(msg.id);
|
const row = current_msg_list.get_row(msg.id);
|
||||||
message_edit.start(row);
|
message_edit.start(row);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -100,60 +100,60 @@ function place_popover(hotspot) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
switch (orientation) {
|
switch (orientation) {
|
||||||
case TOP:
|
case TOP:
|
||||||
popover_offset = {
|
popover_offset = {
|
||||||
top: -(popover_height + arrow_offset),
|
top: -(popover_height + arrow_offset),
|
||||||
left: el_width / 2 - popover_width / 2,
|
left: el_width / 2 - popover_width / 2,
|
||||||
};
|
};
|
||||||
arrow_placement = "bottom";
|
arrow_placement = "bottom";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LEFT:
|
case LEFT:
|
||||||
popover_offset = {
|
popover_offset = {
|
||||||
top: el_height / 2 - popover_height / 2,
|
top: el_height / 2 - popover_height / 2,
|
||||||
left: -(popover_width + arrow_offset),
|
left: -(popover_width + arrow_offset),
|
||||||
};
|
};
|
||||||
arrow_placement = "right";
|
arrow_placement = "right";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BOTTOM:
|
case BOTTOM:
|
||||||
popover_offset = {
|
popover_offset = {
|
||||||
top: el_height + arrow_offset,
|
top: el_height + arrow_offset,
|
||||||
left: el_width / 2 - popover_width / 2,
|
left: el_width / 2 - popover_width / 2,
|
||||||
};
|
};
|
||||||
arrow_placement = "top";
|
arrow_placement = "top";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIGHT:
|
case RIGHT:
|
||||||
popover_offset = {
|
popover_offset = {
|
||||||
top: el_height / 2 - popover_height / 2,
|
top: el_height / 2 - popover_height / 2,
|
||||||
left: el_width + arrow_offset,
|
left: el_width + arrow_offset,
|
||||||
};
|
};
|
||||||
arrow_placement = "left";
|
arrow_placement = "left";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LEFT_BOTTOM:
|
case LEFT_BOTTOM:
|
||||||
popover_offset = {
|
popover_offset = {
|
||||||
top: 0,
|
top: 0,
|
||||||
left: -(popover_width + arrow_offset / 2),
|
left: -(popover_width + arrow_offset / 2),
|
||||||
};
|
};
|
||||||
arrow_placement = "";
|
arrow_placement = "";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIEWPORT_CENTER:
|
case VIEWPORT_CENTER:
|
||||||
popover_offset = {
|
popover_offset = {
|
||||||
top: el_height / 2,
|
top: el_height / 2,
|
||||||
left: el_width / 2,
|
left: el_width / 2,
|
||||||
};
|
};
|
||||||
arrow_placement = "";
|
arrow_placement = "";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
blueslip.error(
|
blueslip.error(
|
||||||
"Invalid popover placement value for hotspot '" +
|
"Invalid popover placement value for hotspot '" +
|
||||||
hotspot.name + "'",
|
hotspot.name + "'",
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// position arrow
|
// position arrow
|
||||||
|
|||||||
@@ -169,42 +169,42 @@ exports.end_if_focused_on_message_row_edit = function () {
|
|||||||
function handle_message_row_edit_keydown(e) {
|
function handle_message_row_edit_keydown(e) {
|
||||||
const code = e.keyCode || e.which;
|
const code = e.keyCode || e.which;
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case 13:
|
case 13:
|
||||||
if ($(e.target).hasClass("message_edit_content")) {
|
if ($(e.target).hasClass("message_edit_content")) {
|
||||||
// Pressing enter to save edits is coupled with enter to send
|
// Pressing enter to save edits is coupled with enter to send
|
||||||
if (composebox_typeahead.should_enter_send(e)) {
|
if (composebox_typeahead.should_enter_send(e)) {
|
||||||
const row = $(".message_edit_content").filter(":focus").closest(".message_row");
|
const row = $(".message_edit_content").filter(":focus").closest(".message_row");
|
||||||
const message_edit_save_button = row.find(".message_edit_save");
|
const message_edit_save_button = row.find(".message_edit_save");
|
||||||
if (message_edit_save_button.attr("disabled") === "disabled") {
|
if (message_edit_save_button.attr("disabled") === "disabled") {
|
||||||
// In cases when the save button is disabled
|
// In cases when the save button is disabled
|
||||||
// we need to disable save on pressing enter
|
// we need to disable save on pressing enter
|
||||||
// Prevent default to avoid new-line on pressing
|
// Prevent default to avoid new-line on pressing
|
||||||
// enter inside the textarea in this case
|
// enter inside the textarea in this case
|
||||||
|
e.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
exports.save_message_row_edit(row);
|
||||||
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
} else {
|
||||||
|
composebox_typeahead.handle_enter($(e.target), e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else if ($(e.target).hasClass("message_edit_topic") ||
|
||||||
|
$(e.target).hasClass("message_edit_topic_propagate")) {
|
||||||
|
const row = $(e.target).closest(".message_row");
|
||||||
exports.save_message_row_edit(row);
|
exports.save_message_row_edit(row);
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
} else {
|
|
||||||
composebox_typeahead.handle_enter($(e.target), e);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
} else if ($(e.target).hasClass("message_edit_topic") ||
|
return;
|
||||||
$(e.target).hasClass("message_edit_topic_propagate")) {
|
case 27: // Handle escape keys in the message_edit form.
|
||||||
const row = $(e.target).closest(".message_row");
|
exports.end_if_focused_on_message_row_edit();
|
||||||
exports.save_message_row_edit(row);
|
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
return;
|
||||||
return;
|
default:
|
||||||
case 27: // Handle escape keys in the message_edit form.
|
return;
|
||||||
exports.end_if_focused_on_message_row_edit();
|
|
||||||
e.stopPropagation();
|
|
||||||
e.preventDefault();
|
|
||||||
return;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,19 +212,19 @@ function handle_inline_topic_edit_keydown(e) {
|
|||||||
let row;
|
let row;
|
||||||
const code = e.keyCode || e.which;
|
const code = e.keyCode || e.which;
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case 13: // Handle enter key in the recipient bar/inline topic edit form
|
case 13: // Handle enter key in the recipient bar/inline topic edit form
|
||||||
row = $(e.target).closest(".recipient_row");
|
row = $(e.target).closest(".recipient_row");
|
||||||
exports.save_inline_topic_edit(row);
|
exports.save_inline_topic_edit(row);
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return;
|
return;
|
||||||
case 27: // handle escape
|
case 27: // handle escape
|
||||||
exports.end_if_focused_on_inline_topic_edit();
|
exports.end_if_focused_on_inline_topic_edit();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -164,37 +164,37 @@ exports.add_message_metadata = function (message) {
|
|||||||
util.convert_message_topic(message);
|
util.convert_message_topic(message);
|
||||||
|
|
||||||
switch (message.type) {
|
switch (message.type) {
|
||||||
case "stream":
|
case "stream":
|
||||||
message.is_stream = true;
|
message.is_stream = true;
|
||||||
message.stream = message.display_recipient;
|
message.stream = message.display_recipient;
|
||||||
message.reply_to = message.sender_email;
|
message.reply_to = message.sender_email;
|
||||||
|
|
||||||
stream_topic_history.add_message({
|
stream_topic_history.add_message({
|
||||||
stream_id: message.stream_id,
|
stream_id: message.stream_id,
|
||||||
topic_name: message.topic,
|
topic_name: message.topic,
|
||||||
message_id: message.id,
|
message_id: message.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
recent_senders.process_message_for_senders(message);
|
recent_senders.process_message_for_senders(message);
|
||||||
message_user_ids.add(message.sender_id);
|
message_user_ids.add(message.sender_id);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "private":
|
case "private":
|
||||||
message.is_private = true;
|
message.is_private = true;
|
||||||
message.reply_to = util.normalize_recipients(
|
message.reply_to = util.normalize_recipients(
|
||||||
exports.get_pm_emails(message));
|
exports.get_pm_emails(message));
|
||||||
message.display_reply_to = exports.get_pm_full_names(message);
|
message.display_reply_to = exports.get_pm_full_names(message);
|
||||||
message.pm_with_url = people.pm_with_url(message);
|
message.pm_with_url = people.pm_with_url(message);
|
||||||
message.to_user_ids = people.pm_reply_user_string(message);
|
message.to_user_ids = people.pm_reply_user_string(message);
|
||||||
|
|
||||||
exports.process_message_for_recent_private_messages(message);
|
exports.process_message_for_recent_private_messages(message);
|
||||||
|
|
||||||
if (people.is_my_user_id(message.sender_id)) {
|
if (people.is_my_user_id(message.sender_id)) {
|
||||||
for (const recip of message.display_recipient) {
|
for (const recip of message.display_recipient) {
|
||||||
message_user_ids.add(recip.id);
|
message_user_ids.add(recip.id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
alert_words.process_message(message);
|
alert_words.process_message(message);
|
||||||
|
|||||||
@@ -684,13 +684,13 @@ exports.by_recipient = function (target_id, opts) {
|
|||||||
unread_ops.notify_server_message_read(message);
|
unread_ops.notify_server_message_read(message);
|
||||||
|
|
||||||
switch (message.type) {
|
switch (message.type) {
|
||||||
case "private":
|
case "private":
|
||||||
exports.by("pm-with", message.reply_to, opts);
|
exports.by("pm-with", message.reply_to, opts);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "stream":
|
case "stream":
|
||||||
exports.by("stream", message.stream, opts);
|
exports.by("stream", message.stream, opts);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1135,18 +1135,18 @@ exports.extract_people_from_message = function (message) {
|
|||||||
let involved_people;
|
let involved_people;
|
||||||
|
|
||||||
switch (message.type) {
|
switch (message.type) {
|
||||||
case "stream":
|
case "stream":
|
||||||
involved_people = [{full_name: message.sender_full_name,
|
involved_people = [{full_name: message.sender_full_name,
|
||||||
user_id: message.sender_id,
|
user_id: message.sender_id,
|
||||||
email: message.sender_email}];
|
email: message.sender_email}];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "private":
|
case "private":
|
||||||
involved_people = message.display_recipient;
|
involved_people = message.display_recipient;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
involved_people = [];
|
involved_people = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add new people involved in this message to the people list
|
// Add new people involved in this message to the people list
|
||||||
|
|||||||
@@ -131,31 +131,31 @@ function get_custom_profile_field_data(user, field, field_types, dateFormat) {
|
|||||||
profile_field.type = field_type;
|
profile_field.type = field_type;
|
||||||
|
|
||||||
switch (field_type) {
|
switch (field_type) {
|
||||||
case field_types.DATE.id:
|
case field_types.DATE.id:
|
||||||
profile_field.value = moment(field_value.value).format(dateFormat);
|
profile_field.value = moment(field_value.value).format(dateFormat);
|
||||||
break;
|
break;
|
||||||
case field_types.USER.id:
|
case field_types.USER.id:
|
||||||
profile_field.id = field.id;
|
profile_field.id = field.id;
|
||||||
profile_field.is_user_field = true;
|
profile_field.is_user_field = true;
|
||||||
profile_field.value = field_value.value;
|
profile_field.value = field_value.value;
|
||||||
break;
|
break;
|
||||||
case field_types.CHOICE.id: {
|
case field_types.CHOICE.id: {
|
||||||
const field_choice_dict = JSON.parse(field.field_data);
|
const field_choice_dict = JSON.parse(field.field_data);
|
||||||
profile_field.value = field_choice_dict[field_value.value].text;
|
profile_field.value = field_choice_dict[field_value.value].text;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case field_types.SHORT_TEXT.id:
|
case field_types.SHORT_TEXT.id:
|
||||||
case field_types.LONG_TEXT.id:
|
case field_types.LONG_TEXT.id:
|
||||||
profile_field.value = field_value.value;
|
profile_field.value = field_value.value;
|
||||||
profile_field.rendered_value = field_value.rendered_value;
|
profile_field.rendered_value = field_value.rendered_value;
|
||||||
break;
|
break;
|
||||||
case field_types.EXTERNAL_ACCOUNT.id:
|
case field_types.EXTERNAL_ACCOUNT.id:
|
||||||
profile_field.value = field_value.value;
|
profile_field.value = field_value.value;
|
||||||
profile_field.field_data = JSON.parse(field.field_data);
|
profile_field.field_data = JSON.parse(field.field_data);
|
||||||
profile_field.link = settings_profile_fields.get_external_account_link(profile_field);
|
profile_field.link = settings_profile_fields.get_external_account_link(profile_field);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
profile_field.value = field_value.value;
|
profile_field.value = field_value.value;
|
||||||
}
|
}
|
||||||
return profile_field;
|
return profile_field;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -269,49 +269,49 @@ function render(next_state) {
|
|||||||
|
|
||||||
function dispatch(action, payload) {
|
function dispatch(action, payload) {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case "CHANGE_CATEGORY":
|
case "CHANGE_CATEGORY":
|
||||||
render(Object.assign({}, state, {
|
render(Object.assign({}, state, {
|
||||||
category: payload.category,
|
category: payload.category,
|
||||||
}));
|
}));
|
||||||
update_path();
|
update_path();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "SHOW_INTEGRATION":
|
case "SHOW_INTEGRATION":
|
||||||
render(Object.assign({}, state, {
|
render(Object.assign({}, state, {
|
||||||
integration: payload.integration,
|
integration: payload.integration,
|
||||||
}));
|
}));
|
||||||
update_path();
|
update_path();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "HIDE_INTEGRATION":
|
case "HIDE_INTEGRATION":
|
||||||
render(Object.assign({}, state, {
|
render(Object.assign({}, state, {
|
||||||
integration: null,
|
integration: null,
|
||||||
}));
|
}));
|
||||||
update_path();
|
update_path();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "SHOW_CATEGORY":
|
case "SHOW_CATEGORY":
|
||||||
render(Object.assign({}, state, {
|
render(Object.assign({}, state, {
|
||||||
integration: null,
|
integration: null,
|
||||||
category: payload.category,
|
category: payload.category,
|
||||||
}));
|
}));
|
||||||
update_path();
|
update_path();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "UPDATE_QUERY":
|
case "UPDATE_QUERY":
|
||||||
render(Object.assign({}, state, {
|
render(Object.assign({}, state, {
|
||||||
query: payload.query,
|
query: payload.query,
|
||||||
}));
|
}));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "LOAD_PATH":
|
case "LOAD_PATH":
|
||||||
render(get_state_from_path());
|
render(get_state_from_path());
|
||||||
google_analytics.config({page_path: window.location.pathname});
|
google_analytics.config({page_path: window.location.pathname});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
blueslip.error("Invalid action dispatched on /integrations.");
|
blueslip.error("Invalid action dispatched on /integrations.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -488,73 +488,73 @@ exports.change_focused_element = function (e, input_key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (input_key) {
|
switch (input_key) {
|
||||||
case "left_arrow":
|
case "left_arrow":
|
||||||
if (start !== 0 || is_selected) {
|
if (start !== 0 || is_selected) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
current_focus_elem = filter_buttons().last();
|
current_focus_elem = filter_buttons().last();
|
||||||
break;
|
break;
|
||||||
case "right_arrow":
|
case "right_arrow":
|
||||||
if (end !== text_length || is_selected) {
|
if (end !== text_length || is_selected) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
current_focus_elem = filter_buttons().first();
|
current_focus_elem = filter_buttons().first();
|
||||||
break;
|
break;
|
||||||
case "down_arrow":
|
case "down_arrow":
|
||||||
set_table_focus(row_focus, col_focus);
|
set_table_focus(row_focus, col_focus);
|
||||||
return true;
|
return true;
|
||||||
case "click":
|
case "click":
|
||||||
// Note: current_focus_elem can be different here, so we just
|
// Note: current_focus_elem can be different here, so we just
|
||||||
// set current_focus_elem to the input box, we don't want .focus() on
|
// set current_focus_elem to the input box, we don't want .focus() on
|
||||||
// it since it is already focused.
|
// it since it is already focused.
|
||||||
// We only do this for search beacuse we don't want the focus to
|
// We only do this for search beacuse we don't want the focus to
|
||||||
// go away from the input box when `revive_current_focus` is called
|
// go away from the input box when `revive_current_focus` is called
|
||||||
// on rerender when user is typing.
|
// on rerender when user is typing.
|
||||||
current_focus_elem = $("#recent_topics_search");
|
current_focus_elem = $("#recent_topics_search");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if ($elem.hasClass("btn-recent-filters")) {
|
} else if ($elem.hasClass("btn-recent-filters")) {
|
||||||
switch (input_key) {
|
switch (input_key) {
|
||||||
case "left_arrow":
|
case "left_arrow":
|
||||||
if (filter_buttons().first()[0] === $elem[0]) {
|
if (filter_buttons().first()[0] === $elem[0]) {
|
||||||
current_focus_elem = $("#recent_topics_search");
|
current_focus_elem = $("#recent_topics_search");
|
||||||
} else {
|
} else {
|
||||||
current_focus_elem = $elem.prev();
|
current_focus_elem = $elem.prev();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "right_arrow":
|
case "right_arrow":
|
||||||
if (filter_buttons().last()[0] === $elem[0]) {
|
if (filter_buttons().last()[0] === $elem[0]) {
|
||||||
current_focus_elem = $("#recent_topics_search");
|
current_focus_elem = $("#recent_topics_search");
|
||||||
} else {
|
} else {
|
||||||
current_focus_elem = $elem.next();
|
current_focus_elem = $elem.next();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "down_arrow":
|
case "down_arrow":
|
||||||
set_table_focus(row_focus, col_focus);
|
set_table_focus(row_focus, col_focus);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (current_focus_elem === "table") {
|
} else if (current_focus_elem === "table") {
|
||||||
// For arrowing around the table of topics, we implement left/right
|
// For arrowing around the table of topics, we implement left/right
|
||||||
// wraparound. Going off the top or the bottom takes one
|
// wraparound. Going off the top or the bottom takes one
|
||||||
// to the navigation at the top (see set_table_focus).
|
// to the navigation at the top (see set_table_focus).
|
||||||
switch (input_key) {
|
switch (input_key) {
|
||||||
case "left_arrow":
|
case "left_arrow":
|
||||||
col_focus -= 1;
|
col_focus -= 1;
|
||||||
if (col_focus < 0) {
|
if (col_focus < 0) {
|
||||||
col_focus = MAX_SELECTABLE_COLS - 1;
|
col_focus = MAX_SELECTABLE_COLS - 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "right_arrow":
|
case "right_arrow":
|
||||||
col_focus += 1;
|
col_focus += 1;
|
||||||
if (col_focus >= MAX_SELECTABLE_COLS) {
|
if (col_focus >= MAX_SELECTABLE_COLS) {
|
||||||
col_focus = 0;
|
col_focus = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "down_arrow":
|
case "down_arrow":
|
||||||
row_focus += 1;
|
row_focus += 1;
|
||||||
break;
|
break;
|
||||||
case "up_arrow":
|
case "up_arrow":
|
||||||
row_focus -= 1;
|
row_focus -= 1;
|
||||||
}
|
}
|
||||||
set_table_focus(row_focus, col_focus);
|
set_table_focus(row_focus, col_focus);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -302,21 +302,21 @@ function get_topic_suggestions(last, operators) {
|
|||||||
// in terms of telling us whether they provided the operator,
|
// in terms of telling us whether they provided the operator,
|
||||||
// i.e. "foo" and "search:foo" both become [{operator: 'search', operand: 'foo'}].
|
// i.e. "foo" and "search:foo" both become [{operator: 'search', operand: 'foo'}].
|
||||||
switch (operator) {
|
switch (operator) {
|
||||||
case "stream":
|
case "stream":
|
||||||
guess = "";
|
guess = "";
|
||||||
stream = operand;
|
stream = operand;
|
||||||
suggest_operators.push(last);
|
suggest_operators.push(last);
|
||||||
break;
|
break;
|
||||||
case "topic":
|
case "topic":
|
||||||
case "search":
|
case "search":
|
||||||
guess = operand;
|
guess = operand;
|
||||||
if (filter.has_operator("stream")) {
|
if (filter.has_operator("stream")) {
|
||||||
stream = filter.operands("stream")[0];
|
stream = filter.operands("stream")[0];
|
||||||
} else {
|
} else {
|
||||||
stream = narrow_state.stream();
|
stream = narrow_state.stream();
|
||||||
suggest_operators.push({operator: "stream", operand: stream});
|
suggest_operators.push({operator: "stream", operand: stream});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stream) {
|
if (!stream) {
|
||||||
|
|||||||
@@ -52,29 +52,29 @@ function get_events_success(events) {
|
|||||||
// rarely modified logic for non-normal events.
|
// rarely modified logic for non-normal events.
|
||||||
const dispatch_event = function dispatch_event(event) {
|
const dispatch_event = function dispatch_event(event) {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case "message": {
|
case "message": {
|
||||||
const msg = event.message;
|
const msg = event.message;
|
||||||
msg.flags = event.flags;
|
msg.flags = event.flags;
|
||||||
if (event.local_message_id) {
|
if (event.local_message_id) {
|
||||||
msg.local_id = event.local_message_id;
|
msg.local_id = event.local_message_id;
|
||||||
sent_messages.report_event_received(event.local_message_id);
|
sent_messages.report_event_received(event.local_message_id);
|
||||||
|
}
|
||||||
|
messages.push(msg);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
messages.push(msg);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case "update_message":
|
case "update_message":
|
||||||
update_message_events.push(event);
|
update_message_events.push(event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "delete_message":
|
case "delete_message":
|
||||||
case "submessage":
|
case "submessage":
|
||||||
case "update_message_flags":
|
case "update_message_flags":
|
||||||
post_message_events.push(event);
|
post_message_events.push(event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return server_events_dispatch.dispatch_normal_event(event);
|
return server_events_dispatch.dispatch_normal_event(event);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -5,21 +5,21 @@ exports.get_group = function (section) {
|
|||||||
// Sometimes several sections all share the same code.
|
// Sometimes several sections all share the same code.
|
||||||
|
|
||||||
switch (section) {
|
switch (section) {
|
||||||
case "organization-profile":
|
case "organization-profile":
|
||||||
case "organization-settings":
|
case "organization-settings":
|
||||||
case "organization-permissions":
|
case "organization-permissions":
|
||||||
case "auth-methods":
|
case "auth-methods":
|
||||||
return "org_misc";
|
return "org_misc";
|
||||||
|
|
||||||
case "bot-list-admin":
|
case "bot-list-admin":
|
||||||
return "org_bots";
|
return "org_bots";
|
||||||
|
|
||||||
case "user-list-admin":
|
case "user-list-admin":
|
||||||
case "deactivated-users-admin":
|
case "deactivated-users-admin":
|
||||||
return "org_users";
|
return "org_users";
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return section;
|
return section;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -118,14 +118,14 @@ function update_view_on_reactivate(row) {
|
|||||||
function get_status_field() {
|
function get_status_field() {
|
||||||
const current_tab = settings_panel_menu.org_settings.current_tab();
|
const current_tab = settings_panel_menu.org_settings.current_tab();
|
||||||
switch (current_tab) {
|
switch (current_tab) {
|
||||||
case "deactivated-users-admin":
|
case "deactivated-users-admin":
|
||||||
return $("#deactivated-user-field-status").expectOne();
|
return $("#deactivated-user-field-status").expectOne();
|
||||||
case "user-list-admin":
|
case "user-list-admin":
|
||||||
return $("#user-field-status").expectOne();
|
return $("#user-field-status").expectOne();
|
||||||
case "bot-list-admin":
|
case "bot-list-admin":
|
||||||
return $("#bot-field-status").expectOne();
|
return $("#bot-field-status").expectOne();
|
||||||
default:
|
default:
|
||||||
blueslip.fatal("Invalid admin settings page");
|
blueslip.fatal("Invalid admin settings page");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,48 +19,48 @@ exports.update_property = function (stream_id, property, value, other_values) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (property) {
|
switch (property) {
|
||||||
case "color":
|
case "color":
|
||||||
stream_color.update_stream_color(sub, value, {update_historical: true});
|
stream_color.update_stream_color(sub, value, {update_historical: true});
|
||||||
break;
|
break;
|
||||||
case "in_home_view":
|
case "in_home_view":
|
||||||
stream_muting.update_is_muted(sub, !value);
|
stream_muting.update_is_muted(sub, !value);
|
||||||
break;
|
break;
|
||||||
case "desktop_notifications":
|
case "desktop_notifications":
|
||||||
case "audible_notifications":
|
case "audible_notifications":
|
||||||
case "push_notifications":
|
case "push_notifications":
|
||||||
case "email_notifications":
|
case "email_notifications":
|
||||||
case "wildcard_mentions_notify":
|
case "wildcard_mentions_notify":
|
||||||
update_stream_setting(sub, value, property);
|
update_stream_setting(sub, value, property);
|
||||||
settings_notifications.update_page();
|
settings_notifications.update_page();
|
||||||
break;
|
break;
|
||||||
case "name":
|
case "name":
|
||||||
subs.update_stream_name(sub, value);
|
subs.update_stream_name(sub, value);
|
||||||
break;
|
break;
|
||||||
case "description":
|
case "description":
|
||||||
subs.update_stream_description(sub, value, other_values.rendered_description);
|
subs.update_stream_description(sub, value, other_values.rendered_description);
|
||||||
break;
|
break;
|
||||||
case "email_address":
|
case "email_address":
|
||||||
sub.email_address = value;
|
sub.email_address = value;
|
||||||
break;
|
break;
|
||||||
case "pin_to_top":
|
case "pin_to_top":
|
||||||
update_stream_setting(sub, value, property);
|
update_stream_setting(sub, value, property);
|
||||||
stream_list.refresh_pinned_or_unpinned_stream(sub);
|
stream_list.refresh_pinned_or_unpinned_stream(sub);
|
||||||
break;
|
break;
|
||||||
case "invite_only":
|
case "invite_only":
|
||||||
subs.update_stream_privacy(sub, {
|
subs.update_stream_privacy(sub, {
|
||||||
invite_only: value,
|
invite_only: value,
|
||||||
history_public_to_subscribers: other_values.history_public_to_subscribers,
|
history_public_to_subscribers: other_values.history_public_to_subscribers,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "stream_post_policy":
|
case "stream_post_policy":
|
||||||
subs.update_stream_post_policy(sub, value);
|
subs.update_stream_post_policy(sub, value);
|
||||||
break;
|
break;
|
||||||
case "message_retention_days":
|
case "message_retention_days":
|
||||||
subs.update_message_retention_setting(sub, value);
|
subs.update_message_retention_setting(sub, value);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
blueslip.warn("Unexpected subscription property type", {property: property,
|
blueslip.warn("Unexpected subscription property type", {property: property,
|
||||||
value: value});
|
value: value});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -27,52 +27,52 @@ exports.get_item = function (key, config) {
|
|||||||
}
|
}
|
||||||
if (config.mode === "compose") {
|
if (config.mode === "compose") {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "textarea":
|
case "textarea":
|
||||||
return $("#compose-textarea");
|
return $("#compose-textarea");
|
||||||
case "send_button":
|
case "send_button":
|
||||||
return $("#compose-send-button");
|
return $("#compose-send-button");
|
||||||
case "send_status_identifier":
|
case "send_status_identifier":
|
||||||
return "#compose-send-status";
|
return "#compose-send-status";
|
||||||
case "send_status":
|
case "send_status":
|
||||||
return $("#compose-send-status");
|
return $("#compose-send-status");
|
||||||
case "send_status_close_button":
|
case "send_status_close_button":
|
||||||
return $(".compose-send-status-close");
|
return $(".compose-send-status-close");
|
||||||
case "send_status_message":
|
case "send_status_message":
|
||||||
return $("#compose-error-msg");
|
return $("#compose-error-msg");
|
||||||
case "file_input_identifier":
|
case "file_input_identifier":
|
||||||
return "#file_input";
|
return "#file_input";
|
||||||
case "source":
|
case "source":
|
||||||
return "compose-file-input";
|
return "compose-file-input";
|
||||||
case "drag_drop_container":
|
case "drag_drop_container":
|
||||||
return $("#compose");
|
return $("#compose");
|
||||||
default:
|
default:
|
||||||
throw Error(`Invalid key name for mode "${config.mode}"`);
|
throw Error(`Invalid key name for mode "${config.mode}"`);
|
||||||
}
|
}
|
||||||
} else if (config.mode === "edit") {
|
} else if (config.mode === "edit") {
|
||||||
if (!config.row) {
|
if (!config.row) {
|
||||||
throw Error("Missing row in config");
|
throw Error("Missing row in config");
|
||||||
}
|
}
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "textarea":
|
case "textarea":
|
||||||
return $("#message_edit_content_" + config.row);
|
return $("#message_edit_content_" + config.row);
|
||||||
case "send_button":
|
case "send_button":
|
||||||
return $("#message_edit_content_" + config.row).closest("#message_edit_form").find(".message_edit_save");
|
return $("#message_edit_content_" + config.row).closest("#message_edit_form").find(".message_edit_save");
|
||||||
case "send_status_identifier":
|
case "send_status_identifier":
|
||||||
return "#message-edit-send-status-" + config.row;
|
return "#message-edit-send-status-" + config.row;
|
||||||
case "send_status":
|
case "send_status":
|
||||||
return $("#message-edit-send-status-" + config.row);
|
return $("#message-edit-send-status-" + config.row);
|
||||||
case "send_status_close_button":
|
case "send_status_close_button":
|
||||||
return $("#message-edit-send-status-" + config.row).find(".send-status-close");
|
return $("#message-edit-send-status-" + config.row).find(".send-status-close");
|
||||||
case "send_status_message":
|
case "send_status_message":
|
||||||
return $("#message-edit-send-status-" + config.row).find(".error-msg");
|
return $("#message-edit-send-status-" + config.row).find(".error-msg");
|
||||||
case "file_input_identifier":
|
case "file_input_identifier":
|
||||||
return "#message_edit_file_input_" + config.row;
|
return "#message_edit_file_input_" + config.row;
|
||||||
case "source":
|
case "source":
|
||||||
return "message-edit-file-input";
|
return "message-edit-file-input";
|
||||||
case "drag_drop_container":
|
case "drag_drop_container":
|
||||||
return $("#message_edit_form");
|
return $("#message_edit_form");
|
||||||
default:
|
default:
|
||||||
throw Error(`Invalid key name for mode "${config.mode}"`);
|
throw Error(`Invalid key name for mode "${config.mode}"`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw Error("Invalid upload mode!");
|
throw Error("Invalid upload mode!");
|
||||||
|
|||||||
@@ -80,13 +80,13 @@ exports.same_recipient = function util_same_recipient(a, b) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (a.type) {
|
switch (a.type) {
|
||||||
case "private":
|
case "private":
|
||||||
if (a.to_user_ids === undefined) {
|
if (a.to_user_ids === undefined) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return a.to_user_ids === b.to_user_ids;
|
return a.to_user_ids === b.to_user_ids;
|
||||||
case "stream":
|
case "stream":
|
||||||
return exports.same_stream_and_topic(a, b);
|
return exports.same_stream_and_topic(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
// should never get here
|
// should never get here
|
||||||
|
|||||||
Reference in New Issue
Block a user