mirror of
https://github.com/openvk/openvk
synced 2024-11-11 01:19:53 +03:00
Wall: Fix attachment of files in the comment popup
This commit is contained in:
parent
5f9b36de5f
commit
7f43458cda
2 changed files with 17 additions and 12 deletions
|
@ -49,20 +49,20 @@
|
||||||
<br/>
|
<br/>
|
||||||
<input type="submit" value="{_'write'}" class="button" />
|
<input type="submit" value="{_'write'}" class="button" />
|
||||||
<div style="float: right; display: flex; flex-direction: column;">
|
<div style="float: right; display: flex; flex-direction: column;">
|
||||||
<a href="javascript:void(u('#wallAttachmentMenu').toggleClass('hidden'));">
|
<a href="javascript:void(u('#post-buttons{$textAreaId} #wallAttachmentMenu').toggleClass('hidden'));">
|
||||||
Прикрепить
|
Прикрепить
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<div id="wallAttachmentMenu" class="hidden">
|
<div id="wallAttachmentMenu" class="hidden">
|
||||||
<a href="javascript:void(document.querySelector('input[name=_pic_attachment]').click());">
|
<a href="javascript:void(document.querySelector('#post-buttons{$textAreaId} input[name=_pic_attachment]').click());">
|
||||||
<img src="/assets/packages/static/openvk/img/oxygen-icons/16x16/mimetypes/application-x-egon.png" />
|
<img src="/assets/packages/static/openvk/img/oxygen-icons/16x16/mimetypes/application-x-egon.png" />
|
||||||
{_attach_photo}
|
{_attach_photo}
|
||||||
</a>
|
</a>
|
||||||
<a href="javascript:void(document.querySelector('input[name=_vid_attachment]').click());">
|
<a href="javascript:void(document.querySelector('#post-buttons{$textAreaId} input[name=_vid_attachment]').click());">
|
||||||
<img src="/assets/packages/static/openvk/img/oxygen-icons/16x16/mimetypes/application-vnd.rn-realmedia.png" />
|
<img src="/assets/packages/static/openvk/img/oxygen-icons/16x16/mimetypes/application-vnd.rn-realmedia.png" />
|
||||||
Прикрепить видео
|
Прикрепить видео
|
||||||
</a>
|
</a>
|
||||||
<a n:if="$graffiti ?? false" href="javascript:initGraffiti();">
|
<a n:if="$graffiti ?? false" href="javascript:initGraffiti({$textAreaId});">
|
||||||
<img src="/assets/packages/static/openvk/img/oxygen-icons/16x16/actions/draw-brush.png" />
|
<img src="/assets/packages/static/openvk/img/oxygen-icons/16x16/actions/draw-brush.png" />
|
||||||
Нарисовать граффити
|
Нарисовать граффити
|
||||||
</a>
|
</a>
|
||||||
|
@ -72,6 +72,12 @@
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(document).ready(() => u("#post-buttons{$textAreaId} .postFileSel").on("change", function() {
|
||||||
|
handleUpload.bind(this, {$textAreaId})();
|
||||||
|
}));
|
||||||
|
</script>
|
||||||
|
|
||||||
{if $graffiti}
|
{if $graffiti}
|
||||||
{script "js/node_modules/react/dist/react-with-addons.min.js"}
|
{script "js/node_modules/react/dist/react-with-addons.min.js"}
|
||||||
{script "js/node_modules/react-dom/dist/react-dom.min.js"}
|
{script "js/node_modules/react-dom/dist/react-dom.min.js"}
|
||||||
|
|
|
@ -22,12 +22,13 @@ function trim(string) {
|
||||||
return newStr;
|
return newStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleUpload() {
|
function handleUpload(id) {
|
||||||
console.warn("блять...");
|
console.warn("блять...");
|
||||||
|
|
||||||
u(".postFileSel").not("#" + this.id).each(input => input.value = null);
|
document.querySelector("input[name='_poll_attachment']").value = "";
|
||||||
|
u(".postFileSel" + id).not("#" + this.id).each(input => input.value = null);
|
||||||
|
|
||||||
var indicator = u(".post-upload");
|
var indicator = u("#post-buttons" + id + " .post-upload");
|
||||||
var file = this.files[0];
|
var file = this.files[0];
|
||||||
if(typeof file === "undefined") {
|
if(typeof file === "undefined") {
|
||||||
indicator.attr("style", "display: none;");
|
indicator.attr("style", "display: none;");
|
||||||
|
@ -37,7 +38,7 @@ function handleUpload() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function initGraffiti() {
|
function initGraffiti(id) {
|
||||||
let canvas = null;
|
let canvas = null;
|
||||||
let msgbox = MessageBox("Нарисовать граффити", "<div id='ovkDraw'></div>", ["Сохранить", "Отменить"], [function() {
|
let msgbox = MessageBox("Нарисовать граффити", "<div id='ovkDraw'></div>", ["Сохранить", "Отменить"], [function() {
|
||||||
canvas.getImage({includeWatermark: false}).toBlob(blob => {
|
canvas.getImage({includeWatermark: false}).toBlob(blob => {
|
||||||
|
@ -46,11 +47,11 @@ function initGraffiti() {
|
||||||
let trans = new DataTransfer();
|
let trans = new DataTransfer();
|
||||||
trans.items.add(image);
|
trans.items.add(image);
|
||||||
|
|
||||||
let fileSelect = document.querySelector("input[name='_pic_attachment']");
|
let fileSelect = document.querySelector("#post-buttons" + id + " input[name='_pic_attachment']");
|
||||||
fileSelect.files = trans.files;
|
fileSelect.files = trans.files;
|
||||||
|
|
||||||
u(fileSelect).trigger("change");
|
u(fileSelect).trigger("change");
|
||||||
u("#write textarea").trigger("focusin");
|
u("#post-buttons" + id + " #write textarea").trigger("focusin");
|
||||||
}, "image/jpeg", 0.92);
|
}, "image/jpeg", 0.92);
|
||||||
|
|
||||||
canvas.teardown();
|
canvas.teardown();
|
||||||
|
@ -113,5 +114,3 @@ u("#wall-post-input").on("input", function(e) {
|
||||||
// revert to original size if it is larger (possibly changed by user)
|
// revert to original size if it is larger (possibly changed by user)
|
||||||
// textArea.style.height = (newHeight > originalHeight ? (newHeight + boost) : originalHeight) + "px";
|
// textArea.style.height = (newHeight > originalHeight ? (newHeight + boost) : originalHeight) + "px";
|
||||||
});
|
});
|
||||||
|
|
||||||
u(".postFileSel").on("change", handleUpload);
|
|
||||||
|
|
Loading…
Reference in a new issue