77 lines
2.1 KiB
JavaScript
Executable File
77 lines
2.1 KiB
JavaScript
Executable File
|
|
$(document).on("click", '.post-like-button[data-action="like"]', function(event) {
|
|
event.preventDefault();
|
|
var $this = $(".post-like-button");
|
|
var id = $(this).data("id");
|
|
if ($this.hasClass("requesting")) {
|
|
return !1
|
|
}
|
|
$this.addClass("requesting");
|
|
$.ajax({
|
|
url: globals.ajax_url,
|
|
type: "POST",
|
|
dataType: "html",
|
|
data: {
|
|
action: "pandapro_like",
|
|
id,
|
|
like_action: "like"
|
|
},
|
|
}).done(function(data) {
|
|
$this.addClass("active");
|
|
$this.attr("data-action", "unlike");
|
|
ncPopupTips(1, __("Thank you!", "pandapro"));
|
|
$(".like-count").html(data.trim());
|
|
isApollo && apolloAjaxPostLikeSection(id)
|
|
}).always(function() {
|
|
$this.removeClass("requesting")
|
|
});
|
|
return !1
|
|
});
|
|
|
|
$(document).on("click", '.post-like-button[data-action="unlike"]', function(event) {
|
|
event.preventDefault();
|
|
var $this = $(".post-like-button");
|
|
var id = $(this).data("id");
|
|
if ($this.hasClass("requesting")) {
|
|
return !1
|
|
}
|
|
$this.addClass("requesting");
|
|
$this.removeClass("active");
|
|
$.ajax({
|
|
url: globals.ajax_url,
|
|
type: "POST",
|
|
dataType: "html",
|
|
data: {
|
|
action: "pandapro_like",
|
|
id,
|
|
like_action: "unlike"
|
|
},
|
|
}).done(function(data) {
|
|
$this.removeClass("active");
|
|
$this.attr("data-action", "like");
|
|
ncPopupTips(0, __("Cancelled.", "pandapro"));
|
|
$(".like-count").html(data.trim());
|
|
isApollo && apolloAjaxPostLikeSection(id)
|
|
}).always(function() {
|
|
$this.removeClass("requesting")
|
|
});
|
|
return !1
|
|
});
|
|
|
|
function apolloAjaxPostLikeSection(id) {
|
|
$.ajax({
|
|
url: globals.ajax_url,
|
|
type: "POST",
|
|
dataType: "html",
|
|
data: {
|
|
action: "ajax_apollo_userlike_section",
|
|
id: id,
|
|
},
|
|
}).done(function(response) {
|
|
$("#apollo-postlike-section").length > 0 && $("#apollo-postlike-section").remove();
|
|
if (response.trim()) {
|
|
$(".post-actions").after(response)
|
|
}
|
|
})
|
|
}
|