From d0b25814b1a3c77d518b51984c0f97fef8817753 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 5 Jan 2011 10:23:13 -0800 Subject: [PATCH] publisher retains text when filtering stream --- app/helpers/aspects_helper.rb | 15 +++++++++++ app/views/shared/_publisher.haml | 10 +++----- config/locales/diaspora/en.yml | 2 ++ public/javascripts/aspect-filters.js | 32 ++++++++++++++++++++---- public/stylesheets/sass/application.sass | 5 ++-- 5 files changed, 49 insertions(+), 15 deletions(-) diff --git a/app/helpers/aspects_helper.rb b/app/helpers/aspects_helper.rb index 8a9f08da8..e173bc75f 100644 --- a/app/helpers/aspects_helper.rb +++ b/app/helpers/aspects_helper.rb @@ -42,5 +42,20 @@ module AspectsHelper remove_from_aspect_button(aspect_id, person.id) end end + + def publisher_description(aspect_count, aspect=nil) + if aspect && aspect == :all + str = t('.share_with_all') + else + str = "#{t('.post_a_message_to', :aspect => aspect_count)} " + if aspect_count == 1 + str += t('_aspect') + else + str += t('_aspects') + end + end + (link_to str, '#', :id => 'expand_publisher').html_safe + end + end diff --git a/app/views/shared/_publisher.haml b/app/views/shared/_publisher.haml index 516f38c87..c4951732d 100644 --- a/app/views/shared/_publisher.haml +++ b/app/views/shared/_publisher.haml @@ -3,14 +3,11 @@ -# the COPYRIGHT file. -#publisher{:class=>"closed"} +#publisher{:class => ("closed" unless params[:op])} #click_to_share = image_tag 'icons/doc_edit.png' - - if aspect == :all - = link_to t('.share_with_all'), '#', :id => 'expand_publisher' - - else - = link_to t('.post_a_message_to', :aspect => aspect), '#', :id => 'expand_publisher' + = publisher_description(@aspect_ids.count, aspect) .content_creation = form_for(StatusMessage.new, :remote => true) do |status| @@ -30,14 +27,13 @@ = hidden_field_tag 'aspect_ids[]', aspect_id.to_s .options_and_submit - .right #fileInfo = image_tag 'ajax-loader.gif', :class => 'hidden', :id => "publisher_spinner" - if aspect == :all = status.submit t('.share'), :title => t('.share_with_all'), :disable_with => t('.posting'), :class => 'button' - else - = status.submit t('.share'), :title => t('.share_with', :aspect => aspect), :disable_with => t('.posting'), :class => 'button' + = status.submit t('.share'), :disable_with => t('.posting'), :class => 'button' - if aspect == :all .public_toggle diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 24b16d056..a7633c99b 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -41,6 +41,8 @@ en: one: "new request!" few: "%{count} new requests!" other: "%{count} new requests!" + _aspect: "aspect" + _aspects: "aspects" activemodel: errors: diff --git a/public/javascripts/aspect-filters.js b/public/javascripts/aspect-filters.js index 977386b0c..f15682376 100644 --- a/public/javascripts/aspect-filters.js +++ b/public/javascripts/aspect-filters.js @@ -4,7 +4,8 @@ */ $(document).ready(function(){ - var selectedGUIDS = []; + var selectedGUIDS = [], + requests = 0; $("#aspect_nav li").each(function(){ var button = $(this), @@ -19,9 +20,13 @@ $(document).ready(function(){ $("#aspect_nav a.aspect_selector").click(function(e){ e.preventDefault(); + requests++; + // loading animation $("#aspect_stream_container").fadeTo(100, 0.4); + // get text from box + var post = $("#publisher textarea").val(); // filtering ////////////////////// var $this = $(this), @@ -58,16 +63,33 @@ $(document).ready(function(){ for(i=0; i < selectedGUIDS.length; i++){ baseURL += 'a_ids[]='+ selectedGUIDS[i] +'&'; } - baseURL = baseURL.slice(0,baseURL.length-1); + + if(!$("#publisher").hasClass("closed")) { + // open publisher + baseURL += "op=true"; + } else { + // slice last '&' + baseURL = baseURL.slice(0,baseURL.length-1); + } /////////////////////////////////// - - //window.location = baseURL; $.ajax({ url : baseURL, dataType : 'script', success : function(data){ - $("#aspect_stream_container").fadeTo(100, 1); + requests--; + + // fill in publisher + // (not cached because this element changes) + $("#publisher textarea").val(post); + + // reinit listeners on stream + Stream.initialize(); + + // fade contents back in + if(requests == 0){ + $("#aspect_stream_container").fadeTo(100, 1); + } } }); diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index a3e6ebad8..b8ee14c8e 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -112,7 +112,7 @@ form :margin 0 header - :z-index 4 + :z-index 10 :position relative :min-height 40px @@ -120,7 +120,7 @@ header :color #111 :color rgba(30,30,30,0.98) - :background -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(30,30,30,0.94)), to(rgba(0,0,0,0.96))) + :background -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(30,30,30,0.88)), to(rgba(0,0,0,0.96))) :-webkit-box-shadow 0 1px 3px #111 :-moz-box-shadow 0 1px 2px #111 @@ -786,7 +786,6 @@ label :size 14px .options_and_submit - :display none :min-height 21px :position relative :padding