2017-03-18 09:21:18 +00:00
|
|
|
"use strict";
|
|
|
|
|
2016-12-18 15:53:28 +00:00
|
|
|
// vendor libraries
|
2017-03-18 09:21:18 +00:00
|
|
|
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");
|
2016-10-09 19:14:02 +00:00
|
|
|
|
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");
|
|
|
|
|
2017-04-08 12:34:31 +00:00
|
|
|
window.addEventListener("popstate", (e) => {
|
|
|
|
const {state} = e;
|
2018-02-20 07:28:04 +00:00
|
|
|
|
2017-04-08 12:34:31 +00:00
|
|
|
if (!state) {
|
|
|
|
return;
|
2017-01-28 17:48:34 +00:00
|
|
|
}
|
2017-04-08 12:34:31 +00:00
|
|
|
|
2017-09-09 20:36:06 +00:00
|
|
|
let {clickTarget} = state;
|
|
|
|
|
2017-04-08 12:34:31 +00:00
|
|
|
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.
|
2017-09-10 19:00:27 +00:00
|
|
|
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.
|
2017-04-08 12:34:31 +00:00
|
|
|
$(clickTarget).trigger("click", {
|
2017-11-15 06:35:15 +00:00
|
|
|
pushState: false,
|
2017-04-08 12:34:31 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2017-08-28 09:18:31 +00:00
|
|
|
|
|
|
|
// Only start opening socket.io connection after all events have been registered
|
|
|
|
socket.open();
|
2018-07-08 14:57:02 +00:00
|
|
|
};
|