mirror of
https://github.com/openvk/openvk
synced 2024-12-23 00:51:03 +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>
|
||||
|
||||
<script>
|
||||
$(document).ready(() => u("#post-buttons{$textAreaId} .postFileSel").on("change", function() {
|
||||
$(document).ready(() => {
|
||||
u("#post-buttons{$textAreaId} .postFileSel").on("change", function() {
|
||||
handleUpload.bind(this, {$textAreaId})();
|
||||
}));
|
||||
});
|
||||
|
||||
setupWallPostInputHandlers({$textAreaId});
|
||||
});
|
||||
</script>
|
||||
|
||||
{if $graffiti}
|
||||
|
|
|
@ -25,8 +25,7 @@ function trim(string) {
|
|||
function handleUpload(id) {
|
||||
console.warn("блять...");
|
||||
|
||||
document.querySelector("input[name='_poll_attachment']").value = "";
|
||||
u(".postFileSel" + id).not("#" + this.id).each(input => input.value = null);
|
||||
u("#post-buttons" + id + " .postFileSel").not("#" + this.id).each(input => input.value = null);
|
||||
|
||||
var indicator = u("#post-buttons" + id + " .post-upload");
|
||||
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) {
|
||||
e.preventDefault();
|
||||
|
||||
|
@ -103,7 +93,17 @@ u(".post-like-button").on("click", function(e) {
|
|||
return false;
|
||||
});
|
||||
|
||||
u("#wall-post-input").on("input", function(e) {
|
||||
function setupWallPostInputHandlers(id) {
|
||||
u("#wall-post-input" + id).on("paste", function(e) {
|
||||
if(e.clipboardData.files.length === 1) {
|
||||
var input = u("#post-buttons" + id + " input[name=_pic_attachment]").nodes[0];
|
||||
input.files = e.clipboardData.files;
|
||||
|
||||
u(input).trigger("change");
|
||||
}
|
||||
});
|
||||
|
||||
u("#wall-post-input" + id).on("input", function(e) {
|
||||
var boost = 5;
|
||||
var textArea = e.target;
|
||||
textArea.style.height = "5px";
|
||||
|
@ -113,4 +113,5 @@ u("#wall-post-input").on("input", function(e) {
|
|||
|
||||
// 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