hotkey: Add support for hotspots on enter.

This commit is contained in:
Jack Zhang 2017-08-01 19:46:56 -07:00 committed by Tim Abbott
parent 04fda9e51f
commit c69b5d7d65
3 changed files with 16 additions and 1 deletions

View File

@ -162,7 +162,9 @@ function stubbing(func_name_to_stub, test_function) {
set_global('emoji_picker', {
reactions_popped: return_false,
});
set_global('hotspots', {
is_open: return_false,
});
// All letters should return false if we are composing text.
hotkey.processing_text = return_true;

View File

@ -251,6 +251,11 @@ exports.process_enter_key = function (e) {
return true;
}
if (hotspots.is_open()) {
$(e.target).find('.hotspot.overlay.show .hotspot-confirm').click();
return false;
}
if (emoji_picker.reactions_popped()) {
if (emoji_picker.is_composition(e.target)) {
e.target.click();
@ -443,6 +448,10 @@ exports.process_hotkey = function (e, hotkey) {
return emoji_picker.navigate(e, event_name);
}
if (hotspots.is_open()) {
return false;
}
if (overlays.info_overlay_open()) {
return false;
}

View File

@ -247,6 +247,10 @@ function insert_hotspot_into_DOM(hotspot) {
}, (hotspot.delay * 100));
}
exports.is_open = function () {
return $('.hotspot.overlay').hasClass('show');
};
exports.load_new = function (new_hotspots) {
exports.map_hotspots_to_DOM(new_hotspots, HOTSPOT_LOCATIONS);
new_hotspots.forEach(insert_hotspot_into_DOM);