diff --git a/zephyr/static/js/compose.js b/zephyr/static/js/compose.js index 0b19212109..92c889d69e 100644 --- a/zephyr/static/js/compose.js +++ b/zephyr/static/js/compose.js @@ -183,7 +183,8 @@ exports.start = function (msg_type, opts) { message_type: msg_type, stream: '', subject: '', - private_message_recipient: '' + private_message_recipient: '', + trigger: 'unknown' }; // Set default parameters based on the current narrowed view. diff --git a/zephyr/static/js/hotkey.js b/zephyr/static/js/hotkey.js index 810f3d6c3a..f288ba9ee2 100644 --- a/zephyr/static/js/hotkey.js +++ b/zephyr/static/js/hotkey.js @@ -183,13 +183,13 @@ function process_hotkey(e) { compose.set_mode('private'); return true; case 13: // Enter: respond to message (unless we need to do something else) - respond_to_message(); + respond_to_message({trigger: 'hotkey enter'}); return true; case 114: // 'r': respond to message - respond_to_message(); + respond_to_message({trigger: 'hotkey'}); return true; case 82: // 'R': respond to author - respond_to_message("personal"); + respond_to_message({reply_type: "personal", trigger: 'hotkey pm'}); return true; case 47: // '/': initiate search search.initiate_search(); diff --git a/zephyr/static/js/ui.js b/zephyr/static/js/ui.js index d6108ec6be..3bb8326766 100644 --- a/zephyr/static/js/ui.js +++ b/zephyr/static/js/ui.js @@ -1052,7 +1052,7 @@ $(function () { // Was a click (not a click-and-drag). var row = $(this).closest(".message_row"); current_msg_list.select_id(rows.id(row)); - respond_to_message(); + respond_to_message({trigger: 'message click'}); e.stopPropagation(); } mouse_moved = false; @@ -1214,7 +1214,8 @@ $(function () { $('#user_presences').on('click', 'a', function (e) { var email = $(e.target).attr('data-email'); - compose.start('private', {private_message_recipient: email}); + compose.start('private', {private_message_recipient: email, + trigger: 'presence list'}); // The preventDefault is necessary so that clicking the // link doesn't jump us to the top of the page. e.preventDefault(); @@ -1286,11 +1287,11 @@ $(function () { }); $('.empty_feed_compose_stream').click(function (e) { - compose.start('stream'); + compose.start('stream', {trigger: 'empty feed message'}); return false; }); $('.empty_feed_compose_private').click(function (e) { - compose.start('private'); + compose.start('private', {trigger: 'empty feed message'}); return false; }); $('.empty_feed_join').click(function (e) { @@ -1301,12 +1302,14 @@ $(function () { // Keep these 2 feedback bot triggers separate because they have to // propagate the event differently. $('.feedback').click(function (e) { - compose.start('private', { 'private_message_recipient': 'feedback@humbughq.com' }); + compose.start('private', { 'private_message_recipient': 'feedback@humbughq.com', + trigger: 'feedback menu item' }); }); $('#feedback_button').click(function (e) { e.stopPropagation(); - compose.start('private', { 'private_message_recipient': 'feedback@humbughq.com' }); + compose.start('private', { 'private_message_recipient': 'feedback@humbughq.com', + trigger: 'feedback button' }); }); $('.logout_button').click(function (e) { @@ -1328,12 +1331,12 @@ $(function () { }); $('body').on('click', '.respond_button', function (e) { - respond_to_message(); + respond_to_message({trigger: 'popover respond'}); ui.hide_actions_popover(); e.stopPropagation(); }); $('body').on('click', '.respond_personal_button', function (e) { - respond_to_message('personal'); + respond_to_message({reply_type: 'personal', trigger: 'popover respond pm'}); ui.hide_actions_popover(); e.stopPropagation(); }); @@ -1419,7 +1422,7 @@ $(function () { $('body').on('click', '.compose_to_stream', function (e) { var stream = $(e.currentTarget).parents('ul').attr('data-name'); ui.hide_sidebar_popover(); - compose.start('stream', {"stream": stream}); + compose.start('stream', {"stream": stream, trigger: 'sidebar stream actions'}); e.stopPropagation(); }); diff --git a/zephyr/static/js/zephyr.js b/zephyr/static/js/zephyr.js index d7b5a9acb8..80d84c262c 100644 --- a/zephyr/static/js/zephyr.js +++ b/zephyr/static/js/zephyr.js @@ -170,7 +170,7 @@ function get_private_message_recipient(message, attr) { return recipient; } -function respond_to_message(reply_type) { +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. @@ -190,20 +190,21 @@ function respond_to_message(reply_type) { } var pm_recipient = message.reply_to; - if (reply_type === "personal" && message.type === "private") { + 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 (reply_type === 'personal' || message.type === 'private') { + 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}); + 'replying_to_message': message, + 'trigger': opts.trigger}); } // Returns messages from the given message list in the specified range, inclusive