From c3a98fda15c707f3718e30cf1abb30c1ea042df8 Mon Sep 17 00:00:00 2001 From: Scott Ostler Date: Wed, 24 Feb 2010 09:55:06 -0500 Subject: Added edit-toggle to profile --- static/js/pichat.js | 51 +++++++++++++++++---------- template/profile.st | 99 +++++++++++++++++++++++++++-------------------------- 2 files changed, 83 insertions(+), 67 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); + + var resetPage = function() { location.reload() }; + $('#edit-toggle a').text('--> Done editing <--').click(resetPage); +} - if ($('#upload').length > 0) { - setupUploadAvatar('upload'); - } +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; diff --git a/template/profile.st b/template/profile.st index b5d3f38..52b745c 100755 --- a/template/profile.st +++ b/template/profile.st @@ -34,59 +34,60 @@ $dumps:{ d | $logged_dump(dump=d)$ }$ -
- -

$nick$

- - $if(avatar)$ - - $else$ - - $endif$ - - $if(is_home)$ -
$avatar$
- - - $endif$ - - - $if(is_home)$ -

contact info

-
$contact$
- $elseif(contact)$ -

contact info

-
$contact$
- $else$ -

-
- $endif$ - - -
- - $if(is_home)$ -

bio

-
$bio$
- $elseif(bio)$ -

bio

-
$bio$
- $else$ -
- $endif$ - - -
-
-
-
+
+ +

$nick$

+ $if(avatar)$ + + $else$ + + $endif$ + + $if(is_home)$ + + $endif$ + + $endif$ + +

contact info

+ $if(contact)$ +
$contact$
+ $else$ +

+
+ $endif$ +
+ +

bio

+ $if(bio)$ +
$bio$
+ $else$ +
+ $endif$ + + $if(is_home)$ +
+ + $endif$ + + +
+
+
+
$else$

 

 

-

 

 

 

-

 

-

☺✌ Welcome to dump.fm ✌☺

+

 

+

 

+

 

+
+

☺✌ Welcome to dump.fm ✌☺



-- cgit v1.2.3-70-g09d2