mirror of
https://github.com/openvk/openvk
synced 2025-04-23 16:43:02 +03:00
Add checkboxes
This commit is contained in:
parent
1518e424ca
commit
2f05d81c02
5 changed files with 83 additions and 14 deletions
|
@ -521,8 +521,31 @@ final class WallPresenter extends OpenVKPresenter
|
||||||
|
|
||||||
$post->setEdited(time());
|
$post->setEdited(time());
|
||||||
$post->setContent($this->postParam("newContent"));
|
$post->setContent($this->postParam("newContent"));
|
||||||
|
|
||||||
|
if($this->postParam("type") === "post") {
|
||||||
|
$post->setNsfw($this->postParam("nsfw") == "true");
|
||||||
|
$flags = 0;
|
||||||
|
|
||||||
|
if($post->getTargetWall() < 0) {
|
||||||
|
if($this->postParam("fromgroup") == "true") {
|
||||||
|
$flags |= 0b10000000;
|
||||||
|
$post->setFlags($flags);
|
||||||
|
} else
|
||||||
|
$post->setFlags($flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$post->save(true);
|
$post->save(true);
|
||||||
|
|
||||||
$this->returnJson(["error" => "no", "new_content" => $post->getText(), "new_edited" => (string)$post->getEditTime()]);
|
$this->returnJson(["error" => "no",
|
||||||
|
"new_content" => $post->getText(),
|
||||||
|
"new_edited" => (string)$post->getEditTime(),
|
||||||
|
"nsfw" => $this->postParam("type") === "post" ? (int)$post->isExplicit() : 0,
|
||||||
|
"from_group" => $this->postParam("type") === "post" && $post->getTargetWall() < 0 ?
|
||||||
|
((int)$post->isPostedOnBehalfOfGroup()) : "false",
|
||||||
|
"author" => [
|
||||||
|
"name" => $post->getOwner()->getCanonicalName(),
|
||||||
|
"avatar" => $post->getOwner()->getAvatarUrl()
|
||||||
|
]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,9 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div n:if="isset($thisUser) &&! ($compact ?? false)" class="post-menu">
|
<div n:if="isset($thisUser) &&! ($compact ?? false)" class="post-menu">
|
||||||
<a href="#_comment{$comment->getId()}" class="date">{$comment->getPublicationTime()} <span n:if="$post->getEditTime()" class="edited editedMark">({_edited_short})</span></a>
|
<a href="#_comment{$comment->getId()}" class="date">{$comment->getPublicationTime()}
|
||||||
|
<span n:if="$comment->getEditTime()" class="edited editedMark">({_edited_short})</span>
|
||||||
|
</a>
|
||||||
{if !$timeOnly}
|
{if !$timeOnly}
|
||||||
|
|
|
|
||||||
{if $comment->canBeDeletedBy($thisUser)}
|
{if $comment->canBeDeletedBy($thisUser)}
|
||||||
|
|
|
@ -18,13 +18,13 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td width="54" valign="top">
|
<td width="54" valign="top">
|
||||||
<a href="{$author->getURL()}">
|
<a href="{$author->getURL()}">
|
||||||
<img src="{$author->getAvatarURL('miniscule')}" width="{if $compact}25{else}50{/if}" {if $compact}class="cCompactAvatars"{/if} />
|
<img src="{$author->getAvatarURL('miniscule')}" width="{if $compact}25{else}50{/if}" class="post-avatar {if $compact}cCompactAvatars{/if}" />
|
||||||
<span n:if="!$post->isPostedOnBehalfOfGroup() && !$compact && $author->isOnline()" class="post-online">{_online}</span>
|
<span n:if="!$post->isPostedOnBehalfOfGroup() && !$compact && $author->isOnline()" class="post-online">{_online}</span>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td width="100%" valign="top">
|
<td width="100%" valign="top">
|
||||||
<div class="post-author">
|
<div class="post-author">
|
||||||
<a href="{$author->getURL()}"><b>{$author->getCanonicalName()}</b></a>
|
<a href="{$author->getURL()}"><b class="post-author-name">{$author->getCanonicalName()}</b></a>
|
||||||
<img n:if="$author->isVerified()" class="name-checkmark" src="/assets/packages/static/openvk/img/checkmark.png">
|
<img n:if="$author->isVerified()" class="name-checkmark" src="/assets/packages/static/openvk/img/checkmark.png">
|
||||||
{$post->isDeactivationMessage() ? ($author->isFemale() ? tr($deac . "_f") : tr($deac . "_m"))}
|
{$post->isDeactivationMessage() ? ($author->isFemale() ? tr($deac . "_f") : tr($deac . "_m"))}
|
||||||
{$post->isUpdateAvatarMessage() && !$post->isPostedOnBehalfOfGroup() ? ($author->isFemale() ? tr("upd_f") : tr("upd_m"))}
|
{$post->isUpdateAvatarMessage() && !$post->isPostedOnBehalfOfGroup() ? ($author->isFemale() ? tr("upd_f") : tr("upd_m"))}
|
||||||
|
@ -64,7 +64,10 @@
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{if $post->canBeEditedBy($thisUser) && !($forceNoEditLink ?? false) && $compact == false}
|
{if $post->canBeEditedBy($thisUser) && !($forceNoEditLink ?? false) && $compact == false}
|
||||||
<a class="edit" id="editPost" data-id="{$post->getId()}"></a>
|
<a class="edit" id="editPost"
|
||||||
|
data-id="{$post->getId()}"
|
||||||
|
data-nsfw="{(int)$post->isExplicit()}"
|
||||||
|
{if $post->getTargetWall() < 0}data-fromgroup="{(int)$post->isPostedOnBehalfOfGroup()}"{/if}></a>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<div class="post-content" id="{$post->getPrettyId()}">
|
<div class="post-content" id="{$post->getPrettyId()}">
|
||||||
|
|
|
@ -14,13 +14,13 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td width="54" valign="top">
|
<td width="54" valign="top">
|
||||||
<a href="{$author->getURL()}">
|
<a href="{$author->getURL()}">
|
||||||
<img src="{$author->getAvatarURL('miniscule')}" width="50" />
|
<img src="{$author->getAvatarURL('miniscule')}" class="post-avatar" width="50" />
|
||||||
<span n:if="!$post->isPostedOnBehalfOfGroup() && !($compact ?? false) && $author->isOnline()" class="post-online">{_online}</span>
|
<span n:if="!$post->isPostedOnBehalfOfGroup() && !($compact ?? false) && $author->isOnline()" class="post-online">{_online}</span>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td width="100%" valign="top">
|
<td width="100%" valign="top">
|
||||||
<div class="post-author">
|
<div class="post-author">
|
||||||
<a href="{$author->getURL()}"><b>{$author->getCanonicalName()}</b></a>
|
<a href="{$author->getURL()}"><b class="post-author-name">{$author->getCanonicalName()}</b></a>
|
||||||
<img n:if="$author->isVerified()" class="name-checkmark" src="/assets/packages/static/openvk/img/checkmark.png">
|
<img n:if="$author->isVerified()" class="name-checkmark" src="/assets/packages/static/openvk/img/checkmark.png">
|
||||||
{if $post->isDeactivationMessage()}
|
{if $post->isDeactivationMessage()}
|
||||||
{$author->isFemale() ? tr($deac . "_f") : tr($deac . "_m")}
|
{$author->isFemale() ? tr($deac . "_f") : tr($deac . "_m")}
|
||||||
|
@ -92,7 +92,10 @@
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{if !($forceNoEditLink ?? false) && $post->canBeEditedBy($thisUser)}
|
{if !($forceNoEditLink ?? false) && $post->canBeEditedBy($thisUser)}
|
||||||
<a id="editPost" data-id="{$post->getId()}">{_edit}</a> |
|
<a id="editPost"
|
||||||
|
data-id="{$post->getId()}"
|
||||||
|
data-nsfw="{(int)$post->isExplicit()}"
|
||||||
|
{if $post->getTargetWall() < 0}data-fromgroup="{(int)$post->isPostedOnBehalfOfGroup()}"{/if}>{_edit}</a> |
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{if !($forceNoDeleteLink ?? false) && $post->canBeDeletedBy($thisUser)}
|
{if !($forceNoDeleteLink ?? false) && $post->canBeDeletedBy($thisUser)}
|
||||||
|
|
|
@ -271,10 +271,22 @@ $(document).on("click", "#editPost", (e) => {
|
||||||
|
|
||||||
if(content.querySelector("textarea") == null) {
|
if(content.querySelector("textarea") == null) {
|
||||||
content.insertAdjacentHTML("afterbegin", `
|
content.insertAdjacentHTML("afterbegin", `
|
||||||
<div id="wall-post-input999" class="editMenu">
|
<div class="editMenu">
|
||||||
<textarea id="new_content">${text.innerHTML.replace(/(<([^>]+)>)/gi, '')}</textarea>
|
<div id="wall-post-input999">
|
||||||
<input type="button" class="button" value="${tr("save")}" id="endEditing">
|
<textarea id="new_content">${text.innerHTML.replace(/(<([^>]+)>)/gi, '')}</textarea>
|
||||||
<input type="button" class="button" value="${tr("cancel")}" id="cancelEditing">
|
<input type="button" class="button" value="${tr("save")}" id="endEditing">
|
||||||
|
<input type="button" class="button" value="${tr("cancel")}" id="cancelEditing">
|
||||||
|
</div>
|
||||||
|
${e.currentTarget.dataset.nsfw != null ? `
|
||||||
|
<div class="postOptions">
|
||||||
|
<label><input type="checkbox" id="nswfw" ${e.currentTarget.dataset.nsfw == 1 ? `checked` : ``}>${tr("contains_nsfw")}</label>
|
||||||
|
</div>
|
||||||
|
` : ``}
|
||||||
|
${e.currentTarget.dataset.fromgroup != null ? `
|
||||||
|
<div class="postOptions">
|
||||||
|
<label><input type="checkbox" id="fromgroup" ${e.currentTarget.dataset.fromgroup == 1 ? `checked` : ``}>${tr("post_as_group")}</label>
|
||||||
|
</div>
|
||||||
|
` : ``}
|
||||||
</div>
|
</div>
|
||||||
`)
|
`)
|
||||||
|
|
||||||
|
@ -295,7 +307,11 @@ $(document).on("click", "#editPost", (e) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
xhr.onerror = () => {
|
xhr.onerror = () => {
|
||||||
MessageBox(tr("error"), "unknown error occured", tr("ok"), (() => {Function.noop}))
|
MessageBox(tr("error"), "unknown error occured", [tr("ok")], [() => {Function.noop}])
|
||||||
|
}
|
||||||
|
|
||||||
|
xhr.ontimeout = () => {
|
||||||
|
MessageBox(tr("error"), "Try to refresh page", [tr("ok")], [() => {Function.noop}])
|
||||||
}
|
}
|
||||||
|
|
||||||
xhr.onload = () => {
|
xhr.onload = () => {
|
||||||
|
@ -310,6 +326,23 @@ $(document).on("click", "#editPost", (e) => {
|
||||||
<span class="edited editedMark">(${tr("edited_short")})</span>
|
<span class="edited editedMark">(${tr("edited_short")})</span>
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(e.currentTarget.dataset.nsfw != null) {
|
||||||
|
e.currentTarget.setAttribute("data-nsfw", result.nsfw)
|
||||||
|
|
||||||
|
if(result.nsfw == 0) {
|
||||||
|
post.classList.remove("post-nsfw")
|
||||||
|
} else {
|
||||||
|
post.classList.add("post-nsfw")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(e.currentTarget.dataset.fromgroup != null) {
|
||||||
|
e.currentTarget.setAttribute("data-fromgroup", result.from_group)
|
||||||
|
}
|
||||||
|
|
||||||
|
post.querySelector(".post-avatar").setAttribute("src", result.author.avatar)
|
||||||
|
post.querySelector(".post-author-name").innerHTML = result.author.name
|
||||||
} else {
|
} else {
|
||||||
MessageBox(tr("error"), result.error, [tr("ok")], [Function.noop])
|
MessageBox(tr("error"), result.error, [tr("ok")], [Function.noop])
|
||||||
post.querySelector("#editPost").click()
|
post.querySelector("#editPost").click()
|
||||||
|
@ -317,7 +350,12 @@ $(document).on("click", "#editPost", (e) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
||||||
xhr.send("postid="+e.currentTarget.dataset.id+"&newContent="+nwcntnt+"&hash="+encodeURIComponent(u("meta[name=csrf]").attr("value"))+"&type="+type)
|
xhr.send("postid="+e.currentTarget.dataset.id+
|
||||||
|
"&newContent="+nwcntnt+
|
||||||
|
"&hash="+encodeURIComponent(u("meta[name=csrf]").attr("value"))+
|
||||||
|
"&type="+type+
|
||||||
|
"&nsfw="+(content.querySelector("#nswfw") != null ? content.querySelector("#nswfw").checked : 0)+
|
||||||
|
"&fromgroup="+(content.querySelector("#fromgroup") != null ? content.querySelector("#fromgroup").checked : 0))
|
||||||
})
|
})
|
||||||
|
|
||||||
text.style.display = "none"
|
text.style.display = "none"
|
||||||
|
|
Loading…
Reference in a new issue