From 582cb799dd0ce78235b1620ce631a45c4753e2ce Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Fri, 26 Oct 2012 20:58:21 -0400 Subject: [PATCH] Get rid of the selected_message_class global Instead we infer this from narrow.active(), with the ability to override during the narrowing procedure. (imported from commit fab9c6861f19aedf0ee8af094c1ef4e8a0a73d80) --- tools/jslint/check-all.js | 2 +- zephyr/static/js/narrow.js | 7 ++++--- zephyr/static/js/zephyr.js | 12 ++++++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/tools/jslint/check-all.js b/tools/jslint/check-all.js index 64c34c6134..fd49ce099a 100644 --- a/tools/jslint/check-all.js +++ b/tools/jslint/check-all.js @@ -38,7 +38,7 @@ var globals = + ' update_autocomplete autocomplete_needs_update' // zephyr.js - + ' message_array message_dict selected_message_class' + + ' message_array message_dict' + ' clear_table add_to_table subject_dict' + ' keep_pointer_in_view move_pointer_at_page_top_and_bottom' + ' respond_to_message' diff --git a/zephyr/static/js/narrow.js b/zephyr/static/js/narrow.js index cb7e31d53c..0d8211e990 100644 --- a/zephyr/static/js/narrow.js +++ b/zephyr/static/js/narrow.js @@ -32,6 +32,8 @@ exports.narrowing_type = function () { }; function do_narrow(icon, description, filter_function) { + var was_narrowed = exports.active(); + narrowed = filter_function; // Your pointer isn't changed when narrowed. @@ -58,8 +60,8 @@ function do_narrow(icon, description, filter_function) { // Indicate both which message is persistently selected and which // is temporarily selected select_message_by_id(selected_message_id, - {then_scroll: false, update_server: false}); - selected_message_class = "narrowed_selected_message"; + {then_scroll: false, update_server: false, + for_narrow: was_narrowed}); select_message_by_id(target_id, {then_scroll: true, update_server: false}); @@ -154,7 +156,6 @@ exports.show_all_messages = function () { $("#searchbox").removeClass('narrowed_view'); $("#show_all_messages").attr("disabled", "disabled"); $("#currently_narrowed_to").html(""); - selected_message_class = "selected_message"; // Includes scrolling. select_message_by_id(persistent_message_id, {then_scroll: true}); diff --git a/zephyr/static/js/zephyr.js b/zephyr/static/js/zephyr.js index a2df2b422b..3726ad90f9 100644 --- a/zephyr/static/js/zephyr.js +++ b/zephyr/static/js/zephyr.js @@ -3,7 +3,6 @@ var message_dict = {}; var subject_dict = {}; var people_hash = {}; -var selected_message_class = 'selected_message'; var viewport = $(window); var reloading_app = false; @@ -188,9 +187,14 @@ function send_pointer_update() { $(setTimeout(send_pointer_update, 1000)); function update_selected_message(message, opts) { - opts = $.extend({}, {update_server: true}, opts); - $('.' + selected_message_class).removeClass(selected_message_class); - message.addClass(selected_message_class); + opts = $.extend({}, { + update_server: true, + for_narrow: narrow.active() + }, opts); + + var cls = opts.for_narrow ? 'narrowed_selected_message' : 'selected_message'; + $('.' + cls).removeClass(cls); + message.addClass(cls); var new_selected_id = rows.id(message); if (opts.update_server && !narrow.active()