hardlounge/client/js/lounge.js

46 lines
1.1 KiB
JavaScript
Raw Normal View History

"use strict";
2016-12-18 15:53:28 +00:00
// vendor libraries
const $ = require("jquery");
2016-12-18 15:53:28 +00:00
// our libraries
2017-04-18 07:31:46 +00:00
const socket = require("./socket");
2018-07-08 14:57:02 +00:00
window.vueMounted = () => {
require("./socket-events");
2019-10-17 15:32:59 +00:00
require("./contextMenuFactory");
2018-07-08 14:57:02 +00:00
require("./webpush");
require("./keybinds");
window.addEventListener("popstate", (e) => {
const {state} = e;
if (!state) {
return;
}
2017-09-09 20:36:06 +00:00
let {clickTarget} = state;
if (clickTarget) {
2017-09-09 20:36:06 +00:00
// This will be true when click target corresponds to opening a thumbnail,
// browsing to the previous/next thumbnail, or closing the image viewer.
const imageViewerRelated = clickTarget.includes(".toggle-thumbnail");
2017-09-09 20:36:06 +00:00
// If the click target is not related to the image viewer but the viewer
// is currently opened, we need to close it.
if (!imageViewerRelated && $("#image-viewer").hasClass("opened")) {
clickTarget += ", #image-viewer";
}
// Emit the click to the target, while making sure it is not going to be
// added to the state again.
$(clickTarget).trigger("click", {
pushState: false,
});
}
});
// Only start opening socket.io connection after all events have been registered
socket.open();
2018-07-08 14:57:02 +00:00
};