mirror of
https://github.com/openvk/openvk
synced 2025-01-30 19:45:28 +03:00
feat(docs): corct aud/img preview, hide report btn
when doc is yours.
This commit is contained in:
parent
9ea67ac8aa
commit
0fb18e34f5
5 changed files with 42 additions and 21 deletions
|
@ -166,6 +166,16 @@ class Document extends Media
|
|||
return in_array($this->getVKAPIType(), [3, 4]);
|
||||
}
|
||||
|
||||
function isBook(): bool
|
||||
{
|
||||
return in_array($this->getFileExtension(), ["pdf"]);
|
||||
}
|
||||
|
||||
function isAudio(): bool
|
||||
{
|
||||
return in_array($this->getVKAPIType(), [Document::VKAPI_TYPE_AUDIO]);
|
||||
}
|
||||
|
||||
function isGif(): bool
|
||||
{
|
||||
return $this->getVKAPIType() == 3;
|
||||
|
|
|
@ -139,7 +139,7 @@ final class DocumentsPresenter extends OpenVKPresenter
|
|||
} catch(\TypeError $e) {
|
||||
$this->flashFail("err", tr("forbidden"), $e->getMessage(), null, $isAjax);
|
||||
} catch(ISE $e) {
|
||||
$this->flashFail("err", tr("forbidden"), tr("error_file_preview"), null, $isAjax);
|
||||
$this->flashFail("err", tr("forbidden"), "corrupted file", null, $isAjax);
|
||||
} catch(\ValueError $e) {
|
||||
$this->flashFail("err", tr("forbidden"), $e->getMessage(), null, $isAjax);
|
||||
} catch(\ImagickException $e) {
|
||||
|
|
|
@ -22,8 +22,12 @@
|
|||
|
||||
<div class='media-page-wrapper photo-page-wrapper'>
|
||||
<div class='photo-page-wrapper-photo'>
|
||||
{if $is_image}
|
||||
<img alt="doc image" src="{$doc->getURL()}" />
|
||||
{if $doc->isGif()}
|
||||
<img class="main_doc_block" alt="doc image" src="{$doc->getURL()}" />
|
||||
{elseif $doc->isImage()}
|
||||
<img class="main_doc_block" alt="doc image" src="{$doc->getPreview()->getURLBySizeId('original')}" />
|
||||
{elseif $doc->isAudio()}
|
||||
<audio src="{$doc->getURL()}" controls></audio>
|
||||
{else}
|
||||
<a href="{$doc->getURL()}" download="{downloadable_name($doc->getName())}">
|
||||
<input class="button" type="button" value="{_download_file}">
|
||||
|
@ -63,7 +67,7 @@
|
|||
|
||||
{if isset($thisUser)}
|
||||
<a n:if="$modifiable" class="profile_link" style="display:block;width:96%;" id="edit_icon">{_edit}</a>
|
||||
<a n:if="$modifiable" class="profile_link" style="display:block;width:96%;" id="report_icon">{_report}</a>
|
||||
<a n:if="!$modifiable" class="profile_link" style="display:block;width:96%;" id="report_icon">{_report}</a>
|
||||
<a n:if="!$copied || $copied && $copyImportance" class="profile_link" style="display:block;width:96%;" id="add_icon">{_add}</a>
|
||||
<a n:if="$copied && !$copyImportance" class="profile_link" style="display:block;width:96%;" id="remove_icon">{_remove}</a>
|
||||
{/if}
|
||||
|
|
|
@ -2718,6 +2718,11 @@ a.poll-retract-vote {
|
|||
user-select: none;
|
||||
}
|
||||
|
||||
.ovk-photo-view iframe {
|
||||
width: 90vw;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.photo_com_title {
|
||||
font-weight: bold;
|
||||
padding-bottom: 16px;
|
||||
|
|
|
@ -241,24 +241,26 @@ u(document).on('click', '.docMainItem #report_icon', (e) => {
|
|||
const item = target.closest('.docMainItem')
|
||||
const id = item.nodes[0].dataset.id.split("_")
|
||||
|
||||
MessageBox(tr("report_question"), `
|
||||
const msg = new CMessageBox({
|
||||
title: tr("report_question"),
|
||||
unique_name: "report_doc",
|
||||
body: `
|
||||
${tr("going_to_report_doc")}
|
||||
<br/>${tr("report_question_text")}
|
||||
<br/><br/><b> ${tr("report_reason")}</b>: <input type='text' id='uReportMsgInput' placeholder='${tr("reason")}' />`, [tr("confirm_m"), tr("cancel")], [(function() {
|
||||
|
||||
res = document.querySelector("#uReportMsgInput").value;
|
||||
xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "/report/" + id[1] + "?reason=" + res + "&type=doc", true);
|
||||
xhr.onload = (function() {
|
||||
if(xhr.responseText.indexOf("reason") === -1)
|
||||
MessageBox(tr("error"), tr("error_sending_report"), ["OK"], [Function.noop]);
|
||||
else
|
||||
MessageBox(tr("action_successfully"), tr("will_be_watched"), ["OK"], [Function.noop]);
|
||||
});
|
||||
xhr.send(null)
|
||||
}),
|
||||
|
||||
Function.noop])
|
||||
<br/><br/><b> ${tr("report_reason")}</b>: <input type='text' id='uReportMsgInput' placeholder='${tr("reason")}' />`,
|
||||
buttons: [tr("confirm_m"), tr("cancel")],
|
||||
callbacks: [(function() {
|
||||
res = document.querySelector("#uReportMsgInput").value;
|
||||
xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "/report/" + id[1] + "?reason=" + res + "&type=doc", true);
|
||||
xhr.onload = (function() {
|
||||
if(xhr.responseText.indexOf("reason") === -1)
|
||||
MessageBox(tr("error"), tr("error_sending_report"), ["OK"], [Function.noop]);
|
||||
else
|
||||
MessageBox(tr("action_successfully"), tr("will_be_watched"), ["OK"], [Function.noop]);
|
||||
});
|
||||
xhr.send(null)
|
||||
}), Function.noop]})
|
||||
})
|
||||
|
||||
u(document).on("click", ".docListViewItem a.viewerOpener, a.docGalleryItem", async (e) => {
|
||||
|
@ -287,7 +289,7 @@ u(document).on("click", ".docListViewItem a.viewerOpener, a.docGalleryItem", asy
|
|||
const preview = body.querySelector('.photo-page-wrapper-photo')
|
||||
const details = body.querySelector('.ovk-photo-details')
|
||||
|
||||
u(preview.querySelector('img')).attr('id', 'ovk-photo-img')
|
||||
u(preview.querySelector('.main_doc_block')).attr('id', 'ovk-photo-img')
|
||||
|
||||
const photo_viewer = new CMessageBox({
|
||||
title: '',
|
||||
|
|
Loading…
Reference in a new issue