formatting - template associated js

v1.18.x
psychobunny 12 years ago
parent dc41c6bc0d
commit 221b9bc149

@ -26,7 +26,9 @@
} }
followBtn.on('click', function() { followBtn.on('click', function() {
socket.emit('api:user.follow', {uid: theirid}, function(success) { socket.emit('api:user.follow', {
uid: theirid
}, function(success) {
if (success) { if (success) {
followBtn.hide(); followBtn.hide();
unfollowBtn.show(); unfollowBtn.show();
@ -39,7 +41,9 @@
}); });
unfollowBtn.on('click', function() { unfollowBtn.on('click', function() {
socket.emit('api:user.unfollow', {uid: theirid}, function(success) { socket.emit('api:user.unfollow', {
uid: theirid
}, function(success) {
if (success) { if (success) {
followBtn.show(); followBtn.show();
unfollowBtn.hide(); unfollowBtn.hide();

@ -1,5 +1,3 @@
var gravatarPicture = templates.get('gravatarpicture'); var gravatarPicture = templates.get('gravatarpicture');
var uploadedPicture = templates.get('uploadedpicture'); var uploadedPicture = templates.get('uploadedpicture');
@ -51,7 +49,9 @@ $(document).ready(function() {
$('#upload-picture-modal').modal('hide'); $('#upload-picture-modal').modal('hide');
}, 750); }, 750);
socket.emit('api:updateHeader', { fields: ['username', 'picture', 'userslug'] }); socket.emit('api:updateHeader', {
fields: ['username', 'picture', 'userslug']
});
success('File uploaded successfully!'); success('File uploaded successfully!');
} }
}); });
@ -131,15 +131,13 @@ $(document).ready(function() {
if (gravatarPicture) { if (gravatarPicture) {
$('#user-gravatar-picture').attr('src', gravatarPicture); $('#user-gravatar-picture').attr('src', gravatarPicture);
$('#gravatar-box').show(); $('#gravatar-box').show();
} } else
else
$('#gravatar-box').hide(); $('#gravatar-box').hide();
if (uploadedPicture) { if (uploadedPicture) {
$('#user-uploaded-picture').attr('src', uploadedPicture); $('#user-uploaded-picture').attr('src', uploadedPicture);
$('#uploaded-box').show(); $('#uploaded-box').show();
} } else
else
$('#uploaded-box').hide(); $('#uploaded-box').hide();
@ -263,7 +261,10 @@ $(document).ready(function() {
$('#changePasswordBtn').on('click', function() { $('#changePasswordBtn').on('click', function() {
if (passwordvalid && passwordsmatch && currentPassword.val()) { 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(''); currentPassword.val('');
password.val(''); password.val('');

@ -1,6 +1,3 @@
$(document).ready(function() { $(document).ready(function() {
$('#submitBtn').on('click', function() { $('#submitBtn').on('click', function() {

@ -36,7 +36,9 @@
]); ]);
function onNewTopic(data) { 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'), topic = document.createElement('div'),
container = document.getElementById('topics-container'), container = document.getElementById('topics-container'),
topics = document.querySelectorAll('#topics-container a'), topics = document.querySelectorAll('#topics-container a'),
@ -98,7 +100,9 @@
function onTopicsLoaded(topics) { 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'); container = $('#topics-container');
jQuery('#topics-container, .category-sidebar').removeClass('hidden'); jQuery('#topics-container, .category-sidebar').removeClass('hidden');

@ -1,11 +1,7 @@
(function() { (function() {
$(document).ready(function() { $(document).ready(function() {
$('.user-favourite-posts .topic-row').on('click', function() { $('.user-favourite-posts .topic-row').on('click', function() {
ajaxify.go($(this).attr('topic-url')); ajaxify.go($(this).attr('topic-url'));
}); });
}); });
}()); }());

@ -13,13 +13,14 @@
if (yourid !== theirid) { if (yourid !== theirid) {
$('.unfollow-btn').hide(); $('.unfollow-btn').hide();
} } else {
else {
$('.unfollow-btn').on('click', function() { $('.unfollow-btn').on('click', function() {
var unfollowBtn = $(this); var unfollowBtn = $(this);
var followingUid = $(this).attr('followingUid'); 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'); var username = unfollowBtn.attr('data-username');
if (success) { if (success) {
unfollowBtn.parent().remove(); unfollowBtn.parent().remove();

@ -22,7 +22,9 @@
stats_online.innerHTML = data.users; 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) { socket.on('api:updateHeader', function(data) {
jQuery('#search-button').on('click', function() { jQuery('#search-button').on('click', function() {
@ -134,9 +136,15 @@
notifList.addEventListener('click', function(e) { notifList.addEventListener('click', function(e) {
var target; var target;
switch (e.target.nodeName) { switch (e.target.nodeName) {
case 'SPAN': target = e.target.parentNode.parentNode; break; case 'SPAN':
case 'A': target = e.target.parentNode; break; target = e.target.parentNode.parentNode;
case 'li': target = e.target; break; break;
case 'A':
target = e.target.parentNode;
break;
case 'li':
target = e.target;
break;
} }
if (target) { if (target) {
var nid = parseInt(target.getAttribute('data-nid')); var nid = parseInt(target.getAttribute('data-nid'));

@ -1,13 +1,15 @@
(function() { (function() {
// Alternate Logins // Alternate Logins
var altLoginEl = document.querySelector('.alt-logins'); var altLoginEl = document.querySelector('.alt-logins');
altLoginEl.addEventListener('click', function(e) { altLoginEl.addEventListener('click', function(e) {
var target; var target;
switch (e.target.nodeName) { switch (e.target.nodeName) {
case 'LI': target = e.target; break; case 'LI':
case 'I': target = e.target.parentNode; break; target = e.target;
break;
case 'I':
target = e.target.parentNode;
break;
} }
if (target) { if (target) {
document.location.href = target.getAttribute('data-url'); document.location.href = target.getAttribute('data-url');

@ -8,7 +8,8 @@
'event:new_post' 'event:new_post'
]); ]);
var newTopicCount = 0, newPostCount = 0; var newTopicCount = 0,
newPostCount = 0;
$('#new-topics-alert').on('click', function() { $('#new-topics-alert').on('click', function() {
$(this).hide(); $(this).hide();
@ -50,7 +51,9 @@
function onTopicsLoaded(topics) { 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'); container = $('#topics-container');
$('#category-no-topics').remove(); $('#category-no-topics').remove();
@ -60,7 +63,9 @@
function loadMoreTopics() { function loadMoreTopics() {
loadingMoreTopics = true; 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) { if (data.topics && data.topics.length) {
onTopicsLoaded(data.topics); onTopicsLoaded(data.topics);
} }

@ -36,9 +36,10 @@
if (!utils.isEmailValid(emailEl.val())) { if (!utils.isEmailValid(emailEl.val())) {
showError(email_notify, 'Invalid email address.'); showError(email_notify, 'Invalid email address.');
} } else
else socket.emit('user.email.exists', {
socket.emit('user.email.exists', { email: emailEl.val() }); email: emailEl.val()
});
} }
emailEl.on('blur', function() { emailEl.on('blur', function() {
@ -58,7 +59,9 @@
} else if (!utils.isUserNameValid(username.val())) { } else if (!utils.isUserNameValid(username.val())) {
showError(username_notify, 'Invalid username!'); showError(username_notify, 'Invalid username!');
} else { } else {
socket.emit('user.exists', {username: username.val()}); socket.emit('user.exists', {
username: username.val()
});
} }
} }

@ -5,7 +5,9 @@
document.getElementById('reset').onclick = function() { document.getElementById('reset').onclick = function() {
if (inputEl.value.length > 0 && inputEl.value.indexOf('@') !== -1) { 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 { } else {
jQuery('#success').hide(); jQuery('#success').hide();
jQuery(errorEl).show(); jQuery(errorEl).show();

@ -18,12 +18,17 @@
noticeEl.querySelector('p').innerHTML = 'The two passwords you\'ve entered do not match.'; noticeEl.querySelector('p').innerHTML = 'The two passwords you\'ve entered do not match.';
noticeEl.style.display = 'block'; noticeEl.style.display = 'block';
} else { } else {
socket.emit('user:reset.commit', { code: reset_code, password: password.value }); socket.emit('user:reset.commit', {
code: reset_code,
password: password.value
});
} }
}, false); }, false);
// Enable the form if the code is valid // 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']); ajaxify.register_events(['user:reset.valid', 'user:reset.commit']);

@ -34,11 +34,15 @@
$('#delete_thread').on('click', function(e) { $('#delete_thread').on('click', function(e) {
if (thread_state.deleted !== '1') { if (thread_state.deleted !== '1') {
bootbox.confirm('Are you sure you want to delete this thread?', function(confirm) { 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 { } else {
bootbox.confirm('Are you sure you want to restore this thread?', function(confirm) { 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; return false;
@ -46,18 +50,26 @@
$('#lock_thread').on('click', function(e) { $('#lock_thread').on('click', function(e) {
if (thread_state.locked !== '1') { if (thread_state.locked !== '1') {
socket.emit('api:topic.lock', { tid: tid }); socket.emit('api:topic.lock', {
tid: tid
});
} else { } else {
socket.emit('api:topic.unlock', { tid: tid }); socket.emit('api:topic.unlock', {
tid: tid
});
} }
return false; return false;
}); });
$('#pin_thread').on('click', function(e) { $('#pin_thread').on('click', function(e) {
if (thread_state.pinned !== '1') { if (thread_state.pinned !== '1') {
socket.emit('api:topic.pin', { tid: tid }); socket.emit('api:topic.pin', {
tid: tid
});
} else { } else {
socket.emit('api:topic.unpin', { tid: tid }); socket.emit('api:topic.unpin', {
tid: tid
});
} }
return false; 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); 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'); var element = $(this).find('i');
if (element.attr('class') == 'icon-star-empty') { if (element.attr('class') == 'icon-star-empty') {
socket.emit('api:posts.favourite', {pid: pid, room_id: app.current_room}); socket.emit('api:posts.favourite', {
} pid: pid,
else { room_id: app.current_room
socket.emit('api:posts.unfavourite', {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) { if (confirmDel) {
deleteAction ? deleteAction ?
socket.emit('api:posts.delete', { pid: pid }) : socket.emit('api:posts.delete', {
socket.emit('api:posts.restore', { pid: pid }); pid: pid
}) :
socket.emit('api:posts.restore', {
pid: pid
});
} }
}); });
@ -655,8 +681,7 @@
var height = Math.floor(el.height()); var height = Math.floor(el.height());
var elBottom = elTop + (height < 300 ? height : 300); var elBottom = elTop + (height < 300 ? height : 300);
var inView = ((elBottom >= scrollTop) && (elTop <= scrollBottom) var inView = ((elBottom >= scrollTop) && (elTop <= scrollBottom) && (elBottom <= scrollBottom) && (elTop >= scrollTop));
&& (elBottom <= scrollBottom) && (elTop >= scrollTop));
if (inView) { if (inView) {

@ -8,7 +8,8 @@
'event:new_post' 'event:new_post'
]); ]);
var newTopicCount = 0, newPostCount = 0; var newTopicCount = 0,
newPostCount = 0;
$('#new-topics-alert').on('click', function() { $('#new-topics-alert').on('click', function() {
$(this).hide(); $(this).hide();
@ -68,7 +69,9 @@
function onTopicsLoaded(topics) { 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'); container = $('#topics-container');
$('#category-no-topics').remove(); $('#category-no-topics').remove();
@ -78,7 +81,9 @@
function loadMoreTopics() { function loadMoreTopics() {
loadingMoreTopics = true; 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) { if (data.topics && data.topics.length) {
onTopicsLoaded(data.topics); onTopicsLoaded(data.topics);
$('#topics-container').attr('data-next-start', data.nextStart); $('#topics-container').attr('data-next-start', data.nextStart);

@ -67,8 +67,7 @@
if (data && data.length === 0) { if (data && data.length === 0) {
$('#user-notfound-notify').html('User not found!'); $('#user-notfound-notify').html('User not found!');
$('#user-notfound-notify').parent().addClass('btn-warning label-warning'); $('#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').html(data.length + ' user' + (data.length > 1 ? 's' : '') + ' found!');
$('#user-notfound-notify').parent().addClass('btn-success label-success'); $('#user-notfound-notify').parent().addClass('btn-success label-success');
} }
@ -78,7 +77,9 @@
function onUsersLoaded(users) { 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); $('#users-container').append(html);
} }

Loading…
Cancel
Save