diff --git a/static/js/click_handlers.js b/static/js/click_handlers.js index 52f79518e1..a95159d809 100644 --- a/static/js/click_handlers.js +++ b/static/js/click_handlers.js @@ -57,7 +57,7 @@ $(function () { } current_msg_list.select_id(id); - respond_to_message({trigger: 'message click'}); + compose.respond_to_message({trigger: 'message click'}); e.stopPropagation(); popovers.hide_all(); } diff --git a/static/js/compose.js b/static/js/compose.js index 326cdfcd41..f17e1aa501 100644 --- a/static/js/compose.js +++ b/static/js/compose.js @@ -598,6 +598,46 @@ function send_message(request) { } } +exports.respond_to_message = function (opts) { + var message, msg_type; + // Before initiating a reply to a message, if there's an + // in-progress composition, snapshot it. + compose.snapshot_message(); + + message = current_msg_list.selected_message(); + + if (message === undefined) { + return; + } + + unread.mark_message_as_read(message); + + var stream = ''; + var subject = ''; + if (message.type === "stream") { + stream = message.stream; + subject = message.subject; + } + + var pm_recipient = message.reply_to; + if (opts.reply_type === "personal" && message.type === "private") { + // reply_to for private messages is everyone involved, so for + // personals replies we need to set the the private message + // recipient to just the sender + pm_recipient = message.sender_email; + } + if (opts.reply_type === 'personal' || message.type === 'private') { + msg_type = 'private'; + } else { + msg_type = message.type; + } + compose.start(msg_type, {'stream': stream, 'subject': subject, + 'private_message_recipient': pm_recipient, + 'replying_to_message': message, + 'trigger': opts.trigger}); + +}; + // This function is for debugging / data collection only. Arguably it // should live in debug.js, but then it wouldn't be able to call // send_message() directly below. diff --git a/static/js/hotkey.js b/static/js/hotkey.js index efc24b2567..56b832a94c 100644 --- a/static/js/hotkey.js +++ b/static/js/hotkey.js @@ -306,13 +306,13 @@ function process_hotkey(e) { case 'narrow_by_subject': return do_narrow_action(narrow.by_subject); case 'enter': // Enter: respond to message (unless we need to do something else) - respond_to_message({trigger: 'hotkey enter'}); + compose.respond_to_message({trigger: 'hotkey enter'}); return true; case 'reply_message': // 'r': respond to message - respond_to_message({trigger: 'hotkey'}); + compose.respond_to_message({trigger: 'hotkey'}); return true; case 'respond_to_author': // 'R': respond to author - respond_to_message({reply_type: "personal", trigger: 'hotkey pm'}); + compose.respond_to_message({reply_type: "personal", trigger: 'hotkey pm'}); return true; } diff --git a/static/js/popovers.js b/static/js/popovers.js index 3c93d80f7e..f77657d3af 100644 --- a/static/js/popovers.js +++ b/static/js/popovers.js @@ -459,13 +459,13 @@ exports.register_click_handlers = function () { }); $('body').on('click', '.respond_button', function (e) { - respond_to_message({trigger: 'popover respond'}); + compose.respond_to_message({trigger: 'popover respond'}); popovers.hide_actions_popover(); e.stopPropagation(); e.preventDefault(); }); $('body').on('click', '.respond_personal_button', function (e) { - respond_to_message({reply_type: 'personal', trigger: 'popover respond pm'}); + compose.respond_to_message({reply_type: 'personal', trigger: 'popover respond pm'}); popovers.hide_all(); e.stopPropagation(); e.preventDefault(); diff --git a/static/js/zulip.js b/static/js/zulip.js index 4aa7f2ebb2..923d624e8e 100644 --- a/static/js/zulip.js +++ b/static/js/zulip.js @@ -10,51 +10,6 @@ var current_msg_list = home_msg_list; var queued_mark_as_read = []; var queued_flag_timer; - -function respond_to_message(opts) { - var message, msg_type; - // Before initiating a reply to a message, if there's an - // in-progress composition, snapshot it. - compose.snapshot_message(); - - message = current_msg_list.selected_message(); - - if (message === undefined) { - return; - } - - unread.mark_message_as_read(message); - - var stream = ''; - var subject = ''; - if (message.type === "stream") { - stream = message.stream; - subject = message.subject; - } - - var pm_recipient = message.reply_to; - if (opts.reply_type === "personal" && message.type === "private") { - // reply_to for private messages is everyone involved, so for - // personals replies we need to set the the private message - // recipient to just the sender - pm_recipient = message.sender_email; - } - if (opts.reply_type === 'personal' || message.type === 'private') { - msg_type = 'private'; - } else { - msg_type = message.type; - } - compose.start(msg_type, {'stream': stream, 'subject': subject, - 'private_message_recipient': pm_recipient, - 'replying_to_message': message, - 'trigger': opts.trigger}); - -} - - - - - function consider_bankruptcy() { // Until we've handled possibly declaring bankruptcy, don't show // unread counts since they only consider messages that are loaded diff --git a/tools/jslint/check-all.js b/tools/jslint/check-all.js index bc09c4f93a..e7635f858e 100644 --- a/tools/jslint/check-all.js +++ b/tools/jslint/check-all.js @@ -54,7 +54,6 @@ var globals = // zulip.js + ' home_msg_list current_msg_list' - + ' respond_to_message' + ' process_loaded_for_unread' ;