mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
client+server: implement code autoformatting using prettier and black
This commit is contained in:
@ -1,36 +1,38 @@
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
const settings = require('../models/settings.js');
|
||||
const views = require('../util/views.js');
|
||||
const optimizedResize = require('../util/optimized_resize.js');
|
||||
const settings = require("../models/settings.js");
|
||||
const views = require("../util/views.js");
|
||||
const optimizedResize = require("../util/optimized_resize.js");
|
||||
|
||||
class PostContentControl {
|
||||
constructor(hostNode, post, viewportSizeCalculator, fitFunctionOverride) {
|
||||
this._post = post;
|
||||
this._viewportSizeCalculator = viewportSizeCalculator;
|
||||
this._hostNode = hostNode;
|
||||
this._template = views.getTemplate('post-content');
|
||||
this._template = views.getTemplate("post-content");
|
||||
|
||||
let fitMode = settings.get().fitMode;
|
||||
if (typeof fitFunctionOverride !== 'undefined') {
|
||||
if (typeof fitFunctionOverride !== "undefined") {
|
||||
fitMode = fitFunctionOverride;
|
||||
}
|
||||
|
||||
this._currentFitFunction = {
|
||||
'fit-both': this.fitBoth,
|
||||
'fit-original': this.fitOriginal,
|
||||
'fit-width': this.fitWidth,
|
||||
'fit-height': this.fitHeight,
|
||||
}[fitMode] || this.fitBoth;
|
||||
this._currentFitFunction =
|
||||
{
|
||||
"fit-both": this.fitBoth,
|
||||
"fit-original": this.fitOriginal,
|
||||
"fit-width": this.fitWidth,
|
||||
"fit-height": this.fitHeight,
|
||||
}[fitMode] || this.fitBoth;
|
||||
|
||||
this._install();
|
||||
|
||||
this._post.addEventListener(
|
||||
'changeContent', e => this._evtPostContentChange(e));
|
||||
this._post.addEventListener("changeContent", (e) =>
|
||||
this._evtPostContentChange(e)
|
||||
);
|
||||
}
|
||||
|
||||
disableOverlay() {
|
||||
this._hostNode.querySelector('.post-overlay').style.display = 'none';
|
||||
this._hostNode.querySelector(".post-overlay").style.display = "none";
|
||||
}
|
||||
|
||||
fitWidth() {
|
||||
@ -92,10 +94,11 @@ class PostContentControl {
|
||||
|
||||
_resize(width, height) {
|
||||
const resizeListenerNodes = [this._postContentNode].concat(
|
||||
...this._postContentNode.querySelectorAll('.resize-listener'));
|
||||
...this._postContentNode.querySelectorAll(".resize-listener")
|
||||
);
|
||||
for (let node of resizeListenerNodes) {
|
||||
node.style.width = width + 'px';
|
||||
node.style.height = height + 'px';
|
||||
node.style.width = width + "px";
|
||||
node.style.height = height + "px";
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,10 +109,9 @@ class PostContentControl {
|
||||
_install() {
|
||||
this._reinstall();
|
||||
optimizedResize.add(() => this._refreshSize());
|
||||
views.monitorNodeRemoval(
|
||||
this._hostNode, () => {
|
||||
this._uninstall();
|
||||
});
|
||||
views.monitorNodeRemoval(this._hostNode, () => {
|
||||
this._uninstall();
|
||||
});
|
||||
}
|
||||
|
||||
_reinstall() {
|
||||
@ -118,7 +120,7 @@ class PostContentControl {
|
||||
autoplay: settings.get().autoplayVideos,
|
||||
});
|
||||
if (settings.get().transparencyGrid) {
|
||||
newNode.classList.add('transparency-grid');
|
||||
newNode.classList.add("transparency-grid");
|
||||
}
|
||||
if (this._postContentNode) {
|
||||
this._hostNode.replaceChild(newNode, this._postContentNode);
|
||||
|
Reference in New Issue
Block a user