diff options
| author | Scott Ostler <sostler@deathmachine.local> | 2010-02-24 09:55:06 -0500 |
|---|---|---|
| committer | Scott Ostler <sostler@deathmachine.local> | 2010-02-24 09:55:06 -0500 |
| commit | c3a98fda15c707f3718e30cf1abb30c1ea042df8 (patch) | |
| tree | 6910f43ab4b1181ecf5b92e92ed7f8090663bb5b /static/js | |
| parent | c4b8c62ffe424e8c3b45519d113905384f3b9b87 (diff) | |
Added edit-toggle to profile
Diffstat (limited to 'static/js')
| -rwxr-xr-x | static/js/pichat.js | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/static/js/pichat.js b/static/js/pichat.js index 071e8e6..d348d93 100755 --- a/static/js/pichat.js +++ b/static/js/pichat.js @@ -240,18 +240,12 @@ function initChat() { setTimeout(refresh, 1000); } -function initProfile() { - jQuery(".linkify").each(function() { - var text = jQuery(this).text(); - jQuery(this).html(linkify(text)); - }); - - - $('.logged-dump .content').each(function() { - var t = $(this); - t.html(buildMsgContent(t.text())); - }); +function makePlainText() { + var j = $(this); + j.text(j.text()); +} +function enableProfileEdit() { var onSubmit = function(attr, newVal, oldVal) { newVal = $.trim(newVal); if (newVal == oldVal) { return oldVal }; @@ -273,22 +267,43 @@ function initProfile() { return escapeHtml(newVal); }; + $('#avatar-editing').show(); + var avatarOpts = { 'default_text': 'Enter here!', 'callback': onSubmit, 'field_type': 'text', 'callbackShowErrors': false }; $('#avatar.editable').editInPlace(avatarOpts); + if ($('#upload').length > 0) { + setupUploadAvatar('upload'); + } + var textareaOpts = { 'default_text': 'Enter here!', 'callback': onSubmit, 'field_type': 'textarea', - 'callbackShowErrors': false }; - $('#contact.editable, #bio.editable').editInPlace(textareaOpts); + 'callbackShowErrors': false }; + $('#contact, #bio') + .addClass('editable') + .editInPlace(textareaOpts) + .each(makePlainText); - if ($('#upload').length > 0) { - setupUploadAvatar('upload'); - } + var resetPage = function() { location.reload() }; + $('#edit-toggle a').text('--> Done editing <--').click(resetPage); +} +function initProfile() { + $(".linkify").each(function() { + var text = jQuery(this).text(); + jQuery(this).html(linkify(text)); + }); + + $('#edit-toggle').click(enableProfileEdit); + + $('.logged-dump .content').each(function() { + var t = $(this); + t.html(buildMsgContent(t.text())); + }); }; function initLog() { @@ -331,9 +346,9 @@ function setupUploadAvatar(elementId) { var onComplete = function(file, resp) { $('#spinner').hide(); if (resp == 'INVALID_REQUEST') { - location.href = location.href; + location.reload(); } else if (resp == 'NOT_LOGGED_IN') { - location.href = location.href; + location.reload(); } else if (resp == 'INVALID_IMAGE') { alert("Sorry, dump.fm can't deal with your image. Pick another :("); return; |
