From 8c82a5974a05d85be028315906ce05fe22579cc6 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 5 Jan 2011 18:18:04 -0800 Subject: [PATCH] aspect badge links work across all pages, ajax stream on index. aspect info lightbox placeholder --- app/controllers/aspects_controller.rb | 4 +- app/helpers/application_helper.rb | 4 +- app/helpers/aspects_helper.rb | 2 +- app/views/aspects/_all_aspects_contacts.haml | 10 ++--- app/views/aspects/_aspect.haml | 6 +-- app/views/aspects/edit.html.haml | 35 ++++++++++------ app/views/aspects/index.html.haml | 21 +++++----- app/views/shared/_add_contact.html.haml | 2 +- config/locales/diaspora/en.yml | 2 +- public/javascripts/aspect-filters.js | 43 +++++++++++++++---- public/javascripts/view.js | 4 +- public/stylesheets/sass/application.sass | 44 ++++++++++++++++---- 12 files changed, 123 insertions(+), 54 deletions(-) diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 6e013d3d5..b3a882e7e 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -22,7 +22,7 @@ class AspectsController < ApplicationController @posts = Post.where(:id.in => post_ids, :_type => "StatusMessage").paginate :page => params[:page], :per_page => 15, :order => 'created_at DESC' @post_hashes = hashes_for_posts @posts @contacts = Contact.all(:user_id => current_user.id, :pending => false) - @aspect_hashes = hashes_for_aspects @aspects, @contacts, :limit => 8 + @aspect_hashes = hashes_for_aspects @all_aspects, @contacts, :limit => 8 @contact_hashes = hashes_for_contacts @contacts @aspect = :all unless params[:a_ids] @@ -98,7 +98,7 @@ class AspectsController < ApplicationController @all_contacts = hashes_for_contacts @contacts - respond_with @aspect + render :layout => false end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 30f672d78..e77342108 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -34,7 +34,9 @@ module ApplicationHelper def aspect_badge aspects str = '' aspects.each do |aspect| - str << "#{aspect.name}" + str << "" + str << link_for_aspect(aspect, 'data-guid' => aspect.id, :class => 'hard_aspect_link').html_safe + str << "" end str.html_safe end diff --git a/app/helpers/aspects_helper.rb b/app/helpers/aspects_helper.rb index 7accf39de..f13fa4488 100644 --- a/app/helpers/aspects_helper.rb +++ b/app/helpers/aspects_helper.rb @@ -7,7 +7,7 @@ module AspectsHelper link_to aspect.name, aspects_path("a_ids[]" => aspect.id), opts end - def remove_link( aspect ) + def remove_link(aspect) if aspect.contacts.size == 0 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure') else diff --git a/app/views/aspects/_all_aspects_contacts.haml b/app/views/aspects/_all_aspects_contacts.haml index 7f62eeb6c..ccf7434dc 100644 --- a/app/views/aspects/_all_aspects_contacts.haml +++ b/app/views/aspects/_all_aspects_contacts.haml @@ -10,9 +10,8 @@ #left_pane .section.aspect_listings %h4 - .right{:style=>"font-size:12px;"} - = link_to t('.manage_aspects'), aspects_manage_path = t('.aspects') + = link_to @all_aspects.count, aspects_manage_path %ul - for a_hash in @aspect_hashes @@ -20,9 +19,8 @@ .section.contact_pictures %h4 - .right.description{:style => "top:-4px"} - = @contact_hashes.count - = t('.all_contacts') + = t('.contacts') + = link_to @contact_hashes.count, '#' - for contact in @contact_hashes = person_image_link(contact[:person]) @@ -34,6 +32,6 @@ = text_field_tag 'q', nil, :placeholder => t('search'), :type => 'search', :results => 5 .section - %h3= t('shared.invitations.invites') + %h4= t('shared.invitations.invites') = render "shared/invitations", :invites => @invites diff --git a/app/views/aspects/_aspect.haml b/app/views/aspects/_aspect.haml index cc2d0c907..acfcc5a5c 100644 --- a/app/views/aspects/_aspect.haml +++ b/app/views/aspects/_aspect.haml @@ -1,4 +1,4 @@ %li - %b - = link_for_aspect(aspect) - = t('contacts', :count => contact_count) + .right + = t('contacts', :count => contact_count) + = link_to aspect.name, edit_aspect_path(aspect), :class => 'aspect_detail_button' diff --git a/app/views/aspects/edit.html.haml b/app/views/aspects/edit.html.haml index e70d52579..110461136 100644 --- a/app/views/aspects/edit.html.haml +++ b/app/views/aspects/edit.html.haml @@ -6,22 +6,31 @@ = include_javascripts :aspects -.span-24.last - %h3 - = "Editing #{@aspect.name}" +#aspect_edit_pane + #aspect_edit_pane_header + %h4 + .aspect_search_field + /= text_field_tag 'q', nil, :placeholder => t('search'), :type => 'search', :results => 5 + = @aspect + .description + = "#{@contacts.count} contacts" + + .person_tiles{:style => "display:none;"} + - for contact in @aspect.contacts + .tile + = person_image_link contact.person + = link_to contact.person.name, contact.person + %hr + + = form_for @aspect do |asp| + = asp.text_field :name, :value => @aspect.name + = asp.submit t('.rename_aspect'), :class => 'button' + + = button_to t('.remove_aspect'), @aspect, :method => "delete", :confirm => t('.confirm_remove_aspect'), :class => 'button' -.span-6.append-1 - if @contacts.count > 0 - %h4= t('.add_existing') + %h5= t('.add_existing') = render 'shared/contact_list', :aspect_id => @aspect.id, :contact_hashes => @all_contacts = render 'shared/add_contact', :aspect_id => @aspect.id -.span-4.last - = form_for @aspect do |asp| - = asp.text_field :name, :value => @aspect.name - = asp.submit t('.rename_aspect') - - .big_buttons - = button_to t('.remove_aspect'), @aspect, :method => "delete", :confirm => t('.confirm_remove_aspect') - diff --git a/app/views/aspects/index.html.haml b/app/views/aspects/index.html.haml index 5e29276a1..5799a2aa4 100644 --- a/app/views/aspects/index.html.haml +++ b/app/views/aspects/index.html.haml @@ -6,15 +6,7 @@ - content_for :head do = include_javascripts :home -.span-22.last - %h3{:style => "position:relative;"} - = current_user.name - .right{:style=>"top:0"} - %span.description - = link_to current_user.diaspora_handle, person_path(current_user.person) - = info_text(t('.handle_explanation')) - -.span-15.append-1 +.span-15.append-2 /= render 'aspects/no_contacts_message', :aspect => @aspect, :contact_count => @contacts.count /= render 'aspects/no_posts_message', :post_count => @post_hashes.length, :contact_count => @contacts.count @@ -24,6 +16,15 @@ :aspect_ids => @aspect_ids, :post_hashes => @post_hashes -.span-6.last +.span-7.last + = owner_image_tag + %h3{:style => "position:relative;display:inline-block;margin-left:12px;top:-8px;"} + = current_user.name + .description + = link_to current_user.diaspora_handle, person_path(current_user.person) + /= info_text(t('.handle_explanation')) + + %hr + = render 'aspects/all_aspects_contacts' diff --git a/app/views/shared/_add_contact.html.haml b/app/views/shared/_add_contact.html.haml index 68d481e2e..2515fd4ed 100644 --- a/app/views/shared/_add_contact.html.haml +++ b/app/views/shared/_add_contact.html.haml @@ -3,7 +3,7 @@ -# the COPYRIGHT file. -%h4 +%h5 = t('aspects.manage.add_a_new_contact') = info_text(t('.enter_a_diaspora_username')) diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index b05c83d36..26b01aba0 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -133,7 +133,7 @@ en: add_existing: "Add an existing contact" rename_aspect: "Rename aspect" all_aspects_contacts: - all_contacts: "All contacts" + contacts: "Contacts" manage_aspects: "manage aspects" aspects: "Aspects" no_contacts: "You currently have no contacts. Find your contacts here." diff --git a/public/javascripts/aspect-filters.js b/public/javascripts/aspect-filters.js index 627277931..9973ea039 100644 --- a/public/javascripts/aspect-filters.js +++ b/public/javascripts/aspect-filters.js @@ -17,6 +17,28 @@ $(document).ready(function(){ } }); + $("a.hard_aspect_link").live("click", function(e){ + e.preventDefault(); + requests++; + + var guid = $(this).attr('data-guid'); + + // select correct aspect in filter list & deselect others + $("#aspect_nav li").each(function(){ + var $this = $(this); + if( $this.attr('data-guid') == guid){ + $this.addClass('selected'); + } else { + $this.removeClass('selected'); + } + }); + + // loading animation + $("#aspect_stream_container").fadeTo(100, 0.4); + + performAjax( $(this).attr('href'), $("#publisher textarea").val()); + }); + $("#aspect_nav a.aspect_selector").click(function(e){ e.preventDefault(); @@ -25,14 +47,11 @@ $(document).ready(function(){ // loading animation $("#aspect_stream_container").fadeTo(100, 0.4); - // get text from box - var post = $("#publisher textarea").val(); - // filtering ////////////////////// var $this = $(this), listElement = $this.parent(), guid = listElement.attr('data-guid'), - baseURL = location.href.split("?")[0], + post = $("#publisher textarea").val(), homeListElement = $("#aspect_nav a.home_selector").parent(); if( listElement.hasClass('selected') ){ @@ -57,6 +76,13 @@ $(document).ready(function(){ homeListElement.removeClass('selected'); } + performAjax(generateURL(), post); + }); + + + function generateURL(){ + var baseURL = location.href.split("?")[0]; + // generate new url baseURL = baseURL.replace('#',''); baseURL += '?'; @@ -71,10 +97,12 @@ $(document).ready(function(){ // slice last '&' baseURL = baseURL.slice(0,baseURL.length-1); } - /////////////////////////////////// + return baseURL; + } + function performAjax(newURL, post){ $.ajax({ - url : baseURL, + url : newURL, dataType : 'script', success : function(data){ requests--; @@ -94,6 +122,5 @@ $(document).ready(function(){ } } }); - - }); + } }); diff --git a/public/javascripts/view.js b/public/javascripts/view.js index 91b95198c..f8818eff5 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -79,7 +79,9 @@ var View = { ".add_photo_button", ".remove_person_button", ".question_mark", - ".share_with_button" + ".share_with_button", + ".aspect_detail_button", + ".aspect_selector_edit" ] }, diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index da1d591f1..e0921309d 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -337,10 +337,6 @@ header :top 7px img - :-webkit-box-shadow 0 1px 2px #333 - :-moz-box-shadow 0 1px 2px #333 - :box-shadow 0 1px 2px #333 - :margin :right 0.5em @@ -753,6 +749,9 @@ label :top 1px :top 0 + :background + :color rgb(248,248,248) + :border :bottom 2px #777 solid :top 1px #777 solid @@ -1215,9 +1214,11 @@ ul#settings_nav :top 12px :line-height 1em img - :margin-right -1px - :width 30px - :height 30px + :margin + :right 1px + :bottom 2px + :width 35px + :height 35px .contact_pictures.horizontal img @@ -1243,6 +1244,8 @@ ul#settings_nav ul :padding 0 :margin 0 + > li + :position relative .aspect_listings @@ -2113,3 +2116,30 @@ ul.show_comments :margin :left 0.5em :right 0.5em + +#aspect_edit_pane + .aspect_search_field + :position absolute + :right 5px + input + :width 200px + + .person_tiles + .tile + :padding 6px + :left 65px + :margin 3px + :left 0 + :display inline-block + :width 126px + :height 50px + + :border 1px solid #eee + :border-radius 2px + + :position relative + + img + :position absolute + :left 6px +