diff --git a/.eslintrc.json b/.eslintrc.json index 8d2b100c1d..bfd8ca2d7a 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -25,6 +25,7 @@ "popovers": false, "server_events": false, "ui": false, + "ui_state": false, "lightbox": false, "stream_color": false, "people": false, diff --git a/frontend_tests/node_tests/hotkey.js b/frontend_tests/node_tests/hotkey.js index 8144e71203..685dbc08b7 100644 --- a/frontend_tests/node_tests/hotkey.js +++ b/frontend_tests/node_tests/hotkey.js @@ -116,7 +116,7 @@ function stubbing(func_name_to_stub, test_function) { _.each([return_true, return_false], function (is_settings_page) { _.each([return_true, return_false], function (home_tab_obscured) { hotkey.is_settings_page = is_settings_page; - set_global('ui', {home_tab_obscured: home_tab_obscured}); + set_global('ui_state', {home_tab_obscured: home_tab_obscured}); test_normal_typing(); }); diff --git a/static/js/click_handlers.js b/static/js/click_handlers.js index a24baa244d..5ba3f7c92b 100644 --- a/static/js/click_handlers.js +++ b/static/js/click_handlers.js @@ -272,7 +272,7 @@ $(function () { }); $(".brand").on('click', function (e) { - if (ui.home_tab_obscured()) { + if (ui_state.home_tab_obscured()) { ui.change_tab_to('#home'); } else { narrow.restore_home_state(); diff --git a/static/js/hotkey.js b/static/js/hotkey.js index d5167163b3..4af2eb6546 100644 --- a/static/js/hotkey.js +++ b/static/js/hotkey.js @@ -379,7 +379,7 @@ exports.process_hotkey = function (e, hotkey) { return exports.process_shift_tab_key(); } - if (hotkey.message_view_only && ui.home_tab_obscured()) { + if (hotkey.message_view_only && ui_state.home_tab_obscured()) { return false; } diff --git a/static/js/narrow.js b/static/js/narrow.js index 3b0f34a24f..51318039a6 100644 --- a/static/js/narrow.js +++ b/static/js/narrow.js @@ -530,7 +530,7 @@ exports.restore_home_state = function () { // If we click on the Home link from another nav pane, just go // back to the state you were in (possibly still narrowed) before // you left the Home pane. - if (!ui.home_tab_obscured()) { + if (!ui_state.home_tab_obscured()) { exports.deactivate(); } navigate.maybe_scroll_to_selected(); diff --git a/static/js/shim.js b/static/js/shim.js index 244ceb4b18..ef073fc0d5 100644 --- a/static/js/shim.js +++ b/static/js/shim.js @@ -13,6 +13,9 @@ var compose_actions = {}; compose_actions.start = compose.start; compose_actions.cancel = compose.cancel; +var ui_state = {}; +ui_state.home_tab_obscured = ui.home_tab_obscured; + var compose_state = {}; compose_state.has_message_content = compose.has_message_content; compose_state.recipient = compose.recipient; diff --git a/static/js/stream_list.js b/static/js/stream_list.js index 45452cf127..261aa5af71 100644 --- a/static/js/stream_list.js +++ b/static/js/stream_list.js @@ -473,7 +473,7 @@ $(function () { if (e.metaKey || e.ctrlKey) { return; } - if (ui.home_tab_obscured()) { + if (ui_state.home_tab_obscured()) { ui.change_tab_to('#home'); } var stream = $(e.target).parents('li').attr('data-name'); @@ -534,7 +534,7 @@ function maybe_select_stream(e) { var topStream = $('#stream_filters li.narrow-filter').first().data('name'); if (topStream !== undefined) { // undefined if there are no results - if (ui.home_tab_obscured()) { + if (ui_state.home_tab_obscured()) { ui.change_tab_to('#home'); } exports.clear_and_hide_search(); diff --git a/static/js/subs.js b/static/js/subs.js index 7146d0180d..1ce9059829 100644 --- a/static/js/subs.js +++ b/static/js/subs.js @@ -132,7 +132,7 @@ function update_in_home_view(sub, value) { var msg_offset; var saved_ypos; // Save our current scroll position - if (ui.home_tab_obscured()) { + if (ui_state.home_tab_obscured()) { saved_ypos = message_viewport.scrollTop(); } else if (home_msg_list === current_msg_list && current_msg_list.selected_row().offset() !== null) { @@ -145,7 +145,7 @@ function update_in_home_view(sub, value) { message_store.add_messages(message_list.all.all_messages(), home_msg_list); // Ensure we're still at the same scroll position - if (ui.home_tab_obscured()) { + if (ui_state.home_tab_obscured()) { message_viewport.scrollTop(saved_ypos); } else if (home_msg_list === current_msg_list) { // We pass use_closest to handle the case where the diff --git a/static/js/topic_list.js b/static/js/topic_list.js index 500da19524..5e460281d6 100644 --- a/static/js/topic_list.js +++ b/static/js/topic_list.js @@ -210,7 +210,7 @@ exports.set_click_handlers = function (callbacks) { // In a more componentized world, we would delegate some // of this stuff back up to our parents. - if (ui.home_tab_obscured()) { + if (ui_state.home_tab_obscured()) { ui.change_tab_to('#home'); } diff --git a/static/js/tutorial.js b/static/js/tutorial.js index 09b82f2ad4..477f433002 100644 --- a/static/js/tutorial.js +++ b/static/js/tutorial.js @@ -504,7 +504,7 @@ function welcome() { } exports.start = function () { - if (ui.home_tab_obscured()) { + if (ui_state.home_tab_obscured()) { ui.change_tab_to('#home'); } narrow.deactivate(); diff --git a/static/js/ui_init.js b/static/js/ui_init.js index 1f400d2667..a026cd2937 100644 --- a/static/js/ui_init.js +++ b/static/js/ui_init.js @@ -68,7 +68,7 @@ $(function () { }); message_viewport.message_pane.mousewheel(function (e, delta) { - if (!ui.home_tab_obscured()) { + if (!ui_state.home_tab_obscured()) { // In the message view, we use a throttled mousewheel handler. throttled_mousewheelhandler(e, delta); }