From 7db1da935ab48f1662e8e682ff0f5428bd8e262d Mon Sep 17 00:00:00 2001 From: Raphael Date: Sun, 21 Nov 2010 13:21:42 -0500 Subject: [PATCH] Stream is a class --- .gitignore | 1 + app/views/js/_websocket_js.haml | 34 +++++++++++-------- app/views/people/index.html.haml | 2 +- app/views/photos/show.html.haml | 2 +- .../requests/_manage_aspect_contacts.haml | 8 ++--- app/views/shared/_stream.haml | 2 +- app/views/status_messages/show.html.haml | 2 +- .../users/getting_started/_step_3.html.haml | 2 +- features/step_definitions/custom_web_steps.rb | 2 +- public/javascripts/stream.js | 6 ++-- public/javascripts/view.js | 7 ++-- public/stylesheets/sass/application.sass | 8 ++--- 12 files changed, 41 insertions(+), 35 deletions(-) diff --git a/.gitignore b/.gitignore index ab2b27011..db6a9121b 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ public/uploads/* public/assets/* public/source.tar* tmp/**/* +tmp/* db/*.sqlite3 .redcar diff --git a/app/views/js/_websocket_js.haml b/app/views/js/_websocket_js.haml index c13680512..1ee98475f 100644 --- a/app/views/js/_websocket_js.haml +++ b/app/views/js/_websocket_js.haml @@ -16,13 +16,9 @@ processNotification(obj['notice']); }else if (obj['class'] == 'people'){ - $('#loader').hide(); debug("got a " + obj['class']); - if(obj['status'] == 'fail'){ - $('#request_result li:first').show().$('#message').text(obj['response']).show(); - }else{ - processPerson(obj['html']); - } + processPerson(obj); + }else{ debug("got a " + obj['class'] + " for aspects " + obj['aspect_ids']); @@ -46,12 +42,20 @@ }; }); - function processPerson(html){ - $('.people#stream').prepend(html).slideDown('slow', function(){}); - var rr = $('#request_result li:first'); - rr.after(html); - $("#request_result [name='into']").val(rr.attr('aspect_id')); - $('#request_result :nth-child(2)').slideDown('fast', function(){}); + function processPerson(response){ + form = $('.webfinger_form:visible'); + form.siblings('.spinner').hide(); + result_ul = form.siblings('.webfinger_result'); + if(response['status'] == 'fail'){ + result_ul.children('.error').show(); + result_ul.children('.webfinger_error').text(response['response']).show(); + }else{ + //result_ul.prepend(response['html']).slideDown('slow', function(){}); + var first_li = result_ul.find('li:first'); + first_li.after(response['html']); + result_ul.children("[name='into']").val(first_li.attr('aspect_id')); + result_ul.children(':nth-child(2)').slideDown('fast', function(){}); + } } function processNotification(html){ @@ -60,7 +64,7 @@ function processRetraction(post_id){ $("*[data-guid='"+post_id+"']").fadeOut(400, function(){$(this).remove()}); - if($("#stream")[0].childElementCount == 0){ + if($("#main_stream")[0].childElementCount == 0){ $("#no_posts").fadeIn(200); } } @@ -89,9 +93,9 @@ function processPost(className, html, aspectIds){ if(onPageForAspects(aspectIds)){ var addPostToStream = function (html){ - $("#stream:not('.show')").prepend( + $("#main_stream:not('.show')").prepend( $(html).fadeIn("fast", function(){ - $("#stream").find("label").first().inFieldLabels(); + $("#main_stream").find("label").first().inFieldLabels(); }) ) }; diff --git a/app/views/people/index.html.haml b/app/views/people/index.html.haml index cf6bb2a55..a61655391 100644 --- a/app/views/people/index.html.haml +++ b/app/views/people/index.html.haml @@ -7,7 +7,7 @@ =t('.results_for') %u= params[:q] - %ul#stream.people + %ul{:class => 'stream people', :id => 'people_stream'} - for person in @people = render 'people/person', :person => person, :aspects => @aspects diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index 03e5438b3..23f570645 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -57,6 +57,6 @@ = link_to t('.delete_photo'), @photo, :confirm => t('are_you_sure'), :method => :delete, :class => 'button' .span-9.last - #stream.show + %div{id => 'photo_stream', :class => 'stream show'}" %li.message{:data=>{:guid=>@photo.id}} = render "comments/comments", :post => @photo diff --git a/app/views/requests/_manage_aspect_contacts.haml b/app/views/requests/_manage_aspect_contacts.haml index c55f1fde1..302a9f08d 100644 --- a/app/views/requests/_manage_aspect_contacts.haml +++ b/app/views/requests/_manage_aspect_contacts.haml @@ -30,13 +30,13 @@ = submit_tag t('.create_request') %br - #loader.hidden= image_tag 'ajax-loader.gif' - %ul#request_result{:aspect_id => aspect.id} + .spinner.hidden= image_tag 'ajax-loader.gif' + %ul{:class => 'webfinger_result stream', :aspect_id => aspect.id} %li.error.hidden - #message + .webfinger_error = link_to t('.know_email'), "#invite_user_pane", :class => "invite_user_button" %br .yo{ :style => "display:none;"} - #invite_user_pane + .invite_user_pane = render "invitations/new" diff --git a/app/views/shared/_stream.haml b/app/views/shared/_stream.haml index 5e31b2bd6..a58c4d6f1 100644 --- a/app/views/shared/_stream.haml +++ b/app/views/shared/_stream.haml @@ -2,6 +2,6 @@ -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. -%ul#stream +%ul{:class => 'stream', :id => 'main_stream'} - for post in posts = render 'shared/stream_element', :post => post diff --git a/app/views/status_messages/show.html.haml b/app/views/status_messages/show.html.haml index 108580a3e..56bb7b039 100644 --- a/app/views/status_messages/show.html.haml +++ b/app/views/status_messages/show.html.haml @@ -16,6 +16,6 @@ = link_to t('.destroy'), @status_message, :confirm => t('are_you_sure'), :method => :delete .span-9.last - #stream.show + %div{:class => 'stream show', :id => 'status_message_stream'} %li.message{:data=>{:guid=>@status_message.id}} = render "comments/comments", :post => @status_message diff --git a/app/views/users/getting_started/_step_3.html.haml b/app/views/users/getting_started/_step_3.html.haml index 222288b14..e3958325b 100644 --- a/app/views/users/getting_started/_step_3.html.haml +++ b/app/views/users/getting_started/_step_3.html.haml @@ -7,7 +7,7 @@ = t('.your_services') .description = t('.description') -%ul#stream +%ul.stream#service_stream - for service in @services %h3 %b= service.provider diff --git a/features/step_definitions/custom_web_steps.rb b/features/step_definitions/custom_web_steps.rb index 9086b8d5e..4dc0222e9 100644 --- a/features/step_definitions/custom_web_steps.rb +++ b/features/step_definitions/custom_web_steps.rb @@ -17,7 +17,7 @@ When /^(.*) in the aspect list$/ do |action| end Then /^I should see "([^\"]*)" in the main content area$/ do |stuff| - within("#stream") do + within("#main_stream") do Then "I should see #{stuff}" end end diff --git a/public/javascripts/stream.js b/public/javascripts/stream.js index ede3fa652..a3495e720 100644 --- a/public/javascripts/stream.js +++ b/public/javascripts/stream.js @@ -5,9 +5,9 @@ $(document).ready(function(){ - var $stream = $("#stream"); + var $stream = $(".stream"); // expand all comments on page load - $("#stream:not('.show')").find('.comments').each(function(index) { + $(".stream:not('.show')").find('.comments').each(function(index) { var comments = $(this); if(comments.children("li").length > 1) { var show_comments_toggle = comments.closest("li").find(".show_post_comments"); @@ -32,7 +32,7 @@ $(document).ready(function(){ .closest("form").find(".comment_submit").fadeIn(200); }); - $("#stream").delegate("textarea.comment_box", "blur", function(evt){ + $(".stream").delegate("textarea.comment_box", "blur", function(evt){ var commentBox = $(this); if( !commentBox.val() ) { commentBox.attr("rows", 1) diff --git a/public/javascripts/view.js b/public/javascripts/view.js index a77602c83..ec99c7793 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -46,7 +46,7 @@ $(document).ready(function(){ } }); - $("#stream").delegate("textarea.comment_box", "keydown", function(e){ + $(".stream").delegate("textarea.comment_box", "keydown", function(e){ if (e.keyCode === 13) { $(this).closest("form").submit(); } @@ -72,8 +72,9 @@ $(document).ready(function(){ $(".person img", ".dropzone").tipsy({live:true}); $(".avatar", ".aspects").tipsy({live:true}); - $('.webfinger_form').submit(function(){ - $('#loader').show(); + $('.webfinger_form').submit(function(evt){ + form = $(evt.currentTarget); + form.siblings('.spinner').show(); $('#request_result li:first').hide(); }); });//end document ready diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index d07ae5851..abc29bb32 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -189,7 +189,7 @@ header :margin :left 432px -#stream +.stream :margin 0 :padding 0 > li @@ -488,7 +488,7 @@ form :margin :right 1em -#stream.show +.stream.show ul.comments :display block :margin @@ -501,7 +501,7 @@ form :background none :border none -#stream ul.comments +.stream ul.comments :display none .avatar @@ -587,7 +587,7 @@ ul.comments :bottom 1em -#stream, #profile, +.stream, #profile, .comments img.person_picture