mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 06:55:46 +01:00
formatting - template associated js
This commit is contained in:
@@ -26,7 +26,9 @@
|
||||
}
|
||||
|
||||
followBtn.on('click', function() {
|
||||
socket.emit('api:user.follow', {uid: theirid}, function(success) {
|
||||
socket.emit('api:user.follow', {
|
||||
uid: theirid
|
||||
}, function(success) {
|
||||
if (success) {
|
||||
followBtn.hide();
|
||||
unfollowBtn.show();
|
||||
@@ -39,7 +41,9 @@
|
||||
});
|
||||
|
||||
unfollowBtn.on('click', function() {
|
||||
socket.emit('api:user.unfollow', {uid: theirid}, function(success) {
|
||||
socket.emit('api:user.unfollow', {
|
||||
uid: theirid
|
||||
}, function(success) {
|
||||
if (success) {
|
||||
followBtn.show();
|
||||
unfollowBtn.hide();
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
var gravatarPicture = templates.get('gravatarpicture');
|
||||
var uploadedPicture = templates.get('uploadedpicture');
|
||||
|
||||
@@ -51,7 +49,9 @@ $(document).ready(function() {
|
||||
$('#upload-picture-modal').modal('hide');
|
||||
}, 750);
|
||||
|
||||
socket.emit('api:updateHeader', { fields: ['username', 'picture', 'userslug'] });
|
||||
socket.emit('api:updateHeader', {
|
||||
fields: ['username', 'picture', 'userslug']
|
||||
});
|
||||
success('File uploaded successfully!');
|
||||
}
|
||||
});
|
||||
@@ -131,15 +131,13 @@ $(document).ready(function() {
|
||||
if (gravatarPicture) {
|
||||
$('#user-gravatar-picture').attr('src', gravatarPicture);
|
||||
$('#gravatar-box').show();
|
||||
}
|
||||
else
|
||||
} else
|
||||
$('#gravatar-box').hide();
|
||||
|
||||
if (uploadedPicture) {
|
||||
$('#user-uploaded-picture').attr('src', uploadedPicture);
|
||||
$('#uploaded-box').show();
|
||||
}
|
||||
else
|
||||
} else
|
||||
$('#uploaded-box').hide();
|
||||
|
||||
|
||||
@@ -263,7 +261,10 @@ $(document).ready(function() {
|
||||
$('#changePasswordBtn').on('click', function() {
|
||||
|
||||
if (passwordvalid && passwordsmatch && currentPassword.val()) {
|
||||
socket.emit('api:user.changePassword', {'currentPassword': currentPassword.val(),'newPassword': password.val() }, function(err) {
|
||||
socket.emit('api:user.changePassword', {
|
||||
'currentPassword': currentPassword.val(),
|
||||
'newPassword': password.val()
|
||||
}, function(err) {
|
||||
|
||||
currentPassword.val('');
|
||||
password.val('');
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#submitBtn').on('click', function() {
|
||||
|
||||
@@ -36,7 +36,9 @@
|
||||
]);
|
||||
|
||||
function onNewTopic(data) {
|
||||
var html = templates.prepare(templates['category'].blocks['topics']).parse({ topics: [data] }),
|
||||
var html = templates.prepare(templates['category'].blocks['topics']).parse({
|
||||
topics: [data]
|
||||
}),
|
||||
topic = document.createElement('div'),
|
||||
container = document.getElementById('topics-container'),
|
||||
topics = document.querySelectorAll('#topics-container a'),
|
||||
@@ -98,7 +100,9 @@
|
||||
|
||||
function onTopicsLoaded(topics) {
|
||||
|
||||
var html = templates.prepare(templates['category'].blocks['topics']).parse({ topics: topics }),
|
||||
var html = templates.prepare(templates['category'].blocks['topics']).parse({
|
||||
topics: topics
|
||||
}),
|
||||
container = $('#topics-container');
|
||||
|
||||
jQuery('#topics-container, .category-sidebar').removeClass('hidden');
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
(function() {
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('.user-favourite-posts .topic-row').on('click', function() {
|
||||
ajaxify.go($(this).attr('topic-url'));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}());
|
||||
@@ -13,13 +13,14 @@
|
||||
|
||||
if (yourid !== theirid) {
|
||||
$('.unfollow-btn').hide();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$('.unfollow-btn').on('click', function() {
|
||||
var unfollowBtn = $(this);
|
||||
var followingUid = $(this).attr('followingUid');
|
||||
|
||||
socket.emit('api:user.unfollow', {uid: followingUid}, function(success) {
|
||||
socket.emit('api:user.unfollow', {
|
||||
uid: followingUid
|
||||
}, function(success) {
|
||||
var username = unfollowBtn.attr('data-username');
|
||||
if (success) {
|
||||
unfollowBtn.parent().remove();
|
||||
|
||||
@@ -22,7 +22,9 @@
|
||||
stats_online.innerHTML = data.users;
|
||||
});
|
||||
|
||||
socket.emit('api:updateHeader', { fields: ['username', 'picture', 'userslug'] });
|
||||
socket.emit('api:updateHeader', {
|
||||
fields: ['username', 'picture', 'userslug']
|
||||
});
|
||||
socket.on('api:updateHeader', function(data) {
|
||||
|
||||
jQuery('#search-button').on('click', function() {
|
||||
@@ -134,9 +136,15 @@
|
||||
notifList.addEventListener('click', function(e) {
|
||||
var target;
|
||||
switch (e.target.nodeName) {
|
||||
case 'SPAN': target = e.target.parentNode.parentNode; break;
|
||||
case 'A': target = e.target.parentNode; break;
|
||||
case 'li': target = e.target; break;
|
||||
case 'SPAN':
|
||||
target = e.target.parentNode.parentNode;
|
||||
break;
|
||||
case 'A':
|
||||
target = e.target.parentNode;
|
||||
break;
|
||||
case 'li':
|
||||
target = e.target;
|
||||
break;
|
||||
}
|
||||
if (target) {
|
||||
var nid = parseInt(target.getAttribute('data-nid'));
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
|
||||
|
||||
(function() {
|
||||
// Alternate Logins
|
||||
var altLoginEl = document.querySelector('.alt-logins');
|
||||
altLoginEl.addEventListener('click', function(e) {
|
||||
var target;
|
||||
switch (e.target.nodeName) {
|
||||
case 'LI': target = e.target; break;
|
||||
case 'I': target = e.target.parentNode; break;
|
||||
case 'LI':
|
||||
target = e.target;
|
||||
break;
|
||||
case 'I':
|
||||
target = e.target.parentNode;
|
||||
break;
|
||||
}
|
||||
if (target) {
|
||||
document.location.href = target.getAttribute('data-url');
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
'event:new_post'
|
||||
]);
|
||||
|
||||
var newTopicCount = 0, newPostCount = 0;
|
||||
var newTopicCount = 0,
|
||||
newPostCount = 0;
|
||||
|
||||
$('#new-topics-alert').on('click', function() {
|
||||
$(this).hide();
|
||||
@@ -50,7 +51,9 @@
|
||||
|
||||
function onTopicsLoaded(topics) {
|
||||
|
||||
var html = templates.prepare(templates['recent'].blocks['topics']).parse({ topics: topics }),
|
||||
var html = templates.prepare(templates['recent'].blocks['topics']).parse({
|
||||
topics: topics
|
||||
}),
|
||||
container = $('#topics-container');
|
||||
|
||||
$('#category-no-topics').remove();
|
||||
@@ -60,7 +63,9 @@
|
||||
|
||||
function loadMoreTopics() {
|
||||
loadingMoreTopics = true;
|
||||
socket.emit('api:topics.loadMoreRecentTopics', {after:$('#topics-container').children().length}, function(data) {
|
||||
socket.emit('api:topics.loadMoreRecentTopics', {
|
||||
after: $('#topics-container').children().length
|
||||
}, function(data) {
|
||||
if (data.topics && data.topics.length) {
|
||||
onTopicsLoaded(data.topics);
|
||||
}
|
||||
|
||||
@@ -36,9 +36,10 @@
|
||||
|
||||
if (!utils.isEmailValid(emailEl.val())) {
|
||||
showError(email_notify, 'Invalid email address.');
|
||||
}
|
||||
else
|
||||
socket.emit('user.email.exists', { email: emailEl.val() });
|
||||
} else
|
||||
socket.emit('user.email.exists', {
|
||||
email: emailEl.val()
|
||||
});
|
||||
}
|
||||
|
||||
emailEl.on('blur', function() {
|
||||
@@ -58,7 +59,9 @@
|
||||
} else if (!utils.isUserNameValid(username.val())) {
|
||||
showError(username_notify, 'Invalid username!');
|
||||
} else {
|
||||
socket.emit('user.exists', {username: username.val()});
|
||||
socket.emit('user.exists', {
|
||||
username: username.val()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
|
||||
document.getElementById('reset').onclick = function() {
|
||||
if (inputEl.value.length > 0 && inputEl.value.indexOf('@') !== -1) {
|
||||
socket.emit('user:reset.send', { email: inputEl.value });
|
||||
socket.emit('user:reset.send', {
|
||||
email: inputEl.value
|
||||
});
|
||||
} else {
|
||||
jQuery('#success').hide();
|
||||
jQuery(errorEl).show();
|
||||
|
||||
@@ -18,12 +18,17 @@
|
||||
noticeEl.querySelector('p').innerHTML = 'The two passwords you\'ve entered do not match.';
|
||||
noticeEl.style.display = 'block';
|
||||
} else {
|
||||
socket.emit('user:reset.commit', { code: reset_code, password: password.value });
|
||||
socket.emit('user:reset.commit', {
|
||||
code: reset_code,
|
||||
password: password.value
|
||||
});
|
||||
}
|
||||
}, false);
|
||||
|
||||
// Enable the form if the code is valid
|
||||
socket.emit('user:reset.valid', { code: reset_code });
|
||||
socket.emit('user:reset.valid', {
|
||||
code: reset_code
|
||||
});
|
||||
|
||||
|
||||
ajaxify.register_events(['user:reset.valid', 'user:reset.commit']);
|
||||
|
||||
@@ -34,11 +34,15 @@
|
||||
$('#delete_thread').on('click', function(e) {
|
||||
if (thread_state.deleted !== '1') {
|
||||
bootbox.confirm('Are you sure you want to delete this thread?', function(confirm) {
|
||||
if (confirm) socket.emit('api:topic.delete', { tid: tid });
|
||||
if (confirm) socket.emit('api:topic.delete', {
|
||||
tid: tid
|
||||
});
|
||||
});
|
||||
} else {
|
||||
bootbox.confirm('Are you sure you want to restore this thread?', function(confirm) {
|
||||
if (confirm) socket.emit('api:topic.restore', { tid: tid });
|
||||
if (confirm) socket.emit('api:topic.restore', {
|
||||
tid: tid
|
||||
});
|
||||
});
|
||||
}
|
||||
return false;
|
||||
@@ -46,18 +50,26 @@
|
||||
|
||||
$('#lock_thread').on('click', function(e) {
|
||||
if (thread_state.locked !== '1') {
|
||||
socket.emit('api:topic.lock', { tid: tid });
|
||||
socket.emit('api:topic.lock', {
|
||||
tid: tid
|
||||
});
|
||||
} else {
|
||||
socket.emit('api:topic.unlock', { tid: tid });
|
||||
socket.emit('api:topic.unlock', {
|
||||
tid: tid
|
||||
});
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#pin_thread').on('click', function(e) {
|
||||
if (thread_state.pinned !== '1') {
|
||||
socket.emit('api:topic.pin', { tid: tid });
|
||||
socket.emit('api:topic.pin', {
|
||||
tid: tid
|
||||
});
|
||||
} else {
|
||||
socket.emit('api:topic.unpin', { tid: tid });
|
||||
socket.emit('api:topic.unpin', {
|
||||
tid: tid
|
||||
});
|
||||
}
|
||||
return false;
|
||||
});
|
||||
@@ -132,7 +144,10 @@
|
||||
});
|
||||
}
|
||||
});
|
||||
socket.emit('api:topic.move', { tid: tid, cid: targetCid });
|
||||
socket.emit('api:topic.move', {
|
||||
tid: tid,
|
||||
cid: targetCid
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -242,7 +257,9 @@
|
||||
cmp.push(tid, null, null, quoted);
|
||||
});
|
||||
});
|
||||
socket.emit('api:posts.getRawPost', { pid: pid });
|
||||
socket.emit('api:posts.getRawPost', {
|
||||
pid: pid
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -252,10 +269,15 @@
|
||||
|
||||
var element = $(this).find('i');
|
||||
if (element.attr('class') == 'icon-star-empty') {
|
||||
socket.emit('api:posts.favourite', {pid: pid, room_id: app.current_room});
|
||||
}
|
||||
else {
|
||||
socket.emit('api:posts.unfavourite', {pid: pid, room_id: app.current_room});
|
||||
socket.emit('api:posts.favourite', {
|
||||
pid: pid,
|
||||
room_id: app.current_room
|
||||
});
|
||||
} else {
|
||||
socket.emit('api:posts.unfavourite', {
|
||||
pid: pid,
|
||||
room_id: app.current_room
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -276,8 +298,12 @@
|
||||
|
||||
if (confirmDel) {
|
||||
deleteAction ?
|
||||
socket.emit('api:posts.delete', { pid: pid }) :
|
||||
socket.emit('api:posts.restore', { pid: pid });
|
||||
socket.emit('api:posts.delete', {
|
||||
pid: pid
|
||||
}) :
|
||||
socket.emit('api:posts.restore', {
|
||||
pid: pid
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -655,8 +681,7 @@
|
||||
var height = Math.floor(el.height());
|
||||
var elBottom = elTop + (height < 300 ? height : 300);
|
||||
|
||||
var inView = ((elBottom >= scrollTop) && (elTop <= scrollBottom)
|
||||
&& (elBottom <= scrollBottom) && (elTop >= scrollTop));
|
||||
var inView = ((elBottom >= scrollTop) && (elTop <= scrollBottom) && (elBottom <= scrollBottom) && (elTop >= scrollTop));
|
||||
|
||||
|
||||
if (inView) {
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
'event:new_post'
|
||||
]);
|
||||
|
||||
var newTopicCount = 0, newPostCount = 0;
|
||||
var newTopicCount = 0,
|
||||
newPostCount = 0;
|
||||
|
||||
$('#new-topics-alert').on('click', function() {
|
||||
$(this).hide();
|
||||
@@ -68,7 +69,9 @@
|
||||
|
||||
function onTopicsLoaded(topics) {
|
||||
|
||||
var html = templates.prepare(templates['unread'].blocks['topics']).parse({ topics: topics }),
|
||||
var html = templates.prepare(templates['unread'].blocks['topics']).parse({
|
||||
topics: topics
|
||||
}),
|
||||
container = $('#topics-container');
|
||||
|
||||
$('#category-no-topics').remove();
|
||||
@@ -78,7 +81,9 @@
|
||||
|
||||
function loadMoreTopics() {
|
||||
loadingMoreTopics = true;
|
||||
socket.emit('api:topics.loadMoreUnreadTopics', {after:parseInt($('#topics-container').attr('data-next-start'), 10)}, function(data) {
|
||||
socket.emit('api:topics.loadMoreUnreadTopics', {
|
||||
after: parseInt($('#topics-container').attr('data-next-start'), 10)
|
||||
}, function(data) {
|
||||
if (data.topics && data.topics.length) {
|
||||
onTopicsLoaded(data.topics);
|
||||
$('#topics-container').attr('data-next-start', data.nextStart);
|
||||
|
||||
@@ -67,8 +67,7 @@
|
||||
if (data && data.length === 0) {
|
||||
$('#user-notfound-notify').html('User not found!');
|
||||
$('#user-notfound-notify').parent().addClass('btn-warning label-warning');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$('#user-notfound-notify').html(data.length + ' user' + (data.length > 1 ? 's' : '') + ' found!');
|
||||
$('#user-notfound-notify').parent().addClass('btn-success label-success');
|
||||
}
|
||||
@@ -78,7 +77,9 @@
|
||||
|
||||
|
||||
function onUsersLoaded(users) {
|
||||
var html = templates.prepare(templates['users'].blocks['users']).parse({ users: users });
|
||||
var html = templates.prepare(templates['users'].blocks['users']).parse({
|
||||
users: users
|
||||
});
|
||||
$('#users-container').append(html);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user