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