mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
feat: add new client side hooks
This commit is contained in:
@@ -338,7 +338,13 @@ define('forum/topic/postTools', [
|
|||||||
function bookmarkPost(button, pid) {
|
function bookmarkPost(button, pid) {
|
||||||
var method = button.attr('data-bookmarked') === 'false' ? 'put' : 'del';
|
var method = button.attr('data-bookmarked') === 'false' ? 'put' : 'del';
|
||||||
|
|
||||||
api[method](`/posts/${pid}/bookmark`, undefined, undefined, 'default');
|
api[method](`/posts/${pid}/bookmark`, undefined, function (err) {
|
||||||
|
if (err) {
|
||||||
|
return app.alertError(err);
|
||||||
|
}
|
||||||
|
var type = method === 'put' ? 'bookmark' : 'unbookmark';
|
||||||
|
$(window).trigger('action:post.' + type, { pid: pid });
|
||||||
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -429,6 +435,7 @@ define('forum/topic/postTools', [
|
|||||||
$(window).trigger('action:composer.topic.new', {
|
$(window).trigger('action:composer.topic.new', {
|
||||||
cid: ajaxify.data.cid,
|
cid: ajaxify.data.cid,
|
||||||
body: body,
|
body: body,
|
||||||
|
fromStaleTopic: true,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -58,14 +58,22 @@ define('forum/topic/votes', [
|
|||||||
var currentState = post.find(className).length;
|
var currentState = post.find(className).length;
|
||||||
|
|
||||||
const method = currentState ? 'del' : 'put';
|
const method = currentState ? 'del' : 'put';
|
||||||
api[method](`/posts/${post.attr('data-pid')}/vote`, {
|
var pid = post.attr('data-pid');
|
||||||
|
api[method](`/posts/${pid}/vote`, {
|
||||||
delta: delta,
|
delta: delta,
|
||||||
}).catch((err) => {
|
}, function (err) {
|
||||||
app.alertError(err.message);
|
if (err) {
|
||||||
|
if (err.message === '[[error:not-logged-in]]') {
|
||||||
if (err.message === '[[error:not-logged-in]]') {
|
ajaxify.go('login');
|
||||||
ajaxify.go('login');
|
return;
|
||||||
|
}
|
||||||
|
return app.alertError(err.message);
|
||||||
}
|
}
|
||||||
|
$(window).trigger('action:post.toggleVote', {
|
||||||
|
pid: pid,
|
||||||
|
delta: delta,
|
||||||
|
unvote: method === 'del',
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ define('share', function () {
|
|||||||
|
|
||||||
function openShare(url, urlToPost, width, height) {
|
function openShare(url, urlToPost, width, height) {
|
||||||
window.open(url + encodeURIComponent(baseUrl + config.relative_path + urlToPost), '_blank', 'width=' + width + ',height=' + height + ',scrollbars=no,status=no');
|
window.open(url + encodeURIComponent(baseUrl + config.relative_path + urlToPost), '_blank', 'width=' + width + ',height=' + height + ',scrollbars=no,status=no');
|
||||||
|
$(window).trigger('action:share.open', {
|
||||||
|
url: url,
|
||||||
|
urlToPost: urlToPost,
|
||||||
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user