mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 08:26:11 +00:00
Fix modals dependency cycle.
This commit forces the files that create modals to create their own modal closing function instead of creating all of them in the modals file. These functions are then passed to the modals.close object. This is intended to remove modals.js's dependencies on these other files.
This commit is contained in:
@@ -376,6 +376,12 @@ exports.launch = function () {
|
||||
};
|
||||
|
||||
$(function () {
|
||||
|
||||
function drafts_close_modal() {
|
||||
hashchange.exit_modal();
|
||||
}
|
||||
modals.set_close_handler("drafts", drafts_close_modal);
|
||||
|
||||
window.addEventListener("beforeunload", function () {
|
||||
exports.update_draft();
|
||||
});
|
||||
|
||||
@@ -133,6 +133,12 @@ $(function () {
|
||||
$('#streams_to_add :checkbox').prop('checked', false);
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
function invite_close_modal() {
|
||||
hashchange.exit_modal();
|
||||
}
|
||||
|
||||
modals.set_close_handler("invite", invite_close_modal);
|
||||
});
|
||||
|
||||
return exports;
|
||||
|
||||
@@ -183,6 +183,15 @@ $(function () {
|
||||
lightbox[direction]();
|
||||
}
|
||||
});
|
||||
|
||||
function lightbox_close_modal() {
|
||||
$(".player-container iframe").remove();
|
||||
lightbox.is_open = false;
|
||||
document.activeElement.blur();
|
||||
}
|
||||
|
||||
modals.set_close_handler("lightbox", lightbox_close_modal);
|
||||
|
||||
});
|
||||
|
||||
return exports;
|
||||
|
||||
@@ -2,32 +2,10 @@ var modals = (function () {
|
||||
"use strict";
|
||||
|
||||
var exports = {
|
||||
close: {
|
||||
subscriptions: function () {
|
||||
subs.close();
|
||||
},
|
||||
close : {},
|
||||
|
||||
drafts: function () {
|
||||
hashchange.exit_modal();
|
||||
},
|
||||
|
||||
informationalOverlays: function () {
|
||||
$(".informational-overlays").removeClass("show");
|
||||
},
|
||||
|
||||
settings: function () {
|
||||
hashchange.exit_modal();
|
||||
},
|
||||
|
||||
lightbox: function () {
|
||||
$(".player-container iframe").remove();
|
||||
lightbox.is_open = false;
|
||||
document.activeElement.blur();
|
||||
},
|
||||
|
||||
invite: function () {
|
||||
hashchange.exit_modal();
|
||||
},
|
||||
set_close_handler : function (name, handler) {
|
||||
exports.close[name] = handler;
|
||||
},
|
||||
|
||||
close_modal: function (name) {
|
||||
@@ -35,6 +13,8 @@ var modals = (function () {
|
||||
|
||||
if (exports.close[name]) {
|
||||
exports.close[name]();
|
||||
} else {
|
||||
blueslip.error("Modal close handler for " + name + " not properly setup." );
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -41,6 +41,11 @@ $("body").ready(function () {
|
||||
});
|
||||
|
||||
$("body").on("click", "[data-sidebar-form-close]", close_sidebar);
|
||||
|
||||
function settings_close_modal() {
|
||||
hashchange.exit_modal();
|
||||
}
|
||||
modals.set_close_handler("settings", settings_close_modal);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -1463,6 +1463,12 @@ $(function () {
|
||||
tr.remove();
|
||||
});
|
||||
|
||||
function subscriptions_close_modal() {
|
||||
exports.close();
|
||||
}
|
||||
|
||||
modals.set_close_handler("subscriptions", subscriptions_close_modal);
|
||||
|
||||
});
|
||||
|
||||
function focus_on_narrowed_stream() {
|
||||
|
||||
@@ -106,6 +106,13 @@ exports.show_failed_message_success = function (message_id) {
|
||||
};
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
function info_overlay_close_modal() {
|
||||
$(".informational-overlays").removeClass("show");
|
||||
}
|
||||
|
||||
modals.set_close_handler("informationalOverlays", info_overlay_close_modal);
|
||||
|
||||
var info_overlay_toggle = components.toggle({
|
||||
name: "info-overlay-toggle",
|
||||
selected: 0,
|
||||
|
||||
Reference in New Issue
Block a user