From f3b32cefcec1db03b2fb27a7ece322eccf125927 Mon Sep 17 00:00:00 2001 From: Scott Ostler Date: Thu, 25 Feb 2010 20:13:46 -0500 Subject: Split apart enableProfileEdit --- static/js/pichat.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'static/js') diff --git a/static/js/pichat.js b/static/js/pichat.js index d348d93..b847f58 100755 --- a/static/js/pichat.js +++ b/static/js/pichat.js @@ -61,7 +61,6 @@ function buildMessageDiv(msg, isLoading) { } function buildUserDiv(user) { - console.warn(user); if (user.avatar) { return '
' + '' @@ -166,7 +165,6 @@ function updateUI(msgs, users) { } if (users !== null) { var flattened = flattenUserJson(users); - console.log(flattened); if (!('userlist' in cache) || flattened != cache.userlist) { $("#userList").html($.map(users, buildUserDiv).join('')); } @@ -245,11 +243,11 @@ function makePlainText() { j.text(j.text()); } -function enableProfileEdit() { +function activateProfileEditable() { var onSubmit = function(attr, newVal, oldVal) { newVal = $.trim(newVal); if (newVal == oldVal) { return oldVal }; - + $.ajax({ type: "POST", timeout: 5000, @@ -267,29 +265,30 @@ function enableProfileEdit() { return escapeHtml(newVal); }; - $('#avatar-editing').show(); - - var avatarOpts = { 'default_text': 'Enter here!', + var avatarOpts = { 'default_text': 'Paste URL here!', 'callback': onSubmit, 'field_type': 'text', 'callbackShowErrors': false }; - $('#avatar.editable').editInPlace(avatarOpts); - - if ($('#upload').length > 0) { + if ($('#avatar.editable').length > 0) { + $('#avatar.editable').editInPlace(avatarOpts); setupUploadAvatar('upload'); } var textareaOpts = { 'default_text': 'Enter here!', 'callback': onSubmit, 'field_type': 'textarea', - 'callbackShowErrors': false }; - $('#contact, #bio') - .addClass('editable') + 'callbackShowErrors': false }; + $('#contact.editable, #bio.editable') .editInPlace(textareaOpts) .each(makePlainText); +} +function enableProfileEdit() { + $('#contact, #bio, #avatar').addClass('editable'); + $('#avatar-editing').show(); var resetPage = function() { location.reload() }; $('#edit-toggle a').text('--> Done editing <--').click(resetPage); + activateProfileEditable(); } function initProfile() { @@ -299,6 +298,7 @@ function initProfile() { }); $('#edit-toggle').click(enableProfileEdit); + activateProfileEditable(); $('.logged-dump .content').each(function() { var t = $(this); -- cgit v1.2.3-70-g09d2