diff --git a/.eslintrc.json b/.eslintrc.json index 01e1d5e4bc..24f53a7d9a 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -34,6 +34,7 @@ "loading": false, "typing": false, "compose": false, + "compose_actions": false, "compose_fade": false, "modals": false, "subs": false, diff --git a/frontend_tests/node_tests/hotkey.js b/frontend_tests/node_tests/hotkey.js index 9b19443999..8144e71203 100644 --- a/frontend_tests/node_tests/hotkey.js +++ b/frontend_tests/node_tests/hotkey.js @@ -134,8 +134,8 @@ function stubbing(func_name_to_stub, test_function) { assert_mapping('A', 'navigate.cycle_stream'); assert_mapping('D', 'navigate.cycle_stream'); - assert_mapping('c', 'compose.start'); - assert_mapping('C', 'compose.start'); + assert_mapping('c', 'compose_actions.start'); + assert_mapping('C', 'compose_actions.start'); assert_mapping('v', 'narrow.by'); // Next, test keys that only work on a selected message. diff --git a/static/js/activity.js b/static/js/activity.js index 683e262b85..ae50b4a754 100644 --- a/static/js/activity.js +++ b/static/js/activity.js @@ -589,8 +589,9 @@ function maybe_select_person(e) { // undefined if there are no results var email = people.get_person_from_user_id(topPerson).email; narrow.by('pm-with', email, {select_first_unread: true, trigger: 'user sidebar'}); - compose.start('private', - {trigger: 'sidebar enter key', private_message_recipient: email}); + compose_actions.start('private', { + trigger: 'sidebar enter key', + private_message_recipient: email}); } // Clear the user filter exports.escape_search(); diff --git a/static/js/click_handlers.js b/static/js/click_handlers.js index 7d49e9cd2b..603ee8c15f 100644 --- a/static/js/click_handlers.js +++ b/static/js/click_handlers.js @@ -314,18 +314,18 @@ $(function () { $('.compose_stream_button').click(function () { - compose.start('stream', {trigger: 'new topic button'}); + compose_actions.start('stream', {trigger: 'new topic button'}); }); $('.compose_private_button').click(function () { - compose.start('private'); + compose_actions.start('private'); }); $('.empty_feed_compose_stream').click(function (e) { - compose.start('stream', {trigger: 'empty feed message'}); + compose_actions.start('stream', {trigger: 'empty feed message'}); e.preventDefault(); }); $('.empty_feed_compose_private').click(function (e) { - compose.start('private', {trigger: 'empty feed message'}); + compose_actions.start('private', {trigger: 'empty feed message'}); e.preventDefault(); }); @@ -369,15 +369,17 @@ $(function () { // Keep these 2 feedback bot triggers separate because they have to // propagate the event differently. $('.feedback').click(function () { - compose.start('private', {private_message_recipient: 'feedback@zulip.com', - trigger: 'feedback menu item'}); + compose_actions.start('private', { + private_message_recipient: 'feedback@zulip.com', + trigger: 'feedback menu item'}); }); $('#feedback_button').click(function (e) { e.stopPropagation(); popovers.hide_all(); - compose.start('private', {private_message_recipient: 'feedback@zulip.com', - trigger: 'feedback button'}); + compose_actions.start('private', { + private_message_recipient: 'feedback@zulip.com', + trigger: 'feedback button'}); }); diff --git a/static/js/compose.js b/static/js/compose.js index 7b99ef3b20..e84344e56a 100644 --- a/static/js/compose.js +++ b/static/js/compose.js @@ -633,7 +633,7 @@ exports.respond_to_message = function (opts) { } else { msg_type = message.type; } - compose.start(msg_type, {stream: stream, subject: subject, + compose_actions.start(msg_type, {stream: stream, subject: subject, private_message_recipient: pm_recipient, replying_to_message: message, trigger: opts.trigger}); @@ -1161,7 +1161,7 @@ $(function () { // Urgh, yet another hack to make sure we're "composing" // when text gets added into the composebox. if (!compose.composing()) { - compose.start('stream'); + compose_actions.start('stream'); } var uri = make_upload_absolute(response.uri); @@ -1212,7 +1212,7 @@ $(function () { rawDrop: function (contents) { var textbox = $("#new_message_content"); if (!compose.composing()) { - compose.start('stream'); + compose_actions.start('stream'); } textbox.val(textbox.val() + contents); exports.autosize_textarea(); @@ -1221,9 +1221,9 @@ $(function () { if (page_params.narrow !== undefined) { if (page_params.narrow_topic !== undefined) { - compose.start("stream", {subject: page_params.narrow_topic}); + compose_actions.start("stream", {subject: page_params.narrow_topic}); } else { - compose.start("stream", {}); + compose_actions.start("stream", {}); } } diff --git a/static/js/drafts.js b/static/js/drafts.js index 78ac941831..10dacb0524 100644 --- a/static/js/drafts.js +++ b/static/js/drafts.js @@ -110,7 +110,7 @@ exports.restore_draft = function (draft_id) { if (draft.type === "stream" && draft.stream === "") { draft_copy.subject = ""; } - compose.start(draft_copy.type, draft_copy); + compose_actions.start(draft_copy.type, draft_copy); compose.autosize_textarea(); $("#new_message_content").data("draft-id", draft_id); }; diff --git a/static/js/hotkey.js b/static/js/hotkey.js index 379e18aac4..5931509d0d 100644 --- a/static/js/hotkey.js +++ b/static/js/hotkey.js @@ -476,10 +476,10 @@ exports.process_hotkey = function (e, hotkey) { // Shortcuts that don't require a message switch (event_name) { case 'compose': // 'c': compose - compose.start('stream', {trigger: "compose_hotkey"}); + compose_actions.start('stream', {trigger: "compose_hotkey"}); return true; case 'compose_private_message': - compose.start('private', {trigger: "compose_hotkey"}); + compose_actions.start('private', {trigger: "compose_hotkey"}); return true; case 'narrow_private': return do_narrow_action(function (target, opts) { diff --git a/static/js/narrow.js b/static/js/narrow.js index 41815068b1..f95c5a95e3 100644 --- a/static/js/narrow.js +++ b/static/js/narrow.js @@ -357,9 +357,9 @@ exports.activate = function (raw_operators, opts) { if (!had_message_content && opts.trigger === 'sidebar' && exports.narrowed_by_reply()) { if (exports.narrowed_to_topic()) { - compose.start('stream'); + compose_actions.start('stream'); } else { - compose.start('private'); + compose_actions.start('private'); } } diff --git a/static/js/popovers.js b/static/js/popovers.js index 8100dd574a..4f451f8fdd 100644 --- a/static/js/popovers.js +++ b/static/js/popovers.js @@ -486,13 +486,13 @@ exports.register_click_handlers = function () { var email = people.get_person_from_user_id(user_id).email; popovers.hide_user_sidebar_popover(); - compose.start('private', {private_message_recipient: email, trigger: 'sidebar user actions'}); + compose_actions.start('private', {private_message_recipient: email, trigger: 'sidebar user actions'}); e.stopPropagation(); }); $('body').on('click', '.user_popover .mention_user', function (e) { var user_id = $(e.target).parents('ul').attr('data-user-id'); - compose.start('stream', {trigger: 'sidebar user actions'}); + compose_actions.start('stream', {trigger: 'sidebar user actions'}); var name = people.get_person_from_user_id(user_id).full_name; var textarea = $("#new_message_content"); textarea.val('@**' + name + '** '); diff --git a/static/js/reload.js b/static/js/reload.js index 8c7809d703..45688f9f08 100644 --- a/static/js/reload.js +++ b/static/js/reload.js @@ -98,7 +98,7 @@ exports.initialize = function reload__initialize() { var send_now = parseInt(vars.send_after_reload, 10); // TODO: preserve focus - compose.start(vars.msg_type, {stream: vars.stream || '', + compose_actions.start(vars.msg_type, {stream: vars.stream || '', subject: vars.subject || '', private_message_recipient: vars.recipient || '', content: vars.msg || ''}); diff --git a/static/js/shim.js b/static/js/shim.js index 02bb6e7646..6e2292f1b7 100644 --- a/static/js/shim.js +++ b/static/js/shim.js @@ -8,3 +8,6 @@ that still refer to the old name. var narrow_state = {}; // global, should be made into module narrow_state.set_compose_defaults = narrow.set_compose_defaults; + +var compose_actions = {}; +compose_actions.start = compose.start; diff --git a/static/js/stream_popover.js b/static/js/stream_popover.js index edb0fe3b6d..a4014db6df 100644 --- a/static/js/stream_popover.js +++ b/static/js/stream_popover.js @@ -203,7 +203,7 @@ exports.register_stream_handlers = function () { $('body').on('click', '.compose_to_stream', function (e) { var sub = stream_popover_sub(e); exports.hide_stream_popover(); - compose.start('stream', {stream: sub.name, trigger: 'sidebar stream actions'}); + compose_actions.start('stream', {stream: sub.name, trigger: 'sidebar stream actions'}); e.stopPropagation(); });