Remove lightbox.is_open property.

Outside of lightbox.js, we now use modals.lightbox_open() to
detect that the lightbox modal is open.
This commit is contained in:
Steve Howell
2017-05-10 06:43:36 -07:00
committed by Tim Abbott
parent 1d7f93e550
commit f60a829b4d
4 changed files with 11 additions and 21 deletions

View File

@@ -307,6 +307,7 @@ function stubbing(func_name_to_stub, test_function) {
global.drafts.drafts_overlay_open = return_false;
modals.settings_open = return_false;
hotkey.is_subs = return_false;
modals.lightbox_open = return_false;
assert_unmapped('down_arrow');
assert_unmapped('end');
@@ -341,10 +342,10 @@ function stubbing(func_name_to_stub, test_function) {
assert_mapping('down_arrow', 'subs.switch_rows');
hotkey.is_subs = return_false;
hotkey.is_lightbox_open = return_true;
modals.lightbox_open = return_true;
assert_mapping('left_arrow', 'lightbox.prev');
assert_mapping('right_arrow', 'lightbox.next');
hotkey.is_lightbox_open = return_false;
modals.lightbox_open = return_false;
hotkey.is_editing_stream_name = return_true;
assert_unmapped('down_arrow');

View File

@@ -25,10 +25,6 @@ function open_reactions() {
return true;
}
exports.is_lightbox_open = function () {
return lightbox.is_open;
};
exports.is_subs = function () {
return subs.is_open;
};
@@ -497,7 +493,7 @@ exports.process_hotkey = function (e, hotkey) {
}
if (event_name === 'left_arrow') {
if (exports.is_lightbox_open()) {
if (modals.lightbox_open()) {
lightbox.prev();
return true;
} else if (exports.is_subs()) {
@@ -510,7 +506,7 @@ exports.process_hotkey = function (e, hotkey) {
}
if (event_name === 'right_arrow') {
if (exports.is_lightbox_open()) {
if (modals.lightbox_open()) {
lightbox.next();
return true;
} else if (exports.is_subs()) {

View File

@@ -107,7 +107,7 @@ exports.open = function (image) {
function lightbox_close_modal() {
$(".player-container iframe").remove();
lightbox.is_open = false;
is_open = false;
document.activeElement.blur();
}
@@ -118,7 +118,7 @@ exports.open = function (image) {
});
popovers.hide_all();
lightbox.is_open = true;
is_open = true;
};
exports.show_from_selected_message = function () {
@@ -136,17 +136,6 @@ exports.next = function () {
$(".image-list .image.selected").next().click();
};
Object.defineProperty(exports, "is_open", {
get: function () {
return is_open;
},
set: function (value) {
if (typeof value === "boolean") {
is_open = value;
}
},
});
// this is a block of events that are required for the lightbox to work.
$(function () {
$("#main_div").on("click", ".message_inline_image a", function (e) {

View File

@@ -24,6 +24,10 @@ exports.settings_open = function () {
return open_modal_name === 'settings';
};
exports.lightbox_open = function () {
return open_modal_name === 'lightbox';
};
exports.open_overlay = function (opts) {
if (!opts.name || !opts.overlay || !opts.on_close) {
blueslip.error('Programming error in open_modal');