diff options
Diffstat (limited to 'static')
-rw-r--r-- | static/fluoride.js | 93 | ||||
-rw-r--r-- | static/style.css | 37 |
2 files changed, 112 insertions, 18 deletions
diff --git a/static/fluoride.js b/static/fluoride.js index 6f14f86..e6624d1 100644 --- a/static/fluoride.js +++ b/static/fluoride.js @@ -7,6 +7,8 @@ var reverseActions = { "unretweet": "retweet" }; +var statusCache = {}; + var csrfToken = ""; var antiDopamineMode = false; @@ -33,11 +35,12 @@ function http(method, url, body, type, success, error) { }; req.onerror = function() { if (typeof error === "function") { - error(this.responseText); + error(this); } }; req.open(method, url); - req.setRequestHeader("Content-Type", type); + if (type) + req.setRequestHeader("Content-Type", type); req.send(body); } @@ -132,7 +135,7 @@ function isInView(el) { return false; } -function handleReplyToLink(a) { +function replyToLinkLocal(a) { if (!a) return; var id = a.getAttribute("href"); @@ -149,6 +152,7 @@ function handleReplyToLink(a) { var copy = status.cloneNode(true); copy.id = "reply-to-popup"; var ract = event.target.getBoundingClientRect(); + copy.style["max-width"] = (window.innerWidth - ract.left - 32) + "px"; if (ract.top > window.innerHeight / 2) { copy.style.bottom = (window.innerHeight - window.scrollY - ract.top) + "px"; @@ -168,6 +172,68 @@ function handleReplyToLink(a) { } } +var inMouseEnter = false; +function replyToLinkRemote(a) { + a.onmouseenter = function(event) { + inMouseEnter = true; + var id = event.target.getAttribute("href"); + var arr = id.replace("/thread", "").split("#"); + if (arr.length < 2) + return + id = arr[1].replace("status-", ""); + if (statusCache[id]) { + var copy = document.createElement("div"); + copy.innerHTML = statusCache[id]; + copy = copy.firstElementChild; + copy.id = "reply-to-popup"; + var ract = event.target.getBoundingClientRect(); + if (ract.top > window.innerHeight / 2) { + copy.style.bottom = (window.innerHeight - + window.scrollY - ract.top) + "px"; + } + event.target.parentElement.appendChild(copy); + } else { + http("GET", "/fluoride/status/"+id, null, null, function(res, type) { + statusCache[id] = res; + if (!inMouseEnter) + return; + var copy = document.createElement("div"); + copy.innerHTML = res; + copy = copy.firstElementChild; + copy.id = "reply-to-popup"; + var ract = event.target.getBoundingClientRect(); + if (ract.top > window.innerHeight / 2) { + copy.style.bottom = (window.innerHeight - + window.scrollY - ract.top) + "px"; + } + event.target.parentElement.appendChild(copy); + }, function(err) { + console.log("error:", err); + }) + } + } + a.onmouseleave = function(event) { + inMouseEnter = false; + var popup = document.getElementById("reply-to-popup"); + if (popup) { + popup.parentElement.removeChild(popup); + } + } +} + +function handleReplyToLink(a) { + if (!a) + return; + var id = a.getAttribute("href"); + if (!id) + return; + if (id[0] === "#") { + replyToLinkLocal(a); + } else if (id.indexOf("/thread/") === 0) { + replyToLinkRemote(a); + } +} + function handleReplyLink(a) { a.onmouseenter = function(event) { var id = event.target.getAttribute("href"); @@ -180,6 +246,7 @@ function handleReplyLink(a) { var copy = status.cloneNode(true); copy.id = "reply-popup"; var ract = event.target.getBoundingClientRect(); + copy.style["max-width"] = (window.innerWidth - 98) + "px"; if (ract.left > window.innerWidth / 2) { copy.style.right = (window.innerWidth - ract.right - 12) + "px"; @@ -269,6 +336,20 @@ function handleImgPreview(a) { } } +function onPaste(e) { + if (!e.clipboardData.files) + return; + var fp = document.querySelector("#post-file-picker") + var dt = new DataTransfer(); + for (var i = 0; i < fp.files.length; i++) { + dt.items.add(fp.files[i]); + } + for (var i = 0; i < e.clipboardData.files.length; i++) { + dt.items.add(e.clipboardData.files[i]); + } + fp.files = dt.files; +} + document.addEventListener("DOMContentLoaded", function() { checkCSRFToken(); checkAntiDopamineMode(); @@ -298,7 +379,7 @@ document.addEventListener("DOMContentLoaded", function() { } } - var links = document.querySelectorAll(".user-profile-decription a"); + var links = document.querySelectorAll(".user-profile-decription a, .user-fields a"); for (var j = 0; j < links.length; j++) { links[j].target = "_blank"; } @@ -307,6 +388,10 @@ document.addEventListener("DOMContentLoaded", function() { for (var j = 0; j < links.length; j++) { handleImgPreview(links[j]); } + + var pf = document.querySelector(".post-form") + if (pf) + pf.addEventListener("paste", onPaste); }); // @license-end diff --git a/static/style.css b/static/style.css index 4e2a196..19cceab 100644 --- a/static/style.css +++ b/static/style.css @@ -194,11 +194,14 @@ textarea { border-color: #777777; } -.notification-container.favourite .status-container, -.notification-container.reblog .status-container { +.notification-container .status-container { opacity: 0.6; } +.notification-container.mention .status-container { + opacity: unset; +} + .notification-info-text span { vertical-align: middle; } @@ -277,7 +280,8 @@ textarea { margin-top: 2px; } -.user-profile-decription { +.user-profile-decription, +.user-fields { overflow-wrap: break-word; margin: 8px 0; } @@ -286,10 +290,22 @@ textarea { margin: 0; } +.user-profile-decription img { + height: auto; + width: auto; + max-height: 240px; + max-width: 280px; + object-fit: contain; +} + .d-inline { display: inline; } +.p-0 { + padding: 0; +} + .btn-link { border: none; outline: none; @@ -354,10 +370,6 @@ a:hover, display: none; } -.post-form-field>* { - vertical-align: middle; -} - .emoji-item-container { width: 220px; display: inline-block; @@ -422,9 +434,6 @@ img.emoji { margin-right: 2px; } -.user-list-container { -} - .user-list-item { overflow: auto; margin: 0 0 12px 0; @@ -441,6 +450,10 @@ img.emoji { overflow: auto; } +.user-list-action { + margin: 0 12px; +} + #settings-form { margin: 8px 0; } @@ -449,10 +462,6 @@ img.emoji { margin: 4px 0; } -.settings-form-field>* { - vertical-align: middle; -} - #settings-form button[type=submit] { margin-top: 8px; } |