mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-06 15:42:52 +01:00
more cleanup
This commit is contained in:
@@ -4,12 +4,18 @@
|
||||
|
||||
define(['composer'], function(composer) {
|
||||
|
||||
var PostTools = {};
|
||||
var PostTools = {},
|
||||
topicName;
|
||||
|
||||
PostTools.init = function(tid, threadState) {
|
||||
topicName = templates.get('topic_name');
|
||||
|
||||
var topicName = templates.get('topic_name');
|
||||
addPostHandlers(tid, threadState);
|
||||
|
||||
addShareHandlers();
|
||||
};
|
||||
|
||||
function addPostHandlers(tid, threadState) {
|
||||
$('.topic').on('click', '.post_reply', function() {
|
||||
if (threadState.locked !== '1') {
|
||||
onReplyClicked($(this), tid, topicName);
|
||||
@@ -27,11 +33,11 @@ define(['composer'], function(composer) {
|
||||
});
|
||||
|
||||
$('#post-container').on('click', '.upvote', function() {
|
||||
onUpvoteClicked($(this));
|
||||
toggleVote($(this), '.upvoted', 'posts.upvote');
|
||||
});
|
||||
|
||||
$('#post-container').on('click', '.downvote', function() {
|
||||
onDownvoteClicked($(this));
|
||||
toggleVote($(this), '.downvoted', 'posts.downvote');
|
||||
});
|
||||
|
||||
$('#post-container').on('click', '.flag', function() {
|
||||
@@ -58,9 +64,7 @@ define(['composer'], function(composer) {
|
||||
$(this).parents('.btn-group').find('.dropdown-toggle').click();
|
||||
return false;
|
||||
});
|
||||
|
||||
addShareHandlers(topicName);
|
||||
};
|
||||
}
|
||||
|
||||
function onReplyClicked(button, tid, topicName) {
|
||||
var selectionText = '',
|
||||
@@ -110,14 +114,6 @@ define(['composer'], function(composer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function onUpvoteClicked(button) {
|
||||
toggleVote(button, '.upvoted', 'posts.upvote');
|
||||
}
|
||||
|
||||
function onDownvoteClicked(button) {
|
||||
toggleVote(button, '.downvoted', 'posts.downvote');
|
||||
}
|
||||
|
||||
function toggleVote(button, className, method) {
|
||||
var post = button.parents('.post-row'),
|
||||
currentState = post.find(className).length;
|
||||
@@ -227,7 +223,13 @@ define(['composer'], function(composer) {
|
||||
});
|
||||
}
|
||||
|
||||
function addShareHandlers(topicName) {
|
||||
function addShareHandlers() {
|
||||
|
||||
function openShare(url, pid, width, height) {
|
||||
window.open(url + encodeURIComponent(window.location.protocol + '//' + window.location.host + window.location.pathname + '#' + pid), '_blank', 'width=' + width + ',height=' + height + ',scrollbars=no,status=no');
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#post-container').on('shown.bs.dropdown', '.share-dropdown', function() {
|
||||
var pid = getPid($(this));
|
||||
$('#post_' + pid + '_link').val(window.location.protocol + '//' + window.location.host + window.location.pathname + '#' + pid);
|
||||
@@ -243,18 +245,15 @@ define(['composer'], function(composer) {
|
||||
});
|
||||
|
||||
$('#post-container').on('click', '.twitter-share', function () {
|
||||
window.open('https://twitter.com/intent/tweet?url=' + encodeURIComponent(window.location.href + '#' + getPid($(this))) + '&text=' + topicName, '_blank', 'width=550,height=420,scrollbars=no,status=no');
|
||||
return false;
|
||||
return openShare('https://twitter.com/intent/tweet?text=' + topicName + '&url=', getPid($(this)), 550, 420);
|
||||
});
|
||||
|
||||
$('#post-container').on('click', '.facebook-share', function () {
|
||||
window.open('https://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent(window.location.href + '#' + getPid($(this))), '_blank', 'width=626,height=436,scrollbars=no,status=no');
|
||||
return false;
|
||||
return openShare('https://www.facebook.com/sharer/sharer.php?u=', getPid($(this)), 626, 436);
|
||||
});
|
||||
|
||||
$('#post-container').on('click', '.google-share', function () {
|
||||
window.open('https://plus.google.com/share?url=' + encodeURIComponent(window.location.href + '#' + getPid($(this))), '_blank', 'width=500,height=570,scrollbars=no,status=no');
|
||||
return false;
|
||||
return openShare('https://plus.google.com/share?url=', getPid($(this)), 500, 570);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user