Skip to content

Commit

Permalink
ui-refactor: Rename modals.js to overlays.js.
Browse files Browse the repository at this point in the history
Fixed zulip#4702.
  • Loading branch information
aero31aero authored and timabbott committed May 29, 2017
1 parent 1f4e1ec commit 2d73e03
Show file tree
Hide file tree
Showing 21 changed files with 87 additions and 87 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"compose_actions": false,
"compose_state": false,
"compose_fade": false,
"modals": false,
"overlays": false,
"stream_create": false,
"stream_edit": false,
"subs": false,
Expand Down
44 changes: 22 additions & 22 deletions frontend_tests/node_tests/hotkey.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// The way the Zulip hotkey tests work is as follows. First, we set
// up various contexts by monkey-patching the various hotkeys exports
// functions (like modals.settings_open). Within that context, to
// functions (like overlays.settings_open). Within that context, to
// test whether a given key (e.g. `x`) results in a specific function
// (e.g. `ui.foo()`), we fail to import any modules other than
// hotkey.js so that accessing them will result in a ReferenceError.
Expand All @@ -17,7 +17,7 @@ set_global('activity', {
set_global('drafts', {
});

set_global('modals', {
set_global('overlays', {
});

set_global('reactions', {
Expand Down Expand Up @@ -158,7 +158,7 @@ function stubbing(func_name_to_stub, test_function) {
// We have to skip some checks due to the way the code is
// currently organized for mapped keys.
hotkey.is_editing_stream_name = return_false;
modals.settings_open = return_false;
overlays.settings_open = return_false;

set_global('popovers', {
actions_popped: return_false,
Expand All @@ -182,7 +182,7 @@ function stubbing(func_name_to_stub, test_function) {
_.each([return_true, return_false], function (settings_open) {
_.each([return_true, return_false], function (is_active) {
_.each([return_true, return_false], function (info_overlay_open) {
set_global('modals', {
set_global('overlays', {
is_active: is_active,
settings_open: settings_open,
info_overlay_open: info_overlay_open});
Expand All @@ -194,15 +194,15 @@ function stubbing(func_name_to_stub, test_function) {

// Ok, now test keys that work when we're viewing messages.
hotkey.processing_text = return_false;
modals.settings_open = return_false;
overlays.settings_open = return_false;

modals.streams_open = return_true;
modals.is_active = return_true;
overlays.streams_open = return_true;
overlays.is_active = return_true;
assert_mapping('S', 'subs.keyboard_sub');
modals.is_active = return_false;
overlays.is_active = return_false;
assert_mapping('V', 'subs.view_stream');
assert_mapping('n', 'subs.new_stream_clicked');
modals.streams_open = return_false;
overlays.streams_open = return_false;

assert_mapping('?', 'ui.show_info_overlay');
assert_mapping('/', 'search.initiate_search');
Expand All @@ -228,9 +228,9 @@ function stubbing(func_name_to_stub, test_function) {
global.current_msg_list.empty = return_false;

// Check that they do nothing while in the settings overlay
modals.settings_open = return_true;
overlays.settings_open = return_true;
assert_unmapped('@*+rRjJkKsSvi:GM');
modals.settings_open = return_false;
overlays.settings_open = return_false;

// TODO: Similar check for being in the subs page

Expand Down Expand Up @@ -307,9 +307,9 @@ function stubbing(func_name_to_stub, test_function) {
list_util.inside_list = return_false;
global.current_msg_list.empty = return_true;
global.drafts.drafts_overlay_open = return_false;
modals.settings_open = return_false;
modals.streams_open = return_false;
modals.lightbox_open = return_false;
overlays.settings_open = return_false;
overlays.streams_open = return_false;
overlays.lightbox_open = return_false;

assert_unmapped('down_arrow');
assert_unmapped('end');
Expand All @@ -334,27 +334,27 @@ function stubbing(func_name_to_stub, test_function) {
assert_mapping('spacebar', 'navigate.page_down');
assert_mapping('up_arrow', 'navigate.up');

modals.info_overlay_open = return_true;
overlays.info_overlay_open = return_true;
assert_unmapped('down_arrow');
assert_unmapped('up_arrow');
modals.info_overlay_open = return_false;
overlays.info_overlay_open = return_false;

modals.streams_open = return_true;
overlays.streams_open = return_true;
assert_mapping('up_arrow', 'subs.switch_rows');
assert_mapping('down_arrow', 'subs.switch_rows');
modals.streams_open = return_false;
overlays.streams_open = return_false;

modals.lightbox_open = return_true;
overlays.lightbox_open = return_true;
assert_mapping('left_arrow', 'lightbox.prev');
assert_mapping('right_arrow', 'lightbox.next');
modals.lightbox_open = return_false;
overlays.lightbox_open = return_false;

hotkey.is_editing_stream_name = return_true;
assert_unmapped('down_arrow');
assert_unmapped('up_arrow');
hotkey.is_editing_stream_name = return_false;

modals.settings_open = return_true;
overlays.settings_open = return_true;
assert_unmapped('end');
assert_unmapped('home');
assert_unmapped('left_arrow');
Expand All @@ -364,7 +364,7 @@ function stubbing(func_name_to_stub, test_function) {

assert_mapping('up_arrow', 'settings.handle_up_arrow');
assert_mapping('down_arrow', 'settings.handle_down_arrow');
modals.settings_open = return_false;
overlays.settings_open = return_false;

global.drafts.drafts_overlay_open = return_true;
assert_mapping('up_arrow', 'drafts.drafts_handle_events');
Expand Down
2 changes: 1 addition & 1 deletion static/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ exports.launch_page = function (tab) {
$(".sidebar .ind-tab[data-tab-key='organization']").click();
}

modals.open_settings();
overlays.open_settings();
$active_tab.click();
};

Expand Down
4 changes: 2 additions & 2 deletions static/js/click_handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ $(function () {
});

$(".brand").on('click', function (e) {
if (modals.is_active()) {
if (overlays.is_active()) {
ui_util.change_tab_to('#home');
} else {
narrow.restore_home_state();
Expand Down Expand Up @@ -599,7 +599,7 @@ $(function () {
}

// Unfocus our compose area if we click out of it. Don't let exits out
// of modals or selecting text (for copy+paste) trigger cancelling.
// of overlays or selecting text (for copy+paste) trigger cancelling.
if (compose_state.composing() && !$(e.target).is("a") &&
($(e.target).closest(".modal").length === 0) &&
window.getSelection().toString() === "" &&
Expand Down
6 changes: 3 additions & 3 deletions static/js/drafts.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ exports.restore_draft = function (draft_id) {
draft_copy);
}

modals.close_modal("drafts");
overlays.close_overlay("drafts");
compose_fade.clear_compose();
if (draft.type === "stream" && draft.stream === "") {
draft_copy.subject = "";
Expand Down Expand Up @@ -354,15 +354,15 @@ exports.drafts_handle_events = function (e, event_key) {

exports.toggle = function () {
if (exports.drafts_overlay_open()) {
modals.close_modal("drafts");
overlays.close_overlay("drafts");
} else {
exports.launch();
}
};

exports.launch = function () {
exports.setup_page(function () {
modals.open_overlay({
overlays.open_overlay({
name: 'drafts',
overlay: $('#draft_overlay'),
on_close: function () {
Expand Down
4 changes: 2 additions & 2 deletions static/js/hashchange.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ function hashchanged(from_reload, e) {

if (!should_ignore(old_hash || "#") || ignore.group !== get_hash_group(base)) {
if (ignore.group !== get_hash_group(base)) {
modals.close_for_hash_change();
overlays.close_for_hash_change();
}

// now only if the previous one should not have been ignored.
Expand All @@ -267,7 +267,7 @@ function hashchanged(from_reload, e) {
subs.change_state(get_hash_components());
}
} else if (!should_ignore(window.location.hash) && !ignore.flag) {
modals.close_for_hash_change();
overlays.close_for_hash_change();
changing_hash = true;
var ret = do_hashchange(from_reload);
changing_hash = false;
Expand Down
30 changes: 15 additions & 15 deletions static/js/hotkey.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ exports.process_escape_key = function (e) {
return false;
}

if (modals.is_active()) {
modals.close_active();
if (overlays.is_active()) {
overlays.close_active();
return true;
}

Expand Down Expand Up @@ -268,13 +268,13 @@ exports.process_enter_key = function (e) {
return true;
}

if (modals.settings_open()) {
if (overlays.settings_open()) {
// On the settings page just let the browser handle
// the enter key for things like submitting forms.
return false;
}

if (modals.streams_open()) {
if (overlays.streams_open()) {
return false;
}

Expand Down Expand Up @@ -416,18 +416,18 @@ exports.process_hotkey = function (e, hotkey) {
}
}

if (hotkey.message_view_only && modals.is_active()) {
if (hotkey.message_view_only && overlays.is_active()) {
if (exports.processing_text()) {
return false;
}
if (event_name === 'narrow_by_subject' && modals.streams_open()) {
if (event_name === 'narrow_by_subject' && overlays.streams_open()) {
subs.keyboard_sub();
return true;
}
return false;
}

if (modals.settings_open()) {
if (overlays.settings_open()) {
if (exports.processing_text()) {
return false;
}
Expand All @@ -446,11 +446,11 @@ exports.process_hotkey = function (e, hotkey) {
return reactions.reaction_navigate(e, event_name);
}

if (modals.info_overlay_open()) {
if (overlays.info_overlay_open()) {
return false;
}

if ((event_name === 'up_arrow' || event_name === 'down_arrow') && modals.streams_open()) {
if ((event_name === 'up_arrow' || event_name === 'down_arrow') && overlays.streams_open()) {
return subs.switch_rows(event_name);
}

Expand Down Expand Up @@ -516,10 +516,10 @@ exports.process_hotkey = function (e, hotkey) {
}

if (event_name === 'left_arrow') {
if (modals.lightbox_open()) {
if (overlays.lightbox_open()) {
lightbox.prev();
return true;
} else if (modals.streams_open()) {
} else if (overlays.streams_open()) {
subs.toggle_view(event_name);
return true;
}
Expand All @@ -529,10 +529,10 @@ exports.process_hotkey = function (e, hotkey) {
}

if (event_name === 'right_arrow') {
if (modals.lightbox_open()) {
if (overlays.lightbox_open()) {
lightbox.next();
return true;
} else if (modals.streams_open()) {
} else if (overlays.streams_open()) {
subs.toggle_view(event_name);
return true;
}
Expand Down Expand Up @@ -572,12 +572,12 @@ exports.process_hotkey = function (e, hotkey) {
navigate.cycle_stream('forward');
return true;
case 'view_selected_stream':
if (modals.streams_open()) {
if (overlays.streams_open()) {
subs.view_stream();
}
return true;
case 'n_key':
if (modals.streams_open()) {
if (overlays.streams_open()) {
subs.new_stream_clicked();
} else {
narrow.narrow_to_next_topic();
Expand Down
2 changes: 1 addition & 1 deletion static/js/invite.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ exports.initialize = function () {
},
});

modals.open_overlay({
overlays.open_overlay({
name: 'invite',
overlay: $('#invite-user'),
on_close: function () {
Expand Down
6 changes: 3 additions & 3 deletions static/js/lightbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,16 @@ exports.open = function (image) {
return;
}

function lightbox_close_modal() {
function lightbox_close_overlay() {
$(".player-container iframe").remove();
is_open = false;
document.activeElement.blur();
}

modals.open_overlay({
overlays.open_overlay({
name: 'lightbox',
overlay: $("#lightbox_overlay"),
on_close: lightbox_close_modal,
on_close: lightbox_close_overlay,
});

popovers.hide_all();
Expand Down
2 changes: 1 addition & 1 deletion static/js/narrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,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 (!modals.is_active()) {
if (!overlays.is_active()) {
exports.deactivate();
}
navigate.maybe_scroll_to_selected();
Expand Down
Loading

0 comments on commit 2d73e03

Please sign in to comment.