This commit is contained in:
lalka2016 2023-08-20 15:38:21 +03:00
parent 6bd475a6ac
commit 77fe2fb63e
6 changed files with 97 additions and 8 deletions

View file

@ -146,6 +146,7 @@ class Wall implements Handler
$post->setSuggested(0); $post->setSuggested(0);
$post->setCreated(time()); $post->setCreated(time());
$post->setApi_Source_Name(NULL);
$post->setFlags($flags); $post->setFlags($flags);
if(mb_strlen($content) > 0) if(mb_strlen($content) > 0)

View file

@ -231,7 +231,7 @@
<div n:if="$thisUser->getPinnedClubCount() > 0" class="menu_divider"></div> <div n:if="$thisUser->getPinnedClubCount() > 0" class="menu_divider"></div>
<a n:foreach="$thisUser->getPinnedClubs() as $club" href="{$club->getURL()}" class="link group_link"> <a n:foreach="$thisUser->getPinnedClubs() as $club" href="{$club->getURL()}" class="link group_link">
{$club->getName()} {ovk_proc_strtr($club->getName(), 14)}
<object type="internal/link" style="white-space: normal;" id="sug{$club->getId()}" n:if="$club->getSuggestedPostsCount($thisUser) > 0 && $club->getWallType() == 2"> <object type="internal/link" style="white-space: normal;" id="sug{$club->getId()}" n:if="$club->getSuggestedPostsCount($thisUser) > 0 && $club->getWallType() == 2">
<a href="/club{$club->getId()}/suggested" class="linkunderline"> <a href="/club{$club->getId()}/suggested" class="linkunderline">

View file

@ -92,11 +92,11 @@
</div> </div>
<div n:if="!is_null($suggestedPostsCountByUser) && $suggestedPostsCountByUser > 0" class="sugglist"> <div n:if="!is_null($suggestedPostsCountByUser) && $suggestedPostsCountByUser > 0" class="sugglist">
<a href="/club{$club->getId()}/suggested">{tr("suggested_by_you", $suggestedPostsCountByUser)}</a> <a href="/club{$club->getId()}/suggested" id="cound_r">{tr("suggested_by_you", $suggestedPostsCountByUser)}</a>
</div> </div>
<div n:if="!is_null($suggestedPostsCountByEveryone) && $suggestedPostsCountByEveryone > 0" class="sugglist"> <div n:if="!is_null($suggestedPostsCountByEveryone) && $suggestedPostsCountByEveryone > 0" class="sugglist">
<a href="/club{$club->getId()}/suggested">{tr("suggested_by_everyone", $suggestedPostsCountByEveryone)}</a> <a href="/club{$club->getId()}/suggested" id="cound_r">{tr("suggested_by_everyone", $suggestedPostsCountByEveryone)}</a>
</div> </div>
{presenter "openvk!Wall->wallEmbedded", -$club->getId()} {presenter "openvk!Wall->wallEmbedded", -$club->getId()}

View file

@ -7,6 +7,8 @@
</nobold> </nobold>
</div> </div>
<div> <div>
<div class="insertThere" id="postz"></div>
<div id="underHeader">
<div n:if="$canPost" class="content_subtitle"> <div n:if="$canPost" class="content_subtitle">
{include "../components/textArea.xml", route => "/wall$owner/makePost", graffiti => true, polls => true, notes => true} {include "../components/textArea.xml", route => "/wall$owner/makePost", graffiti => true, polls => true, notes => true}
</div> </div>
@ -24,6 +26,7 @@
{/if} {/if}
</div> </div>
</div> </div>
</div>
</div> </div>
{if isset($thisUser) && $thisUser->hasMicroblogEnabled()} {if isset($thisUser) && $thisUser->hasMicroblogEnabled()}

View file

@ -2727,3 +2727,11 @@ body.article .floating_sidebar, body.article .page_content {
padding: 16px 40px 6px 4px !important; padding: 16px 40px 6px 4px !important;
} }
} }
.sugglist a:hover {
text-decoration: underline;
}
.sugglist a[data-toogled="true"] {
color:black;
}

View file

@ -307,7 +307,12 @@ $(document).on("click", "#publish_post", async (e) => {
} }
NewNotification(tr("suggestion_succefully_published"), tr("suggestion_press_to_go"), null, () => {window.location.assign("/wall" + post.id)}); NewNotification(tr("suggestion_succefully_published"), tr("suggestion_press_to_go"), null, () => {window.location.assign("/wall" + post.id)});
if(document.getElementById("cound") != null) {
document.getElementById("cound").innerHTML = tr("suggested_posts_in_group", post.new_count) document.getElementById("cound").innerHTML = tr("suggested_posts_in_group", post.new_count)
} else {
document.getElementById("cound_r").innerHTML = tr("suggested_by_everyone", post.new_count)
}
if(document.querySelector("object a[href='"+location.pathname+"'] b") != null) { if(document.querySelector("object a[href='"+location.pathname+"'] b") != null) {
document.querySelector("object a[href='"+location.pathname+"'] b").innerHTML = post.new_count document.querySelector("object a[href='"+location.pathname+"'] b").innerHTML = post.new_count
@ -323,7 +328,7 @@ $(document).on("click", "#publish_post", async (e) => {
e.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.outerHTML = "" e.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.outerHTML = ""
} }
if(document.querySelectorAll(".post").length < 1 && post.new_count > 0 && document.querySelector(".paginator") != null) { if(document.querySelectorAll("#postz .post").length < 1 && post.new_count > 0 && document.querySelector(".paginator") != null) {
loadMoreSuggestedPosts() loadMoreSuggestedPosts()
} }
}), Function.noop]); }), Function.noop]);
@ -374,7 +379,11 @@ $(document).on("click", "#decline_post", async (e) => {
e.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.outerHTML = "" e.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.outerHTML = ""
} }
if(document.getElementById("cound") != null) {
document.getElementById("cound").innerHTML = tr("suggested_posts_in_group", post) document.getElementById("cound").innerHTML = tr("suggested_posts_in_group", post)
} else {
document.getElementById("cound_r").innerHTML = tr("suggested_by_everyone", post)
}
if(document.querySelector("object a[href='"+location.pathname+"'] b") != null) { if(document.querySelector("object a[href='"+location.pathname+"'] b") != null) {
document.querySelector("object a[href='"+location.pathname+"'] b").innerHTML = post document.querySelector("object a[href='"+location.pathname+"'] b").innerHTML = post
@ -384,7 +393,7 @@ $(document).on("click", "#decline_post", async (e) => {
} }
} }
if(document.querySelectorAll(".post").length < 1 && post > 0 && document.querySelector(".paginator") != null) { if(document.querySelectorAll("#postz .post").length < 1 && post > 0 && document.querySelector(".paginator") != null) {
loadMoreSuggestedPosts() loadMoreSuggestedPosts()
} }
}) })
@ -392,7 +401,13 @@ $(document).on("click", "#decline_post", async (e) => {
function loadMoreSuggestedPosts() function loadMoreSuggestedPosts()
{ {
let xhr = new XMLHttpRequest let xhr = new XMLHttpRequest
xhr.open("GET", location.href) let link = location.href
if(!link.includes("/suggested")) {
link += "/suggested"
}
xhr.open("GET", link)
xhr.onloadstart = () => { xhr.onloadstart = () => {
document.getElementById("postz").innerHTML = `<img src="/assets/packages/static/openvk/img/loading_mini.gif">` document.getElementById("postz").innerHTML = `<img src="/assets/packages/static/openvk/img/loading_mini.gif">`
@ -425,3 +440,65 @@ function loadMoreSuggestedPosts()
xhr.send() xhr.send()
} }
// нажатие на "x предложенных записей"
$(document).on("click", ".sugglist a", (e) => {
e.preventDefault()
if(e.currentTarget.getAttribute("data-toogled") == null || e.currentTarget.getAttribute("data-toogled") == "false") {
e.currentTarget.setAttribute("data-toogled", "true")
document.getElementById("underHeader").style.display = "none"
document.querySelector(".insertThere").style.display = "block"
history.pushState({}, "", e.currentTarget.href)
// если ещё ничего не подгружалось
if(document.querySelector(".insertThere").innerHTML == "") {
let xhr = new XMLHttpRequest
xhr.open("GET", e.currentTarget.href)
xhr.onloadstart = () => {
// лоадер
document.querySelector(".insertThere").insertAdjacentHTML("afterbegin", `<img src="/assets/packages/static/openvk/img/loading_mini.gif">`)
}
xhr.onload = () => {
let parser = new DOMParser
let result = parser.parseFromString(xhr.responseText, 'text/html').querySelector(".infContainer")
// парсинг результата и вставка постов
document.querySelector(".insertThere").innerHTML = result.innerHTML
}
xhr.send()
}
} else {
// переключение на нормальную стену
e.currentTarget.setAttribute("data-toogled", "false")
document.getElementById("underHeader").style.display = "block"
document.querySelector(".insertThere").style.display = "none"
history.pushState({}, "", e.currentTarget.href.replace("/suggested", ""))
}
})
// нажатие на пагинатор у постов пъедложки
$(document).on("click", "#postz .paginator a", (e) => {
e.preventDefault()
let xhr = new XMLHttpRequest
xhr.open("GET", e.currentTarget.href)
xhr.onloadstart = () => {
window.scrollTo({top: 0,behavior: "smooth"})
// после того как долистали наверх, добавляем лоадер
setTimeout(() => {document.querySelector("#postz").innerHTML = `<img src="/assets/packages/static/openvk/img/loading_mini.gif">`}, 500)
}
xhr.onload = () => {
// опять парс
let result = (new DOMParser).parseFromString(xhr.responseText, "text/html").querySelector(".infContainer")
// опять вставка
document.getElementById("postz").innerHTML = result.innerHTML
history.pushState({}, "", e.currentTarget.href)
}
xhr.send()
})