aboutsummaryrefslogtreecommitdiff
path: root/static/fluoride.js
diff options
context:
space:
mode:
Diffstat (limited to 'static/fluoride.js')
-rw-r--r--static/fluoride.js34
1 files changed, 30 insertions, 4 deletions
diff --git a/static/fluoride.js b/static/fluoride.js
index c7f3109..e6624d1 100644
--- a/static/fluoride.js
+++ b/static/fluoride.js
@@ -152,6 +152,7 @@ function replyToLinkLocal(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";
@@ -245,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";
@@ -298,20 +300,24 @@ function setPos(el, cx, cy, mw, mh) {
}
var imgPrev = null;
+var imgX = 0;
+var imgY = 0;
function handleImgPreview(a) {
a.onmouseenter = function(e) {
var mw = document.documentElement.clientWidth;
var mh = document.documentElement.clientHeight - 24;
+ imgX = e.clientX;
+ imgY = e.clientY;
var img = document.createElement("img");
img.id = "img-preview";
img.src = e.target.getAttribute("href");
img.style["max-width"] = mw + "px";
img.style["max-height"] = mh + "px";
+ imgPrev = img;
img.onload = function(e2) {
- setPos(e2.target, e.clientX, e.clientY, mw, mh);
+ setPos(imgPrev, imgX, imgY, mw, mh);
}
document.body.appendChild(img);
- imgPrev = img;
}
a.onmouseleave = function(e) {
var img = document.getElementById("img-preview");
@@ -324,8 +330,24 @@ function handleImgPreview(a) {
return;
var mw = document.documentElement.clientWidth;
var mh = document.documentElement.clientHeight - 24;
- setPos(imgPrev, e.clientX, e.clientY, mw, mh);
+ imgX = e.clientX;
+ imgY = e.clientY;
+ setPos(imgPrev, imgX, imgY, mw, mh);
+ }
+}
+
+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() {
@@ -357,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";
}
@@ -366,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