aboutsummaryrefslogtreecommitdiff
path: root/static/fluoride.js
diff options
context:
space:
mode:
authorr <r@freesoftwareextremist.com>2020-01-11 10:51:33 +0000
committerr <r@freesoftwareextremist.com>2020-01-11 10:51:33 +0000
commit8607f16212c9537751030c717dbfb3454e66ca23 (patch)
tree78dc7e4e08ca6b1d2b0a800a223973e8e05ff857 /static/fluoride.js
parent2a777001022ec3f8618ce3a1c696b6317ed36111 (diff)
downloadbloat-8607f16212c9537751030c717dbfb3454e66ca23.tar.gz
bloat-8607f16212c9537751030c717dbfb3454e66ca23.zip
Add status reply preview in fluoride mode
Diffstat (limited to 'static/fluoride.js')
-rw-r--r--static/fluoride.js51
1 files changed, 51 insertions, 0 deletions
diff --git a/static/fluoride.js b/static/fluoride.js
index 3020da0..25ab4a3 100644
--- a/static/fluoride.js
+++ b/static/fluoride.js
@@ -92,6 +92,51 @@ function handleRetweetForm(id, f) {
}
}
+function handleReplyToLink(link) {
+ if (!link) {
+ return;
+ }
+ var id = link.firstElementChild.getAttribute('href');
+ if (!id || id[0] != '#') {
+ return;
+ }
+ link.onmouseenter = function(event) {
+ var id = event.target.firstElementChild.getAttribute('href');
+ var status = document.querySelector(id);
+ if (!status) {
+ return;
+ }
+ var copy = status.cloneNode(true);
+ copy.id = "reply-to-popup";
+ link.appendChild(copy);
+ }
+ link.onmouseleave = function(event) {
+ var popup = document.getElementById("reply-to-popup");
+ if (popup) {
+ event.target.removeChild(popup);
+ }
+ }
+}
+
+function handleReplyLink(link) {
+ link.onmouseenter = function(event) {
+ var id = event.target.firstElementChild.getAttribute('href');
+ var status = document.querySelector(id);
+ if (!status) {
+ return;
+ }
+ var copy = status.cloneNode(true);
+ copy.id = "reply-popup";
+ link.appendChild(copy);
+ }
+ link.onmouseleave = function(event) {
+ var popup = document.getElementById("reply-popup");
+ if (popup) {
+ event.target.removeChild(popup);
+ }
+ }
+}
+
document.addEventListener("DOMContentLoaded", function() {
var statuses = document.querySelectorAll(".status-container");
statuses.forEach(function(s) {
@@ -102,5 +147,11 @@ document.addEventListener("DOMContentLoaded", function() {
var retweetForm = s.querySelector(".status-retweet");
handleRetweetForm(id, retweetForm);
+
+ var replyToLink = s.querySelector(".status-reply-to");
+ handleReplyToLink(replyToLink);
+
+ var replyLinks = s.querySelectorAll(".status-reply");
+ replyLinks.forEach(handleReplyLink);
});
});