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