mirror of
https://github.com/openvk/openvk
synced 2025-01-09 01:09:46 +03:00
Wall: Fix pasting attachments from the clipboard in the post creation form
Also fixup previous commit
This commit is contained in:
parent
7f43458cda
commit
34f4f8fc5d
2 changed files with 29 additions and 24 deletions
|
@ -73,9 +73,13 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(() => u("#post-buttons{$textAreaId} .postFileSel").on("change", function() {
|
$(document).ready(() => {
|
||||||
handleUpload.bind(this, {$textAreaId})();
|
u("#post-buttons{$textAreaId} .postFileSel").on("change", function() {
|
||||||
}));
|
handleUpload.bind(this, {$textAreaId})();
|
||||||
|
});
|
||||||
|
|
||||||
|
setupWallPostInputHandlers({$textAreaId});
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{if $graffiti}
|
{if $graffiti}
|
||||||
|
|
|
@ -25,8 +25,7 @@ function trim(string) {
|
||||||
function handleUpload(id) {
|
function handleUpload(id) {
|
||||||
console.warn("блять...");
|
console.warn("блять...");
|
||||||
|
|
||||||
document.querySelector("input[name='_poll_attachment']").value = "";
|
u("#post-buttons" + id + " .postFileSel").not("#" + this.id).each(input => input.value = null);
|
||||||
u(".postFileSel" + id).not("#" + this.id).each(input => input.value = null);
|
|
||||||
|
|
||||||
var indicator = u("#post-buttons" + id + " .post-upload");
|
var indicator = u("#post-buttons" + id + " .post-upload");
|
||||||
var file = this.files[0];
|
var file = this.files[0];
|
||||||
|
@ -74,15 +73,6 @@ function initGraffiti(id) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
u("#wall-post-input").on("paste", function(e) {
|
|
||||||
if(e.clipboardData.files.length === 1) {
|
|
||||||
var input = u("input[name=_pic_attachment]").nodes[0];
|
|
||||||
input.files = e.clipboardData.files;
|
|
||||||
|
|
||||||
u(input).trigger("change");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
u(".post-like-button").on("click", function(e) {
|
u(".post-like-button").on("click", function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
|
@ -103,14 +93,25 @@ u(".post-like-button").on("click", function(e) {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
u("#wall-post-input").on("input", function(e) {
|
function setupWallPostInputHandlers(id) {
|
||||||
var boost = 5;
|
u("#wall-post-input" + id).on("paste", function(e) {
|
||||||
var textArea = e.target;
|
if(e.clipboardData.files.length === 1) {
|
||||||
textArea.style.height = "5px";
|
var input = u("#post-buttons" + id + " input[name=_pic_attachment]").nodes[0];
|
||||||
var newHeight = textArea.scrollHeight;
|
input.files = e.clipboardData.files;
|
||||||
textArea.style.height = newHeight + boost;
|
|
||||||
return;
|
u(input).trigger("change");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// revert to original size if it is larger (possibly changed by user)
|
u("#wall-post-input" + id).on("input", function(e) {
|
||||||
// textArea.style.height = (newHeight > originalHeight ? (newHeight + boost) : originalHeight) + "px";
|
var boost = 5;
|
||||||
});
|
var textArea = e.target;
|
||||||
|
textArea.style.height = "5px";
|
||||||
|
var newHeight = textArea.scrollHeight;
|
||||||
|
textArea.style.height = newHeight + boost;
|
||||||
|
return;
|
||||||
|
|
||||||
|
// revert to original size if it is larger (possibly changed by user)
|
||||||
|
// textArea.style.height = (newHeight > originalHeight ? (newHeight + boost) : originalHeight) + "px";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue