mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 14:35:47 +01:00
formatting - template associated js
This commit is contained in:
@@ -12,8 +12,8 @@
|
|||||||
var followBtn = $('#follow-btn');
|
var followBtn = $('#follow-btn');
|
||||||
var unfollowBtn = $('#unfollow-btn');
|
var unfollowBtn = $('#unfollow-btn');
|
||||||
|
|
||||||
if(yourid !== theirid) {
|
if (yourid !== theirid) {
|
||||||
if(isFollowing) {
|
if (isFollowing) {
|
||||||
followBtn.hide();
|
followBtn.hide();
|
||||||
unfollowBtn.show();
|
unfollowBtn.show();
|
||||||
} else {
|
} else {
|
||||||
@@ -26,8 +26,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
followBtn.on('click', function() {
|
followBtn.on('click', function() {
|
||||||
socket.emit('api:user.follow', {uid: theirid}, function(success) {
|
socket.emit('api:user.follow', {
|
||||||
if(success) {
|
uid: theirid
|
||||||
|
}, function(success) {
|
||||||
|
if (success) {
|
||||||
followBtn.hide();
|
followBtn.hide();
|
||||||
unfollowBtn.show();
|
unfollowBtn.show();
|
||||||
app.alertSuccess('You are now following ' + username + '!');
|
app.alertSuccess('You are now following ' + username + '!');
|
||||||
@@ -39,8 +41,10 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
unfollowBtn.on('click', function() {
|
unfollowBtn.on('click', function() {
|
||||||
socket.emit('api:user.unfollow', {uid: theirid}, function(success) {
|
socket.emit('api:user.unfollow', {
|
||||||
if(success) {
|
uid: theirid
|
||||||
|
}, function(success) {
|
||||||
|
if (success) {
|
||||||
followBtn.show();
|
followBtn.show();
|
||||||
unfollowBtn.hide();
|
unfollowBtn.hide();
|
||||||
app.alertSuccess('You are no longer following ' + username + '!');
|
app.alertSuccess('You are no longer following ' + username + '!');
|
||||||
@@ -58,7 +62,7 @@
|
|||||||
var onlineStatus = $('.account-online-status');
|
var onlineStatus = $('.account-online-status');
|
||||||
|
|
||||||
function handleUserOnline(data) {
|
function handleUserOnline(data) {
|
||||||
if(data.online) {
|
if (data.online) {
|
||||||
onlineStatus.find('span span').text('online');
|
onlineStatus.find('span span').text('online');
|
||||||
onlineStatus.find('i').attr('class', 'icon-circle');
|
onlineStatus.find('i').attr('class', 'icon-circle');
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
var gravatarPicture = templates.get('gravatarpicture');
|
var gravatarPicture = templates.get('gravatarpicture');
|
||||||
var uploadedPicture = templates.get('uploadedpicture');
|
var uploadedPicture = templates.get('uploadedpicture');
|
||||||
|
|
||||||
@@ -14,7 +12,7 @@ $(document).ready(function() {
|
|||||||
$('#upload-progress-box').show();
|
$('#upload-progress-box').show();
|
||||||
$('#upload-progress-box').removeClass('hide');
|
$('#upload-progress-box').removeClass('hide');
|
||||||
|
|
||||||
if(!$('#userPhotoInput').val()) {
|
if (!$('#userPhotoInput').val()) {
|
||||||
error('select an image to upload!');
|
error('select an image to upload!');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -28,13 +26,13 @@ $(document).ready(function() {
|
|||||||
error('Error: ' + xhr.status);
|
error('Error: ' + xhr.status);
|
||||||
},
|
},
|
||||||
|
|
||||||
uploadProgress : function(event, position, total, percent) {
|
uploadProgress: function(event, position, total, percent) {
|
||||||
$('#upload-progress-bar').css('width', percent+'%');
|
$('#upload-progress-bar').css('width', percent + '%');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
if(response.error) {
|
if (response.error) {
|
||||||
error(response.error);
|
error(response.error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -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!');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -87,7 +87,7 @@ $(document).ready(function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
socket.emit('api:user.changePicture', userData, function(success) {
|
socket.emit('api:user.changePicture', userData, function(success) {
|
||||||
if(!success) {
|
if (!success) {
|
||||||
app.alertError('There was an error changing picture!');
|
app.alertError('There was an error changing picture!');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -95,26 +95,26 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
var selectedImageType = '';
|
var selectedImageType = '';
|
||||||
|
|
||||||
$('#submitBtn').on('click',function(){
|
$('#submitBtn').on('click', function() {
|
||||||
|
|
||||||
var userData = {
|
var userData = {
|
||||||
uid:$('#inputUID').val(),
|
uid: $('#inputUID').val(),
|
||||||
email:$('#inputEmail').val(),
|
email: $('#inputEmail').val(),
|
||||||
fullname:$('#inputFullname').val(),
|
fullname: $('#inputFullname').val(),
|
||||||
website:$('#inputWebsite').val(),
|
website: $('#inputWebsite').val(),
|
||||||
birthday:$('#inputBirthday').val(),
|
birthday: $('#inputBirthday').val(),
|
||||||
location:$('#inputLocation').val(),
|
location: $('#inputLocation').val(),
|
||||||
signature:$('#inputSignature').val()
|
signature: $('#inputSignature').val()
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.emit('api:user.updateProfile', userData, function(err, data) {
|
socket.emit('api:user.updateProfile', userData, function(err, data) {
|
||||||
if(data.success) {
|
if (data.success) {
|
||||||
app.alertSuccess('Your profile has been updated successfully!');
|
app.alertSuccess('Your profile has been updated successfully!');
|
||||||
if(data.picture) {
|
if (data.picture) {
|
||||||
$('#user-current-picture').attr('src', data.picture);
|
$('#user-current-picture').attr('src', data.picture);
|
||||||
$('#user_label img').attr('src', data.picture);
|
$('#user_label img').attr('src', data.picture);
|
||||||
}
|
}
|
||||||
if(data.gravatarpicture) {
|
if (data.gravatarpicture) {
|
||||||
$('#user-gravatar-picture').attr('src', data.gravatarpicture);
|
$('#user-gravatar-picture').attr('src', data.gravatarpicture);
|
||||||
gravatarPicture = data.gravatarpicture;
|
gravatarPicture = data.gravatarpicture;
|
||||||
}
|
}
|
||||||
@@ -128,27 +128,25 @@ $(document).ready(function() {
|
|||||||
function updateImages() {
|
function updateImages() {
|
||||||
var currentPicture = $('#user-current-picture').attr('src');
|
var currentPicture = $('#user-current-picture').attr('src');
|
||||||
|
|
||||||
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();
|
||||||
|
|
||||||
|
|
||||||
if(currentPicture == gravatarPicture)
|
if (currentPicture == gravatarPicture)
|
||||||
$('#gravatar-box .icon-ok').show();
|
$('#gravatar-box .icon-ok').show();
|
||||||
else
|
else
|
||||||
$('#gravatar-box .icon-ok').hide();
|
$('#gravatar-box .icon-ok').hide();
|
||||||
|
|
||||||
if(currentPicture == uploadedPicture)
|
if (currentPicture == uploadedPicture)
|
||||||
$('#uploaded-box .icon-ok').show();
|
$('#uploaded-box .icon-ok').show();
|
||||||
else
|
else
|
||||||
$('#uploaded-box .icon-ok').hide();
|
$('#uploaded-box .icon-ok').hide();
|
||||||
@@ -165,13 +163,13 @@ $(document).ready(function() {
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#gravatar-box').on('click', function(){
|
$('#gravatar-box').on('click', function() {
|
||||||
$('#gravatar-box .icon-ok').show();
|
$('#gravatar-box .icon-ok').show();
|
||||||
$('#uploaded-box .icon-ok').hide();
|
$('#uploaded-box .icon-ok').hide();
|
||||||
selectedImageType = 'gravatar';
|
selectedImageType = 'gravatar';
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#uploaded-box').on('click', function(){
|
$('#uploaded-box').on('click', function() {
|
||||||
$('#gravatar-box .icon-ok').hide();
|
$('#gravatar-box .icon-ok').hide();
|
||||||
$('#uploaded-box .icon-ok').show();
|
$('#uploaded-box .icon-ok').show();
|
||||||
selectedImageType = 'uploaded';
|
selectedImageType = 'uploaded';
|
||||||
@@ -180,12 +178,12 @@ $(document).ready(function() {
|
|||||||
$('#savePictureChangesBtn').on('click', function() {
|
$('#savePictureChangesBtn').on('click', function() {
|
||||||
$('#change-picture-modal').modal('hide');
|
$('#change-picture-modal').modal('hide');
|
||||||
|
|
||||||
if(selectedImageType) {
|
if (selectedImageType) {
|
||||||
changeUserPicture(selectedImageType);
|
changeUserPicture(selectedImageType);
|
||||||
|
|
||||||
if(selectedImageType == 'gravatar')
|
if (selectedImageType == 'gravatar')
|
||||||
$('#user-current-picture').attr('src', gravatarPicture);
|
$('#user-current-picture').attr('src', gravatarPicture);
|
||||||
else if(selectedImageType == 'uploaded')
|
else if (selectedImageType == 'uploaded')
|
||||||
$('#user-current-picture').attr('src', uploadedPicture);
|
$('#user-current-picture').attr('src', uploadedPicture);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,7 +193,7 @@ $(document).ready(function() {
|
|||||||
$('#userPhotoInput').val('');
|
$('#userPhotoInput').val('');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#uploadPictureBtn').on('click', function(){
|
$('#uploadPictureBtn').on('click', function() {
|
||||||
|
|
||||||
$('#change-picture-modal').modal('hide');
|
$('#change-picture-modal').modal('hide');
|
||||||
$('#upload-picture-modal').modal('show');
|
$('#upload-picture-modal').modal('show');
|
||||||
@@ -226,7 +224,7 @@ $(document).ready(function() {
|
|||||||
password_notify.html('Password too short');
|
password_notify.html('Password too short');
|
||||||
password_notify.attr('class', 'alert alert-danger');
|
password_notify.attr('class', 'alert alert-danger');
|
||||||
password_notify.removeClass('hide');
|
password_notify.removeClass('hide');
|
||||||
} else if(!passwordvalid) {
|
} else if (!passwordvalid) {
|
||||||
password_notify.html('Invalid password');
|
password_notify.html('Invalid password');
|
||||||
password_notify.attr('class', 'alert alert-danger');
|
password_notify.attr('class', 'alert alert-danger');
|
||||||
password_notify.removeClass('hide');
|
password_notify.removeClass('hide');
|
||||||
@@ -240,11 +238,11 @@ $(document).ready(function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onPasswordConfirmChanged() {
|
function onPasswordConfirmChanged() {
|
||||||
if(password_notify.hasClass('alert-danger') || !password_confirm.val()) {
|
if (password_notify.hasClass('alert-danger') || !password_confirm.val()) {
|
||||||
password_confirm_notify.addClass('hide');
|
password_confirm_notify.addClass('hide');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(password.val() !== password_confirm.val()) {
|
if (password.val() !== password_confirm.val()) {
|
||||||
password_confirm_notify.html('Passwords must match!');
|
password_confirm_notify.html('Passwords must match!');
|
||||||
password_confirm_notify.attr('class', 'alert alert-danger');
|
password_confirm_notify.attr('class', 'alert alert-danger');
|
||||||
password_confirm_notify.removeClass('hide');
|
password_confirm_notify.removeClass('hide');
|
||||||
@@ -262,8 +260,11 @@ $(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('');
|
||||||
@@ -273,7 +274,7 @@ $(document).ready(function() {
|
|||||||
passwordsmatch = false;
|
passwordsmatch = false;
|
||||||
passwordvalid = false;
|
passwordvalid = false;
|
||||||
|
|
||||||
if(err) {
|
if (err) {
|
||||||
app.alertError(err.error);
|
app.alertError(err.error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
var settingsLink = $('#settingsLink');
|
var settingsLink = $('#settingsLink');
|
||||||
var favouritesLink = $('#favouritesLink');
|
var favouritesLink = $('#favouritesLink');
|
||||||
|
|
||||||
if(yourid === "0" || yourid !== theirid) {
|
if (yourid === "0" || yourid !== theirid) {
|
||||||
editLink.hide();
|
editLink.hide();
|
||||||
settingsLink.hide();
|
settingsLink.hide();
|
||||||
favouritesLink.hide();
|
favouritesLink.hide();
|
||||||
|
|||||||
@@ -1,16 +1,13 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
$('#submitBtn').on('click', function() {
|
$('#submitBtn').on('click', function() {
|
||||||
|
|
||||||
var settings = {
|
var settings = {
|
||||||
showemail: $('#showemailCheckBox').is(':checked')?1:0
|
showemail: $('#showemailCheckBox').is(':checked') ? 1 : 0
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.emit('api:user.saveSettings', settings, function(success) {
|
socket.emit('api:user.saveSettings', settings, function(success) {
|
||||||
if(success) {
|
if (success) {
|
||||||
app.alertSuccess('Settings saved!');
|
app.alertSuccess('Settings saved!');
|
||||||
} else {
|
} else {
|
||||||
app.alertError('There was an error saving settings!');
|
app.alertError('There was an error saving settings!');
|
||||||
|
|||||||
@@ -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'),
|
||||||
@@ -50,7 +52,7 @@
|
|||||||
topic = topic.querySelector('a');
|
topic = topic.querySelector('a');
|
||||||
|
|
||||||
if (numTopics > 0) {
|
if (numTopics > 0) {
|
||||||
for(x=0;x<numTopics;x++) {
|
for (x = 0; x < numTopics; x++) {
|
||||||
if (topics[x].querySelector('.icon-pushpin')) continue;
|
if (topics[x].querySelector('.icon-pushpin')) continue;
|
||||||
container.insertBefore(topic, topics[x]);
|
container.insertBefore(topic, topics[x]);
|
||||||
$(topic).hide().fadeIn('slow');
|
$(topic).hide().fadeIn('slow');
|
||||||
@@ -78,13 +80,13 @@
|
|||||||
|
|
||||||
var frag = document.createDocumentFragment(),
|
var frag = document.createDocumentFragment(),
|
||||||
li = document.createElement('li');
|
li = document.createElement('li');
|
||||||
for (var i=0,numPosts=posts.length; i<numPosts; i++) {
|
for (var i = 0, numPosts = posts.length; i < numPosts; i++) {
|
||||||
var dateString = utils.relativeTime(posts[i].timestamp);
|
var dateString = utils.relativeTime(posts[i].timestamp);
|
||||||
li.setAttribute('data-pid', posts[i].pid);
|
li.setAttribute('data-pid', posts[i].pid);
|
||||||
|
|
||||||
|
|
||||||
li.innerHTML = '<a href="/users/' + posts[i].userslug + '"><img title="' + posts[i].username + '" style="width: 48px; height: 48px; /*temporary*/" class="img-rounded" src="' + posts[i].picture + '" class="" /></a>' +
|
li.innerHTML = '<a href="/users/' + posts[i].userslug + '"><img title="' + posts[i].username + '" style="width: 48px; height: 48px; /*temporary*/" class="img-rounded" src="' + posts[i].picture + '" class="" /></a>' +
|
||||||
'<a href="/topic/'+ posts[i].topicSlug + '#' + posts[i].pid + '">' +
|
'<a href="/topic/' + posts[i].topicSlug + '#' + posts[i].pid + '">' +
|
||||||
'<p>' +
|
'<p>' +
|
||||||
posts[i].content +
|
posts[i].content +
|
||||||
'</p>' +
|
'</p>' +
|
||||||
@@ -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');
|
||||||
@@ -115,7 +119,7 @@
|
|||||||
cid: cid,
|
cid: cid,
|
||||||
after: $('#topics-container').children().length
|
after: $('#topics-container').children().length
|
||||||
}, function(data) {
|
}, function(data) {
|
||||||
if(data.topics.length) {
|
if (data.topics.length) {
|
||||||
onTopicsLoaded(data.topics);
|
onTopicsLoaded(data.topics);
|
||||||
}
|
}
|
||||||
loadingMoreTopics = false;
|
loadingMoreTopics = false;
|
||||||
|
|||||||
@@ -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'));
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
if(parseInt(followersCount, 10) === 0) {
|
if (parseInt(followersCount, 10) === 0) {
|
||||||
$('#no-followers-notice').removeClass('hide');
|
$('#no-followers-notice').removeClass('hide');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,22 +6,23 @@
|
|||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
if(parseInt(followingCount, 10) === 0) {
|
if (parseInt(followingCount, 10) === 0) {
|
||||||
$('#no-following-notice').removeClass('hide');
|
$('#no-following-notice').removeClass('hide');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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();
|
||||||
app.alertSuccess('You are no longer following ' + username + '!');
|
app.alertSuccess('You are no longer following ' + username + '!');
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -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() {
|
||||||
@@ -49,18 +51,18 @@
|
|||||||
jQuery('.nodebb-loggedout').hide();
|
jQuery('.nodebb-loggedout').hide();
|
||||||
|
|
||||||
var userLabel = rightMenu.find('#user_label');
|
var userLabel = rightMenu.find('#user_label');
|
||||||
if(userLabel.length) {
|
if (userLabel.length) {
|
||||||
if(data['userslug'])
|
if (data['userslug'])
|
||||||
userLabel.attr('href','/users/' + data['userslug']);
|
userLabel.attr('href', '/users/' + data['userslug']);
|
||||||
if(data['picture'])
|
if (data['picture'])
|
||||||
userLabel.find('img').attr('src',data['picture']);
|
userLabel.find('img').attr('src', data['picture']);
|
||||||
if(data['username'])
|
if (data['username'])
|
||||||
userLabel.find('span').html(data['username']);
|
userLabel.find('span').html(data['username']);
|
||||||
} else {
|
} else {
|
||||||
var userli = $('<li> \
|
var userli = $('<li> \
|
||||||
<a id="user_label" href="/users/'+data['userslug']+'"> \
|
<a id="user_label" href="/users/' + data['userslug'] + '"> \
|
||||||
<img src="'+data['picture']+'"/> \
|
<img src="' + data['picture'] + '"/> \
|
||||||
<span>'+data['username']+'</span> \
|
<span>' + data['username'] + '</span> \
|
||||||
</a> \
|
</a> \
|
||||||
</li>');
|
</li>');
|
||||||
rightMenu.append(userli);
|
rightMenu.append(userli);
|
||||||
@@ -102,13 +104,13 @@
|
|||||||
x;
|
x;
|
||||||
notifList.innerHTML = '';
|
notifList.innerHTML = '';
|
||||||
if ((data.read.length + data.unread.length) > 0) {
|
if ((data.read.length + data.unread.length) > 0) {
|
||||||
for(x=0;x<numUnread;x++) {
|
for (x = 0; x < numUnread; x++) {
|
||||||
notifEl.setAttribute('data-nid', data.unread[x].nid);
|
notifEl.setAttribute('data-nid', data.unread[x].nid);
|
||||||
notifEl.className = 'unread';
|
notifEl.className = 'unread';
|
||||||
notifEl.innerHTML = '<a href="' + data.unread[x].path + '"><span class="pull-right">' + utils.relativeTime(data.unread[x].datetime, true) + '</span>' + data.unread[x].text + '</a>';
|
notifEl.innerHTML = '<a href="' + data.unread[x].path + '"><span class="pull-right">' + utils.relativeTime(data.unread[x].datetime, true) + '</span>' + data.unread[x].text + '</a>';
|
||||||
notifFrag.appendChild(notifEl.cloneNode(true));
|
notifFrag.appendChild(notifEl.cloneNode(true));
|
||||||
}
|
}
|
||||||
for(x=0;x<numRead;x++) {
|
for (x = 0; x < numRead; x++) {
|
||||||
notifEl.setAttribute('data-nid', data.read[x].nid);
|
notifEl.setAttribute('data-nid', data.read[x].nid);
|
||||||
notifEl.className = '';
|
notifEl.className = '';
|
||||||
notifEl.innerHTML = '<a href="' + data.read[x].path + '"><span class="pull-right">' + utils.relativeTime(data.read[x].datetime, true) + '</span>' + data.read[x].text + '</a>';
|
notifEl.innerHTML = '<a href="' + data.read[x].path + '"><span class="pull-right">' + utils.relativeTime(data.read[x].datetime, true) + '</span>' + data.read[x].text + '</a>';
|
||||||
@@ -133,10 +135,16 @@
|
|||||||
|
|
||||||
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'));
|
||||||
@@ -161,7 +169,7 @@
|
|||||||
|
|
||||||
require(['chat'], function(chat) {
|
require(['chat'], function(chat) {
|
||||||
var modal = null;
|
var modal = null;
|
||||||
if(chat.modalExists(data.fromuid)) {
|
if (chat.modalExists(data.fromuid)) {
|
||||||
modal = chat.getModal(data.fromuid);
|
modal = chat.getModal(data.fromuid);
|
||||||
chat.appendChatMessage(modal, data.message, data.timestamp);
|
chat.appendChatMessage(modal, data.message, data.timestamp);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -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');
|
||||||
@@ -26,14 +28,14 @@
|
|||||||
url: RELATIVE_PATH + '/login',
|
url: RELATIVE_PATH + '/login',
|
||||||
data: loginData,
|
data: loginData,
|
||||||
success: function(data, textStatus, jqXHR) {
|
success: function(data, textStatus, jqXHR) {
|
||||||
if(!data.success) {
|
if (!data.success) {
|
||||||
$('#login-error-notify').show();
|
$('#login-error-notify').show();
|
||||||
} else {
|
} else {
|
||||||
$('#login-error-notify').hide();
|
$('#login-error-notify').hide();
|
||||||
window.location.replace(RELATIVE_PATH + "/?loggedin");
|
window.location.replace(RELATIVE_PATH + "/?loggedin");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error : function(data, textStatus, jqXHR) {
|
error: function(data, textStatus, jqXHR) {
|
||||||
$('#login-error-notify').show();
|
$('#login-error-notify').show();
|
||||||
},
|
},
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
|
|||||||
@@ -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();
|
||||||
@@ -24,16 +25,16 @@
|
|||||||
function updateAlertText() {
|
function updateAlertText() {
|
||||||
var text = '';
|
var text = '';
|
||||||
|
|
||||||
if(newTopicCount > 1)
|
if (newTopicCount > 1)
|
||||||
text = 'There are ' + newTopicCount + ' new topics';
|
text = 'There are ' + newTopicCount + ' new topics';
|
||||||
else if(newTopicCount === 1)
|
else if (newTopicCount === 1)
|
||||||
text = 'There is 1 new topic';
|
text = 'There is 1 new topic';
|
||||||
else
|
else
|
||||||
text = 'There are no new topics';
|
text = 'There are no new topics';
|
||||||
|
|
||||||
if(newPostCount > 1)
|
if (newPostCount > 1)
|
||||||
text += ' and ' + newPostCount + ' new posts.';
|
text += ' and ' + newPostCount + ' new posts.';
|
||||||
else if(newPostCount === 1)
|
else if (newPostCount === 1)
|
||||||
text += ' and 1 new post.';
|
text += ' and 1 new post.';
|
||||||
else
|
else
|
||||||
text += ' and no new posts.';
|
text += ' and no new posts.';
|
||||||
@@ -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,8 +63,10 @@
|
|||||||
|
|
||||||
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', {
|
||||||
if(data.topics && data.topics.length) {
|
after: $('#topics-container').children().length
|
||||||
|
}, function(data) {
|
||||||
|
if (data.topics && data.topics.length) {
|
||||||
onTopicsLoaded(data.topics);
|
onTopicsLoaded(data.topics);
|
||||||
}
|
}
|
||||||
loadingMoreTopics = false;
|
loadingMoreTopics = false;
|
||||||
|
|||||||
@@ -29,16 +29,17 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function validateEmail() {
|
function validateEmail() {
|
||||||
if(!emailEl.val()) {
|
if (!emailEl.val()) {
|
||||||
validationError = true;
|
validationError = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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() {
|
||||||
@@ -46,19 +47,21 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
function validateUsername() {
|
function validateUsername() {
|
||||||
if(!username.val()) {
|
if (!username.val()) {
|
||||||
validationError = true;
|
validationError = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(username.val().length < config.minimumUsernameLength) {
|
if (username.val().length < config.minimumUsernameLength) {
|
||||||
showError(username_notify, 'Username too short!');
|
showError(username_notify, 'Username too short!');
|
||||||
} else if(username.val().length > config.maximumUsernameLength) {
|
} else if (username.val().length > config.maximumUsernameLength) {
|
||||||
showError(username_notify, 'Username too long!');
|
showError(username_notify, 'Username too long!');
|
||||||
} 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()
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,20 +73,20 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
function validatePassword() {
|
function validatePassword() {
|
||||||
if(!password.val()){
|
if (!password.val()) {
|
||||||
validationError = true;
|
validationError = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (password.val().length < config.minimumPasswordLength) {
|
if (password.val().length < config.minimumPasswordLength) {
|
||||||
showError(password_notify, 'Password too short!');
|
showError(password_notify, 'Password too short!');
|
||||||
} else if(!utils.isPasswordValid(password.val())) {
|
} else if (!utils.isPasswordValid(password.val())) {
|
||||||
showError(password_notify, 'Invalid password!');
|
showError(password_notify, 'Invalid password!');
|
||||||
} else {
|
} else {
|
||||||
showSuccess(password_notify, successIcon);
|
showSuccess(password_notify, successIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(password.val() !== password_confirm.val() && password_confirm.val() !== '') {
|
if (password.val() !== password_confirm.val() && password_confirm.val() !== '') {
|
||||||
showError(password_confirm_notify, 'Passwords must match!');
|
showError(password_confirm_notify, 'Passwords must match!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -93,11 +96,11 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
function validatePasswordConfirm() {
|
function validatePasswordConfirm() {
|
||||||
if(!password.val() || password_notify.hasClass('alert-error')) {
|
if (!password.val() || password_notify.hasClass('alert-error')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(password.val() !== password_confirm.val()) {
|
if (password.val() !== password_confirm.val()) {
|
||||||
showError(password_confirm_notify, 'Passwords must match!');
|
showError(password_confirm_notify, 'Passwords must match!');
|
||||||
} else {
|
} else {
|
||||||
showSuccess(password_confirm_notify, successIcon);
|
showSuccess(password_confirm_notify, successIcon);
|
||||||
|
|||||||
@@ -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();
|
||||||
@@ -26,7 +28,7 @@
|
|||||||
} else {
|
} else {
|
||||||
jQuery('#success').hide();
|
jQuery('#success').hide();
|
||||||
jQuery(errorEl).show();
|
jQuery(errorEl).show();
|
||||||
switch(data.message) {
|
switch (data.message) {
|
||||||
case 'invalid-email':
|
case 'invalid-email':
|
||||||
errorTextEl.innerHTML = 'The email you put in (<span>' + data.email + '</span>) is not registered with us. Please try again.';
|
errorTextEl.innerHTML = 'The email you put in (<span>' + data.email + '</span>) is not registered with us. Please try again.';
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -18,17 +18,22 @@
|
|||||||
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']);
|
||||||
socket.on('user:reset.valid', function(data) {
|
socket.on('user:reset.valid', function(data) {
|
||||||
if (!!data.valid) resetEl.disabled = false;
|
if ( !! data.valid) resetEl.disabled = false;
|
||||||
else {
|
else {
|
||||||
var formEl = document.getElementById('reset-form');
|
var formEl = document.getElementById('reset-form');
|
||||||
// Show error message
|
// Show error message
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
$('.search-result-text').each(function() {
|
$('.search-result-text').each(function() {
|
||||||
var text = $(this).html();
|
var text = $(this).html();
|
||||||
var regex = new RegExp(searchQuery, 'gi');
|
var regex = new RegExp(searchQuery, 'gi');
|
||||||
text = text.replace(regex, '<span class="label label-success">'+searchQuery+'</span>');
|
text = text.replace(regex, '<span class="label label-success">' + searchQuery + '</span>');
|
||||||
$(this).html(text);
|
$(this).html(text);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
});
|
});
|
||||||
@@ -85,7 +97,7 @@
|
|||||||
x, info, targetCid, targetCatLabel;
|
x, info, targetCid, targetCatLabel;
|
||||||
|
|
||||||
categoriesEl.className = 'category-list';
|
categoriesEl.className = 'category-list';
|
||||||
for(x=0;x<numCategories;x++) {
|
for (x = 0; x < numCategories; x++) {
|
||||||
info = data.categories[x];
|
info = data.categories[x];
|
||||||
categoryEl.className = info.blockclass;
|
categoryEl.className = info.blockclass;
|
||||||
categoryEl.innerHTML = '<i class="' + info.icon + '"></i> ' + info.name;
|
categoryEl.innerHTML = '<i class="' + info.icon + '"></i> ' + info.name;
|
||||||
@@ -132,7 +144,10 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
socket.emit('api:topic.move', { tid: tid, cid: targetCid });
|
socket.emit('api:topic.move', {
|
||||||
|
tid: tid,
|
||||||
|
cid: targetCid
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -143,7 +158,7 @@
|
|||||||
|
|
||||||
// Fix delete state for this thread's posts
|
// Fix delete state for this thread's posts
|
||||||
var postEls = document.querySelectorAll('#post-container li[data-deleted]');
|
var postEls = document.querySelectorAll('#post-container li[data-deleted]');
|
||||||
for(var x=0,numPosts=postEls.length;x<numPosts;x++) {
|
for (var x = 0, numPosts = postEls.length; x < numPosts; x++) {
|
||||||
if (postEls[x].getAttribute('data-deleted') === '1') toggle_post_delete_state(postEls[x].getAttribute('data-pid'));
|
if (postEls[x].getAttribute('data-deleted') === '1') toggle_post_delete_state(postEls[x].getAttribute('data-pid'));
|
||||||
postEls[x].removeAttribute('data-deleted');
|
postEls[x].removeAttribute('data-deleted');
|
||||||
}
|
}
|
||||||
@@ -194,7 +209,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
socket.emit('api:topic.followCheck', tid);
|
socket.emit('api:topic.followCheck', tid);
|
||||||
if(followEl[0]) {
|
if (followEl[0]) {
|
||||||
followEl[0].addEventListener('click', function() {
|
followEl[0].addEventListener('click', function() {
|
||||||
socket.emit('api:topic.follow', tid);
|
socket.emit('api:topic.follow', tid);
|
||||||
}, false);
|
}, false);
|
||||||
@@ -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
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -251,11 +268,16 @@
|
|||||||
var uid = $(this).parents('li').attr('data-uid');
|
var uid = $(this).parents('li').attr('data-uid');
|
||||||
|
|
||||||
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
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -285,7 +311,7 @@
|
|||||||
var username = $(this).parents('li.row').attr('data-username');
|
var username = $(this).parents('li.row').attr('data-username');
|
||||||
var touid = $(this).parents('li.row').attr('data-uid');
|
var touid = $(this).parents('li.row').attr('data-uid');
|
||||||
|
|
||||||
if(username === app.username || !app.username)
|
if (username === app.username || !app.username)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
app.openChat(username, touid);
|
app.openChat(username, touid);
|
||||||
@@ -302,7 +328,7 @@
|
|||||||
|
|
||||||
socket.on('api:get_users_in_room', function(data) {
|
socket.on('api:get_users_in_room', function(data) {
|
||||||
var activeEl = $('#thread_active_users');
|
var activeEl = $('#thread_active_users');
|
||||||
if(activeEl.length)
|
if (activeEl.length)
|
||||||
activeEl.html(data);
|
activeEl.html(data);
|
||||||
|
|
||||||
app.populate_online_users();
|
app.populate_online_users();
|
||||||
@@ -363,9 +389,9 @@
|
|||||||
socket.on('event:post_edited', function(data) {
|
socket.on('event:post_edited', function(data) {
|
||||||
var editedPostEl = document.getElementById('content_' + data.pid);
|
var editedPostEl = document.getElementById('content_' + data.pid);
|
||||||
|
|
||||||
var editedPostTitle = $('#topic_title_'+data.pid);
|
var editedPostTitle = $('#topic_title_' + data.pid);
|
||||||
|
|
||||||
if(editedPostTitle.length > 0) {
|
if (editedPostTitle.length > 0) {
|
||||||
editedPostTitle.fadeOut(250, function() {
|
editedPostTitle.fadeOut(250, function() {
|
||||||
editedPostTitle.html(data.title);
|
editedPostTitle.html(data.title);
|
||||||
editedPostTitle.fadeIn(250);
|
editedPostTitle.fadeIn(250);
|
||||||
@@ -377,14 +403,14 @@
|
|||||||
$(this).fadeIn(250);
|
$(this).fadeIn(250);
|
||||||
});
|
});
|
||||||
|
|
||||||
if(data.uploadedImages && data.uploadedImages.length) {
|
if (data.uploadedImages && data.uploadedImages.length) {
|
||||||
$('#images_'+data.pid).html('');
|
$('#images_' + data.pid).html('');
|
||||||
for(var i=0; i< data.uploadedImages.length; ++i) {
|
for (var i = 0; i < data.uploadedImages.length; ++i) {
|
||||||
var img = $('<i class="icon-picture icon-1"></i><a href="' + data.uploadedImages[i].url +'"> '+data.uploadedImages[i].name+'</a><br/>');
|
var img = $('<i class="icon-picture icon-1"></i><a href="' + data.uploadedImages[i].url + '"> ' + data.uploadedImages[i].name + '</a><br/>');
|
||||||
$('#images_' + data.pid).append(img);
|
$('#images_' + data.pid).append(img);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$('#images_'+data.pid).html('');
|
$('#images_' + data.pid).html('');
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('time to recreate images', data);
|
console.log('time to recreate images', data);
|
||||||
@@ -432,8 +458,8 @@
|
|||||||
ptotal += value;
|
ptotal += value;
|
||||||
utotal += value;
|
utotal += value;
|
||||||
|
|
||||||
post_rep.html(ptotal+ ' ');
|
post_rep.html(ptotal + ' ');
|
||||||
user_rep.html(utotal+ ' ');
|
user_rep.html(utotal + ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_locked_state(locked, alert) {
|
function set_locked_state(locked, alert) {
|
||||||
@@ -450,7 +476,7 @@
|
|||||||
lockThreadEl.innerHTML = '<i class="icon-unlock"></i> Unlock Thread';
|
lockThreadEl.innerHTML = '<i class="icon-unlock"></i> Unlock Thread';
|
||||||
threadReplyBtn.disabled = true;
|
threadReplyBtn.disabled = true;
|
||||||
threadReplyBtn.innerHTML = 'Locked <i class="icon-lock"></i>';
|
threadReplyBtn.innerHTML = 'Locked <i class="icon-lock"></i>';
|
||||||
for(x=0;x<numPosts;x++) {
|
for (x = 0; x < numPosts; x++) {
|
||||||
postReplyBtns[x].innerHTML = 'Locked <i class="icon-lock"></i>';
|
postReplyBtns[x].innerHTML = 'Locked <i class="icon-lock"></i>';
|
||||||
quoteBtns[x].style.display = 'none';
|
quoteBtns[x].style.display = 'none';
|
||||||
editBtns[x].style.display = 'none';
|
editBtns[x].style.display = 'none';
|
||||||
@@ -472,7 +498,7 @@
|
|||||||
lockThreadEl.innerHTML = '<i class="icon-lock"></i> Lock Thread';
|
lockThreadEl.innerHTML = '<i class="icon-lock"></i> Lock Thread';
|
||||||
threadReplyBtn.disabled = false;
|
threadReplyBtn.disabled = false;
|
||||||
threadReplyBtn.innerHTML = 'Reply';
|
threadReplyBtn.innerHTML = 'Reply';
|
||||||
for(x=0;x<numPosts;x++) {
|
for (x = 0; x < numPosts; x++) {
|
||||||
postReplyBtns[x].innerHTML = 'Reply <i class="icon-reply"></i>';
|
postReplyBtns[x].innerHTML = 'Reply <i class="icon-reply"></i>';
|
||||||
quoteBtns[x].style.display = 'inline-block';
|
quoteBtns[x].style.display = 'inline-block';
|
||||||
editBtns[x].style.display = 'inline-block';
|
editBtns[x].style.display = 'inline-block';
|
||||||
@@ -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) {
|
||||||
@@ -667,7 +692,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
if(scrollTop + windowHeight == jQuery(document).height()) {
|
if (scrollTop + windowHeight == jQuery(document).height()) {
|
||||||
pagination.innerHTML = postcount + ' out of ' + postcount;
|
pagination.innerHTML = postcount + ' out of ' + postcount;
|
||||||
}
|
}
|
||||||
}, 100);
|
}, 100);
|
||||||
|
|||||||
@@ -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();
|
||||||
@@ -24,16 +25,16 @@
|
|||||||
function updateAlertText() {
|
function updateAlertText() {
|
||||||
var text = '';
|
var text = '';
|
||||||
|
|
||||||
if(newTopicCount > 1)
|
if (newTopicCount > 1)
|
||||||
text = 'There are ' + newTopicCount + ' new topics';
|
text = 'There are ' + newTopicCount + ' new topics';
|
||||||
else if(newTopicCount === 1)
|
else if (newTopicCount === 1)
|
||||||
text = 'There is 1 new topic';
|
text = 'There is 1 new topic';
|
||||||
else
|
else
|
||||||
text = 'There are no new topics';
|
text = 'There are no new topics';
|
||||||
|
|
||||||
if(newPostCount > 1)
|
if (newPostCount > 1)
|
||||||
text += ' and ' + newPostCount + ' new posts.';
|
text += ' and ' + newPostCount + ' new posts.';
|
||||||
else if(newPostCount === 1)
|
else if (newPostCount === 1)
|
||||||
text += ' and 1 new post.';
|
text += ' and 1 new post.';
|
||||||
else
|
else
|
||||||
text += ' and no new posts.';
|
text += ' and no new posts.';
|
||||||
@@ -50,8 +51,8 @@
|
|||||||
|
|
||||||
$('#mark-allread-btn').on('click', function() {
|
$('#mark-allread-btn').on('click', function() {
|
||||||
var btn = $(this);
|
var btn = $(this);
|
||||||
socket.emit('api:topics.markAllRead', {} , function(success) {
|
socket.emit('api:topics.markAllRead', {}, function(success) {
|
||||||
if(success) {
|
if (success) {
|
||||||
btn.remove();
|
btn.remove();
|
||||||
$('#topics-container').empty();
|
$('#topics-container').empty();
|
||||||
$('#category-no-topics').removeClass('hidden');
|
$('#category-no-topics').removeClass('hidden');
|
||||||
@@ -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,8 +81,10 @@
|
|||||||
|
|
||||||
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', {
|
||||||
if(data.topics && data.topics.length) {
|
after: parseInt($('#topics-container').attr('data-next-start'), 10)
|
||||||
|
}, function(data) {
|
||||||
|
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);
|
||||||
} else {
|
} else {
|
||||||
@@ -99,7 +104,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if($("body").height() <= $(window).height() && $('#topics-container').children().length >= 20)
|
if ($("body").height() <= $(window).height() && $('#topics-container').children().length >= 20)
|
||||||
$('#load-more-btn').show();
|
$('#load-more-btn').show();
|
||||||
|
|
||||||
$('#load-more-btn').on('click', function() {
|
$('#load-more-btn').on('click', function() {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
var url = window.location.href,
|
var url = window.location.href,
|
||||||
parts = url.split('/'),
|
parts = url.split('/'),
|
||||||
active = parts[parts.length-1];
|
active = parts[parts.length - 1];
|
||||||
|
|
||||||
var lastSearch = null;
|
var lastSearch = null;
|
||||||
|
|
||||||
@@ -20,8 +20,8 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
jQuery('#search-user').on('keyup', function () {
|
jQuery('#search-user').on('keyup', function() {
|
||||||
if(timeoutId !== 0) {
|
if (timeoutId !== 0) {
|
||||||
clearTimeout(timeoutId);
|
clearTimeout(timeoutId);
|
||||||
timeoutId = 0;
|
timeoutId = 0;
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
socket.removeAllListeners('api:admin.user.search');
|
socket.removeAllListeners('api:admin.user.search');
|
||||||
|
|
||||||
socket.on('api:admin.user.search', function(data) {
|
socket.on('api:admin.user.search', function(data) {
|
||||||
if(data === null) {
|
if (data === null) {
|
||||||
$('#user-notfound-notify').html('You need to be logged in to search!');
|
$('#user-notfound-notify').html('You need to be logged in to search!');
|
||||||
$('#user-notfound-notify').parent().addClass('btn-warning label-warning');
|
$('#user-notfound-notify').parent().addClass('btn-warning label-warning');
|
||||||
return;
|
return;
|
||||||
@@ -64,12 +64,11 @@
|
|||||||
userListEl.innerHTML = html;
|
userListEl.innerHTML = html;
|
||||||
|
|
||||||
|
|
||||||
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,27 +77,29 @@
|
|||||||
|
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadMoreUsers() {
|
function loadMoreUsers() {
|
||||||
var set = '';
|
var set = '';
|
||||||
if(active === 'users-latest' || active === 'users') {
|
if (active === 'users-latest' || active === 'users') {
|
||||||
set = 'users:joindate';
|
set = 'users:joindate';
|
||||||
} else if(active === 'users-sort-posts') {
|
} else if (active === 'users-sort-posts') {
|
||||||
set = 'users:postcount';
|
set = 'users:postcount';
|
||||||
} else if(active === 'users-sort-reputation') {
|
} else if (active === 'users-sort-reputation') {
|
||||||
set = 'users:reputation';
|
set = 'users:reputation';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(set) {
|
if (set) {
|
||||||
loadingMoreUsers = true;
|
loadingMoreUsers = true;
|
||||||
socket.emit('api:users.loadMore', {
|
socket.emit('api:users.loadMore', {
|
||||||
set: set,
|
set: set,
|
||||||
after: $('#users-container').children().length
|
after: $('#users-container').children().length
|
||||||
}, function(data) {
|
}, function(data) {
|
||||||
if(data.users.length) {
|
if (data.users.length) {
|
||||||
onUsersLoaded(data.users);
|
onUsersLoaded(data.users);
|
||||||
} else {
|
} else {
|
||||||
$('#load-more-users-btn').addClass('disabled');
|
$('#load-more-users-btn').addClass('disabled');
|
||||||
|
|||||||
Reference in New Issue
Block a user