mirror of
https://github.com/openvk/openvk
synced 2024-12-23 00:51:03 +03:00
feat(friends): add ajax
This commit is contained in:
parent
4c78617a9c
commit
c5644a51d6
7 changed files with 67 additions and 7 deletions
|
@ -49,7 +49,7 @@
|
||||||
{include description, x => $dat}
|
{include description, x => $dat}
|
||||||
{/ifset}
|
{/ifset}
|
||||||
</td>
|
</td>
|
||||||
<td n:ifset="actions" valign="top" class="action_links" style="width: 150px;">
|
<td n:ifset="actions" valign="top" class="action_links" style="min-width: 150px;">
|
||||||
{include actions, x => $dat}
|
{include actions, x => $dat}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -145,21 +145,21 @@
|
||||||
{if ($x->getId() !== $thisUser->getId()) && ($thisUser->getId() === $user->getId())}
|
{if ($x->getId() !== $thisUser->getId()) && ($thisUser->getId() === $user->getId())}
|
||||||
{var $subStatus = $x->getSubscriptionStatus($thisUser)}
|
{var $subStatus = $x->getSubscriptionStatus($thisUser)}
|
||||||
{if $subStatus === 0}
|
{if $subStatus === 0}
|
||||||
<form action="/setSub/user" method="post" class="profile_link_form">
|
<form action="/setSub/user" method="post" class="profile_link_form" id="_submitUserSubscriptionAction">
|
||||||
<input type="hidden" name="act" value="add" />
|
<input type="hidden" name="act" value="add" />
|
||||||
<input type="hidden" name="id" value="{$x->getId()}" />
|
<input type="hidden" name="id" value="{$x->getId()}" />
|
||||||
<input type="hidden" name="hash" value="{$csrfToken}" />
|
<input type="hidden" name="hash" value="{$csrfToken}" />
|
||||||
<input type="submit" class="profile_link" value="{_friends_add}" />
|
<input type="submit" class="profile_link" value="{_friends_add}" />
|
||||||
</form>
|
</form>
|
||||||
{elseif $subStatus === 1}
|
{elseif $subStatus === 1}
|
||||||
<form action="/setSub/user" method="post" class="profile_link_form">
|
<form action="/setSub/user" method="post" class="profile_link_form" id="_submitUserSubscriptionAction">
|
||||||
<input type="hidden" name="act" value="add" />
|
<input type="hidden" name="act" value="add" />
|
||||||
<input type="hidden" name="id" value="{$x->getId()}" />
|
<input type="hidden" name="id" value="{$x->getId()}" />
|
||||||
<input type="hidden" name="hash" value="{$csrfToken}" />
|
<input type="hidden" name="hash" value="{$csrfToken}" />
|
||||||
<input type="submit" class="profile_link" value="{_friends_accept}" />
|
<input type="submit" class="profile_link" value="{_friends_accept}" />
|
||||||
</form>
|
</form>
|
||||||
{if $act !== 'followers'}
|
{if $act !== 'followers'}
|
||||||
<form action="/setSub/user" method="post" class="profile_link_form">
|
<form action="/setSub/user" method="post" class="profile_link_form" id="_submitUserSubscriptionAction">
|
||||||
<input type="hidden" name="act" value="rej" />
|
<input type="hidden" name="act" value="rej" />
|
||||||
<input type="hidden" name="id" value="{$x->getId()}" />
|
<input type="hidden" name="id" value="{$x->getId()}" />
|
||||||
<input type="hidden" name="hash" value="{$csrfToken}" />
|
<input type="hidden" name="hash" value="{$csrfToken}" />
|
||||||
|
@ -167,7 +167,7 @@
|
||||||
</form>
|
</form>
|
||||||
{/if}
|
{/if}
|
||||||
{elseif $subStatus === 2}
|
{elseif $subStatus === 2}
|
||||||
<form action="/setSub/user" method="post" class="profile_link_form">
|
<form action="/setSub/user" method="post" class="profile_link_form" id="_submitUserSubscriptionAction">
|
||||||
<input type="hidden" name="act" value="rem" />
|
<input type="hidden" name="act" value="rem" />
|
||||||
<input type="hidden" name="id" value="{$x->getId()}" />
|
<input type="hidden" name="id" value="{$x->getId()}" />
|
||||||
<input type="hidden" name="hash" value="{$csrfToken}" />
|
<input type="hidden" name="hash" value="{$csrfToken}" />
|
||||||
|
@ -175,7 +175,7 @@
|
||||||
</form>
|
</form>
|
||||||
{elseif $subStatus === 3}
|
{elseif $subStatus === 3}
|
||||||
<a href="/im?sel={$x->getId()}" class="profile_link">{_send_message}</a>
|
<a href="/im?sel={$x->getId()}" class="profile_link">{_send_message}</a>
|
||||||
<form action="/setSub/user" method="post" class="profile_link_form">
|
<form action="/setSub/user" method="post" class="profile_link_form" id="_submitUserSubscriptionAction">
|
||||||
<input type="hidden" name="act" value="rem" />
|
<input type="hidden" name="act" value="rem" />
|
||||||
<input type="hidden" name="id" value="{$x->getId()}" />
|
<input type="hidden" name="id" value="{$x->getId()}" />
|
||||||
<input type="hidden" name="hash" value="{$csrfToken}" />
|
<input type="hidden" name="hash" value="{$csrfToken}" />
|
||||||
|
|
|
@ -427,6 +427,22 @@ h1 {
|
||||||
text-transform: lowercase;
|
text-transform: lowercase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.action_links.disable>a,
|
||||||
|
.action_links.disable>form>input,
|
||||||
|
.action_links.disable {
|
||||||
|
cursor: not-allowed;
|
||||||
|
color: grey;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action_links.loading::after {
|
||||||
|
content: "";
|
||||||
|
display: inline-block;
|
||||||
|
background-image: url('/assets/packages/static/openvk/img/loading_mini.gif');
|
||||||
|
width: 30px;
|
||||||
|
height: 7px;
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
.profile_link.disable>a,
|
.profile_link.disable>a,
|
||||||
.profile_link.disable {
|
.profile_link.disable {
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
|
|
|
@ -167,6 +167,44 @@ document.addEventListener("DOMContentLoaded", function() { //BEGIN
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
u("#_submitUserSubscriptionAction").handle("submit", async function(e) {
|
||||||
|
u(this).nodes[0].parentElement.classList.add('loading');
|
||||||
|
u(this).nodes[0].parentElement.classList.add('disable');
|
||||||
|
console.log(e.target);
|
||||||
|
const data = await fetch(u(this).attr('action'), { method: 'POST', body: new FormData(e.target) });
|
||||||
|
if (data.ok) {
|
||||||
|
u(this).nodes[0].parentElement.classList.remove('loading');
|
||||||
|
u(this).nodes[0].parentElement.classList.remove('disable');
|
||||||
|
if (e.target[0].value == "add") {
|
||||||
|
u(this).nodes[0].parentElement.innerHTML = tr("friends_add_msg");
|
||||||
|
} else if (e.target[0].value == "rej") {
|
||||||
|
u(this).nodes[0].parentElement.innerHTML = tr("friends_rej_msg");
|
||||||
|
} else if (e.target[0].value == "rem") {
|
||||||
|
u(this).nodes[0].parentElement.innerHTML = tr("friends_rem_msg");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$("form").on("submit", function (e) {
|
||||||
|
var dataString = $(this).serialize();
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: "/setSub/user",
|
||||||
|
data: dataString,
|
||||||
|
success: function () {
|
||||||
|
console.log("penis");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
e.preventDefault();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
*/
|
||||||
|
|
||||||
}); //END ONREADY DECLS
|
}); //END ONREADY DECLS
|
||||||
|
|
||||||
async function repostPost(id, hash) {
|
async function repostPost(id, hash) {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
ALTER TABLE `subscriptions` ADD `flags` tinyint(3) unsigned NOT NULL;
|
ALTER TABLE `subscriptions` ADD `flags` tinyint(3) unsigned NOT NULL DEFAULT '0' AFTER `target`
|
|
@ -260,6 +260,9 @@
|
||||||
"friends_reject" = "Reject request";
|
"friends_reject" = "Reject request";
|
||||||
"friends_accept" = "Accept request";
|
"friends_accept" = "Accept request";
|
||||||
"friends_leave_in_flw" = "Leave in followers";
|
"friends_leave_in_flw" = "Leave in followers";
|
||||||
|
"friends_add_msg" = "Now you're friends.";
|
||||||
|
"friends_rej_msg" = "You left this user as subscriber.";
|
||||||
|
"friends_rem_msg" = "You deleted this user from your friend list.";
|
||||||
"send_message" = "Send a message";
|
"send_message" = "Send a message";
|
||||||
"incoming_req" = "Pending";
|
"incoming_req" = "Pending";
|
||||||
"outcoming_req" = "Outgoing";
|
"outcoming_req" = "Outgoing";
|
||||||
|
|
|
@ -240,6 +240,9 @@
|
||||||
"friends_reject" = "Отменить заявку";
|
"friends_reject" = "Отменить заявку";
|
||||||
"friends_accept" = "Принять заявку";
|
"friends_accept" = "Принять заявку";
|
||||||
"friends_leave_in_flw" = "Оставить в подписчиках";
|
"friends_leave_in_flw" = "Оставить в подписчиках";
|
||||||
|
"friends_add_msg" = "Теперь вы друзья.";
|
||||||
|
"friends_rej_msg" = "Вы оставили пользователя в подписчиках.";
|
||||||
|
"friends_rem_msg" = "Вы удалили пользователя из списка своих друзей.";
|
||||||
"send_message" = "Отправить сообщение";
|
"send_message" = "Отправить сообщение";
|
||||||
"incoming_req" = "Входящие";
|
"incoming_req" = "Входящие";
|
||||||
"outcoming_req" = "Исходящие";
|
"outcoming_req" = "Исходящие";
|
||||||
|
|
Loading…
Reference in a new issue