2018-03-30 14:09:11 +02:00
|
|
|
var info_overlay = (function () {
|
|
|
|
|
|
|
|
var exports = {};
|
|
|
|
|
2018-04-13 22:48:20 +02:00
|
|
|
// Make it explicit that our toggler is undefined until
|
2018-06-04 14:51:21 +02:00
|
|
|
// set_up_toggler is called.
|
2018-04-13 22:48:20 +02:00
|
|
|
exports.toggler = undefined;
|
|
|
|
|
2018-06-04 14:51:21 +02:00
|
|
|
exports.set_up_toggler = function () {
|
2018-04-04 17:01:34 +02:00
|
|
|
var opts = {
|
2018-03-30 14:09:11 +02:00
|
|
|
selected: 0,
|
2018-04-04 17:01:34 +02:00
|
|
|
child_wants_focus: true,
|
2018-03-30 14:09:11 +02:00
|
|
|
values: [
|
|
|
|
{ label: i18n.t("Keyboard shortcuts"), key: "keyboard-shortcuts" },
|
2018-08-29 19:15:25 +02:00
|
|
|
{ label: i18n.t("Message formatting"), key: "message-formatting" },
|
2018-03-30 14:09:11 +02:00
|
|
|
{ label: i18n.t("Search operators"), key: "search-operators" },
|
|
|
|
],
|
|
|
|
callback: function (name, key) {
|
|
|
|
$(".overlay-modal").hide();
|
|
|
|
$("#" + key).show();
|
|
|
|
$("#" + key).find(".modal-body").focus();
|
|
|
|
},
|
2018-04-04 17:01:34 +02:00
|
|
|
};
|
2018-03-30 14:09:11 +02:00
|
|
|
|
2018-04-04 17:01:34 +02:00
|
|
|
var toggler = components.toggle(opts);
|
|
|
|
var elem = toggler.get();
|
2019-06-03 16:04:02 +02:00
|
|
|
elem.addClass('large allow-overflow');
|
2018-04-04 17:01:34 +02:00
|
|
|
|
|
|
|
var modals = _.map(opts.values, function (item) {
|
2018-08-29 19:15:25 +02:00
|
|
|
var key = item.key; // e.g. message-formatting
|
2018-04-04 17:01:34 +02:00
|
|
|
var modal = $('#' + key).find('.modal-body');
|
|
|
|
return modal;
|
|
|
|
});
|
|
|
|
|
|
|
|
_.each(modals, function (modal) {
|
|
|
|
keydown_util.handle({
|
|
|
|
elem: modal,
|
|
|
|
handlers: {
|
|
|
|
left_arrow: toggler.maybe_go_left,
|
|
|
|
right_arrow: toggler.maybe_go_right,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$(".informational-overlays .overlay-tabs").append(elem);
|
2018-03-30 14:09:11 +02:00
|
|
|
|
2019-06-07 11:03:13 +02:00
|
|
|
common.adjust_mac_shortcuts(".hotkeys_table .hotkey kbd");
|
2019-05-07 09:26:25 +02:00
|
|
|
common.adjust_mac_shortcuts("#markdown-instructions kbd");
|
2018-04-13 22:48:20 +02:00
|
|
|
|
|
|
|
exports.toggler = toggler;
|
2018-05-30 18:09:17 +02:00
|
|
|
};
|
2018-03-30 14:09:11 +02:00
|
|
|
|
|
|
|
exports.show = function (target) {
|
2018-06-04 14:51:21 +02:00
|
|
|
if (!exports.toggler) {
|
|
|
|
exports.set_up_toggler();
|
|
|
|
}
|
|
|
|
|
2018-03-30 14:09:11 +02:00
|
|
|
var overlay = $(".informational-overlays");
|
|
|
|
|
|
|
|
if (!overlay.hasClass("show")) {
|
|
|
|
overlays.open_overlay({
|
2018-12-18 19:34:45 +01:00
|
|
|
name: 'informationalOverlays',
|
2018-03-30 14:09:11 +02:00
|
|
|
overlay: overlay,
|
|
|
|
on_close: function () {
|
|
|
|
hashchange.changehash("");
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (target) {
|
2018-06-04 14:51:21 +02:00
|
|
|
exports.toggler.goto(target);
|
2018-03-30 14:09:11 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.maybe_show_keyboard_shortcuts = function () {
|
|
|
|
if (overlays.is_active()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (popovers.any_active()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
exports.show("keyboard-shortcuts");
|
|
|
|
};
|
|
|
|
|
|
|
|
return exports;
|
|
|
|
}());
|
|
|
|
|
|
|
|
if (typeof module !== 'undefined') {
|
|
|
|
module.exports = info_overlay;
|
|
|
|
}
|
2018-05-28 08:04:36 +02:00
|
|
|
window.info_overlay = info_overlay;
|