fixed the chat modal

v1.18.x
psychobunny 12 years ago
parent 4307229ae0
commit b5a26696f8

@ -141,15 +141,10 @@ footer.footer {
} }
#chat-content { #chat-content {
width:95%;
height:200px; height:200px;
resize:none; resize:none;
} }
#chat-message-input {
width:95%;
}
#content{ #content{
padding-bottom:20px; padding-bottom:20px;
} }

@ -4,52 +4,53 @@ var gravatarPicture = templates.get('gravatarpicture');
var uploadedPicture = templates.get('uploadedpicture'); var uploadedPicture = templates.get('uploadedpicture');
$(document).ready(function() { $(document).ready(function() {
$('#uploadForm').submit(function() { $('#uploadForm').submit(function() {
status('uploading the file ...'); status('uploading the file ...');
$('#upload-progress-bar').css('width', '0%'); $('#upload-progress-bar').css('width', '0%');
$('#upload-progress-box').show(); $('#upload-progress-box').show();
$('#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;
} }
$(this).find('#imageUploadCsrf').val($('#csrf_token').val()); $(this).find('#imageUploadCsrf').val($('#csrf_token').val());
$(this).ajaxSubmit({ $(this).ajaxSubmit({
error: function(xhr) { error: function(xhr) {
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;
} }
var imageUrlOnServer = response.path; var imageUrlOnServer = response.path;
$('#user-current-picture').attr('src', imageUrlOnServer); $('#user-current-picture').attr('src', imageUrlOnServer);
$('#user-uploaded-picture').attr('src', imageUrlOnServer); $('#user-uploaded-picture').attr('src', imageUrlOnServer);
uploadedPicture = imageUrlOnServer; uploadedPicture = imageUrlOnServer;
setTimeout(function() { setTimeout(function() {
hideAlerts(); hideAlerts();
$('#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!');
} }
@ -57,45 +58,45 @@ $(document).ready(function() {
return false; return false;
}); });
function hideAlerts() { function hideAlerts() {
$('#alert-status').hide(); $('#alert-status').hide();
$('#alert-success').hide(); $('#alert-success').hide();
$('#alert-error').hide(); $('#alert-error').hide();
$('#upload-progress-box').hide(); $('#upload-progress-box').hide();
} }
function status(message) { function status(message) {
hideAlerts(); hideAlerts();
$('#alert-status').text(message).show(); $('#alert-status').text(message).show();
} }
function success(message) { function success(message) {
hideAlerts(); hideAlerts();
$('#alert-success').text(message).show(); $('#alert-success').text(message).show();
} }
function error(message) { function error(message) {
hideAlerts(); hideAlerts();
$('#alert-error').text(message).show(); $('#alert-error').text(message).show();
} }
function changeUserPicture(type) { function changeUserPicture(type) {
var userData = { var userData = {
type: type type: type
}; };
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!');
} }
}); });
} }
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(),
@ -116,14 +117,14 @@ $(document).ready(function() {
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;
} }
} else { } else {
app.alertError('There was an error updating your profile!'); app.alertError('There was an error updating your profile!');
} }
}); });
return false; return false;
}); });
function updateImages() { function updateImages() {
var currentPicture = $('#user-current-picture').attr('src'); var currentPicture = $('#user-current-picture').attr('src');
@ -140,73 +141,75 @@ $(document).ready(function() {
} }
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();
} }
$('#changePictureBtn').on('click', function() { $('#changePictureBtn').on('click', function() {
selectedImageType = ''; selectedImageType = '';
updateImages(); updateImages();
$('#change-picture-modal').modal('show'); $('#change-picture-modal').modal('show');
$('#change-picture-modal').removeClass('hide');
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';
}); });
$('#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);
} }
}); });
$('#upload-picture-modal').on('hide', function() { $('#upload-picture-modal').on('hide', 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');
$('#upload-picture-modal').removeClass('hide');
hideAlerts(); hideAlerts();
return false; return false;
}); });
$('#pictureUploadSubmitBtn').on('click', function() { $('#pictureUploadSubmitBtn').on('click', function() {
$('#uploadForm').submit(); $('#uploadForm').submit();
}); });
(function handlePasswordChange() { (function handlePasswordChange() {
var currentPassword = $('#inputCurrentPassword'); var currentPassword = $('#inputCurrentPassword');
var password_notify = $('#password-notify'); var password_notify = $('#password-notify');
@ -229,7 +232,7 @@ $(document).ready(function() {
password_notify.html('OK!'); password_notify.html('OK!');
password_notify.attr('class', 'label label-success'); password_notify.attr('class', 'label label-success');
} }
onPasswordConfirmChanged(); onPasswordConfirmChanged();
} }
@ -249,10 +252,10 @@ $(document).ready(function() {
password_confirm.on('keyup', onPasswordConfirmChanged); password_confirm.on('keyup', onPasswordConfirmChanged);
$('#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(data) { socket.emit('api:user.changePassword', {'currentPassword': currentPassword.val(),'newPassword': password.val() }, function(data) {
currentPassword.val(''); currentPassword.val('');
password.val(''); password.val('');
password_confirm.val(''); password_confirm.val('');
@ -260,18 +263,18 @@ $(document).ready(function() {
password_confirm_notify.html(''); password_confirm_notify.html('');
passwordsmatch = false; passwordsmatch = false;
passwordvalid = false; passwordvalid = false;
if(data.err) { if(data.err) {
app.alertError(data.err); app.alertError(data.err);
return; return;
} }
app.alertSuccess('Your password is updated!'); app.alertSuccess('Your password is updated!');
}); });
} }
return false; return false;
}); });
}()); }());
}); });

@ -281,17 +281,16 @@
}); });
$('.topic-buttons').delegate('.chat', 'click', function(e) { $('.topic-buttons').delegate('.chat', 'click', function(e) {
var username = $(this).parents('li').attr('data-username'); var username = $(this).parents('li.row').attr('data-username');
var touid = $(this).parents('li').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;
require(['chat'], function(chat) { require(['chat'], function(chat) {
var chatModal = chat.createModalIfDoesntExist(username, touid); var chatModal = chat.createModalIfDoesntExist(username, touid);
chatModal.show(); chatModal.modal();
chat.bringModalToTop(chatModal); chat.bringModalToTop(chatModal); // I don't think this is necessary
}); });
}); });

@ -14,17 +14,26 @@
</div> </div>
</div> </div>
<div id="chat-modal" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header"> <div id="chat-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <div class="modal-dialog">
<h3 id="myModalLabel">Chat with <span id="chat-with-name"></span></h3> <div class="modal-content">
</div> <div class="modal-header">
<div class="modal-body"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<textarea id="chat-content" cols="40" rows="10" readonly></textarea><br/> <h3 id="myModalLabel">Chat with <span id="chat-with-name"></span></h3>
<input id="chat-message-input" type="text" name="chat-message" placeholder="type chat message here press enter to send"/><br/> </div>
<button type="button" id="chat-message-send-btn" href="#" class="btn btn-primary">Send</button> <div class="modal-body">
</div> <textarea class="form-control" id="chat-content" cols="40" rows="10" readonly></textarea><br/>
</div> <input id="chat-message-input" type="text" class="form-control" name="chat-message" placeholder="type chat message, here press enter to send"/>
</div>
<div class="modal-footer">
<button type="button" id="chat-message-send-btn" href="#" class="btn btn-primary btn-lg btn-block
">Send</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<div id="alert_window"></div> <div id="alert_window"></div>

Loading…
Cancel
Save