diff --git a/app/views/aspects/_aspect_listings.haml b/app/views/aspects/_aspect_listings.haml index 6e5339134..940ab6f53 100644 --- a/app/views/aspects/_aspect_listings.haml +++ b/app/views/aspects/_aspect_listings.haml @@ -4,10 +4,10 @@ %ul#aspect_nav.left_nav %li.all_aspects{:class => ("active" if params["set"] != "all" && params["set"] != "only_sharing" && !@featured && !@finder)} - %a.home_selector{:href => aspects_path, :class => ("sub_selected" if params["a_id"])} - = t('aspects.index.your_aspects') + .root_element= t('aspects.index.your_aspects') %ul.sub_nav + %a.toggle_selector{:href => '#'} - for aspect in all_aspects %li{:data => {:aspect_id => aspect.id}, :class => ("active" if params["a_id"].to_i == aspect.id)} .edit diff --git a/config/assets.yml b/config/assets.yml index 6c45eac3c..2bd5b17e9 100644 --- a/config/assets.yml +++ b/config/assets.yml @@ -55,7 +55,6 @@ javascripts: - public/javascripts/friend-finder.js home: - public/javascripts/publisher.js - - public/javascripts/aspect-filters.js - public/javascripts/aspect-edit-pane.js - public/javascripts/fileuploader-custom.js people: diff --git a/config/locales/javascript/javascript.en.yml b/config/locales/javascript/javascript.en.yml index b2288dd55..13f8ff7bd 100644 --- a/config/locales/javascript/javascript.en.yml +++ b/config/locales/javascript/javascript.en.yml @@ -53,3 +53,7 @@ en: hide: "hide comments" reshares: duplicate: "You've already reshared that post!" + aspect_navigation: + select_all: "Select all" + deselect_all: "Deselect all" + no_aspects: "No aspects selected" diff --git a/features/comments.feature b/features/comments.feature index 82fcbd9be..fa73d5fca 100644 --- a/features/comments.feature +++ b/features/comments.feature @@ -62,8 +62,7 @@ Feature: commenting When I focus the comment field Then the first comment field should be open - When I follow "Besties" - And I wait for the ajax to finish + When I select "Besties" aspect Then I should see "Look at this dog" Then the first comment field should be closed When I focus the comment field diff --git a/features/connects_users.feature b/features/connects_users.feature index bb0feacbf..6f698c292 100644 --- a/features/connects_users.feature +++ b/features/connects_users.feature @@ -47,7 +47,6 @@ Feature: following and being followed And I add the person to my "Unicorns" aspect When I go to the home page - When I follow "Your Aspects" Then I should have 1 contact in "Unicorns" Then I should have 1 contact in "Besties" @@ -59,7 +58,6 @@ Feature: following and being followed Then I go to the destroy user session page When I sign in as "bob@bob.bob" - When I follow "Your Aspects" Then I should have 1 contacts in "Besties" When I am on the home page diff --git a/features/mentions_from_profile_page.feature b/features/mentions_from_profile_page.feature index 3487302df..247ddba76 100644 --- a/features/mentions_from_profile_page.feature +++ b/features/mentions_from_profile_page.feature @@ -32,7 +32,7 @@ Feature: mentioning a contact from their profile page And I wait for the ajax to finish Then I should see "I am eating a yogurt" - When I follow "Your Aspects" within "#aspect_nav" + When I am on the aspects page And I follow "NotPostingThingsHere" within "#aspect_nav" And I wait for the ajax to finish Then I should see "I am eating a yogurt" @@ -50,11 +50,13 @@ Feature: mentioning a contact from their profile page And I press "Share" in the modal window When I am on the aspects page + And I follow "Deselect all" within "#aspect_nav" And I follow "PostingTo" within "#aspect_nav" And I wait for the ajax to finish Then I should see "I am eating a yogurt" - When I follow "Your Aspects" within "#aspect_nav" + When I am on the aspects page + And I follow "Deselect all" within "#aspect_nav" And I follow "NotPostingThingsHere" within "#aspect_nav" And I wait for the ajax to finish Then I should not see "I am eating a yogurt" diff --git a/features/posts_from_main_page.feature b/features/posts_from_main_page.feature index d7f4e2a27..7a8ba929b 100644 --- a/features/posts_from_main_page.feature +++ b/features/posts_from_main_page.feature @@ -22,25 +22,22 @@ Feature: posting from the main page Given I expand the publisher When I fill in "status_message_fake_text" with "I am eating a yogurt" And I press "Share" - And I follow "Your Aspects" + And I go to the aspects page Then I should see "I am eating a yogurt" within ".stream_element" Scenario: post a text-only message to just one aspect - When I follow "PostingTo" - And I wait for the ajax to finish + When I select "PostingTo" aspect And I expand the publisher And I fill in "status_message_fake_text" with "I am eating a yogurt" And I press "Share" And I wait for the ajax to finish When I am on the aspects page - And I follow "PostingTo" within "#aspect_nav" - And I wait for the ajax to finish + And I select "PostingTo" aspect Then I should see "I am eating a yogurt" - When I follow "Your Aspects" within "#aspect_nav" - And I follow "NotPostingThingsHere" within "#aspect_nav" - And I wait for the ajax to finish + When I am on the aspects page + And I select "NotPostingThingsHere" aspect Then I should not see "I am eating a yogurt" Scenario: post a photo with text @@ -49,7 +46,7 @@ Feature: posting from the main page And I fill in "status_message_fake_text" with "Look at this dog" And I press "Share" And I wait for the ajax to finish - And I follow "Your Aspects" + And I go to the aspects page Then I should see a "img" within ".stream_element div.photo_attachments" And I should see "Look at this dog" within ".stream_element" Then I log out @@ -65,7 +62,7 @@ Feature: posting from the main page Then I should see an uploaded image within the photo drop zone And I press "Share" And I wait for the ajax to finish - And I follow "Your Aspects" + And I go to the aspects page Then I should see a "img" within ".stream_element div.photo_attachments" Then I log out And I sign in as "alice@alice.alice" @@ -130,10 +127,10 @@ Feature: posting from the main page And I press "Share" And I wait for the ajax to finish - When I follow "Your Aspects" + When I go to the aspects page And I hover over the ".stream_element" And I preemptively confirm the alert And I click to delete the first post And I wait for the ajax to finish - And I follow "Your Aspects" + And I go to the aspects page Then I should not see "I am eating a yogurt" diff --git a/features/reshare.feature b/features/reshare.feature index e7f166cb9..4e527dd9c 100644 --- a/features/reshare.feature +++ b/features/reshare.feature @@ -49,10 +49,9 @@ Feature: public repost And I go to the home page And I wait for the ajax to finish Then I should see a ".reshare" - And I follow "Your Aspects" - Then I should see "reshare this!" - Then I should see a ".reshare" - And I should see "Bob" + And I should see "reshare this!" + And I should see a ".reshare" + And I should see "Bob" Scenario: I can delete a post that has been reshared Given "bob@bob.bob" has a public post with text "reshare this!" @@ -63,11 +62,9 @@ Feature: public repost And I go to the home page Then I should see a ".reshare" - - When I follow "Your Aspects" - Then I should see "reshare this!" - Then I should see a ".reshare" - And I should see "Bob" + And I should see "reshare this!" + And I should see a ".reshare" + And I should see "Bob" When I go to the destroy user session page And I sign in as "bob@bob.bob" @@ -88,10 +85,9 @@ Feature: public repost When I go to the home page Then I should see a ".reshare" - When I follow "Your Aspects" - Then I should see "reshare this!" + And I should see "reshare this!" And I should see a ".reshare" - And I should see "Bob" + And I should see "Bob" When I go to the home page Then I should see "1 reshare" diff --git a/features/step_definitions/aspects_steps.rb b/features/step_definitions/aspects_steps.rb new file mode 100644 index 000000000..3f6505f27 --- /dev/null +++ b/features/step_definitions/aspects_steps.rb @@ -0,0 +1,14 @@ +When /^I click on "([^"]*)" aspect edit icon$/ do |aspect_name| + When %{I hover over the "ul.sub_nav > li:contains('#{aspect_name}')"} + within("#aspect_nav") do + find(:xpath, "//a[@rel='facebox'][.//img[@title='Edit #{aspect_name}']]").click + end +end + +When /^I select "([^"]*)" aspect$/ do |aspect_name| + within('#aspect_nav') do + click_link 'Deselect all' + click_link aspect_name + end + And %{I wait for the ajax to finish} +end diff --git a/features/step_definitions/custom_web_steps.rb b/features/step_definitions/custom_web_steps.rb index 1a0ca0922..e37235364 100644 --- a/features/step_definitions/custom_web_steps.rb +++ b/features/step_definitions/custom_web_steps.rb @@ -193,13 +193,6 @@ When /^I resize my window to 800x600$/ do JS end -When /^I click on "([^"]*)" aspect edit icon$/ do |aspect_name| - When %{I hover over the "ul.sub_nav > li:contains('#{aspect_name}')"} - within("#aspect_nav") do - find(:xpath, "//a[@rel='facebox'][.//img[@title='Edit #{aspect_name}']]").click - end -end - Then /^I follow Edit Profile in the same window$/ do page.execute_script("$('a[href=\"#{edit_profile_path}\"]').removeAttr('target')") @@ -212,4 +205,4 @@ end Then 'I press the attached image' do Then %{I press the 1st "img" within ".stream_element div.photo_attachments"} -end \ No newline at end of file +end diff --git a/public/javascripts/aspect-filters.js b/public/javascripts/aspect-filters.js deleted file mode 100644 index 5e3e732de..000000000 --- a/public/javascripts/aspect-filters.js +++ /dev/null @@ -1,173 +0,0 @@ -/* Copyright (c) 2010-2011, Diaspora Inc. This file is - * licensed under the Affero General Public License version 3 or later. See - * the COPYRIGHT file. - */ - -var AspectFilters = { - selectedGUIDS: [], - activeRequest: null, - initialize: function(){ - AspectFilters.initializeSelectedGUIDS(); - AspectFilters.interceptAspectLinks(); - AspectFilters.interceptAspectNavLinks(); - }, - initializeSelectedGUIDS: function(){ - $("#aspect_nav .aspect_selector").each(function(){ - var button = $(this), - guid = button.attr('data-guid'); - - if(guid && location.href.search("a_ids..="+guid+"(#|&|$)") != -1){ - button.parent().addClass('active'); - AspectFilters.selectedGUIDS.push(guid); - $("#aspect_nav li.all_aspects").removeClass('active'); - } - }); - }, - interceptAspectLinks: function(){ - $("a.hard_aspect_link").live("click", AspectFilters.aspectLinkClicked); - }, - aspectLinkClicked: function(e){ - var link = $(this); - e.preventDefault(); - if( !link.hasClass('aspect_selector') ){ - AspectFilters.switchToAspect(link); - } - - // remove focus - this.blur(); - - $('html, body').animate({scrollTop:0}, 'fast'); - }, - switchToAspect: function(aspectLi){ - var guid = aspectLi.attr('data-guid'); - - // select correct aspect in filter list & deselect others - $("#aspect_nav li.active").removeClass('active'); - aspectLi.addClass('active'); - - AspectFilters.fadeOut(); - - AspectFilters.performAjax( aspectLi.attr('href')); - }, - interceptAspectNavLinks: function(){ - $("#aspect_nav a.aspect_selector").click(function(e){ - e.preventDefault(); - - // loading animation - AspectFilters.fadeOut(); - - // filtering ////////////////////// - var $this = $(this), - listElement = $this.parent(), - guid = $this.attr('data-guid'), - homeListElement = $("#aspect_nav li.all_aspects"); - - if( listElement.hasClass('active') ){ - // remove filter - var idx = AspectFilters.selectedGUIDS.indexOf( guid ); - if( idx != -1 ){ - AspectFilters.selectedGUIDS.splice(idx,1); - } - listElement.removeClass('active'); - - if(AspectFilters.selectedGUIDS.length === 0){ - homeListElement.addClass('active'); - } - - } else { - // append filter - if(AspectFilters.selectedGUIDS.indexOf( guid == 1)){ - AspectFilters.selectedGUIDS.push( guid ); - } - listElement.addClass('active'); - - homeListElement.removeClass('active'); - } - - AspectFilters.performAjax(AspectFilters.generateURL()); - }); - }, - generateURL: function(){ - var baseURL = location.href.split("?")[0]; - - // generate new url - baseURL = baseURL.replace('#',''); - baseURL += '?'; - for(i=0; i < AspectFilters.selectedGUIDS.length; i++){ - baseURL += 'a_ids[]='+ AspectFilters.selectedGUIDS[i] +'&'; - } - - if(!$("#publisher").hasClass("closed")) { - // open publisher - baseURL += "op=true"; - } else { - // slice last '&' - baseURL = baseURL.slice(0,baseURL.length-1); - } - return baseURL; - }, - performAjax: function(newURL) { - var post = $("#publisher textarea").val(), - photos = {}; - - //pass photos - $('#photodropzone img').each(function(){ - var img = $(this); - var guid = img.attr('data-id'); - var url = img.attr('src'); - photos[guid] = url; - }); - - // set url - // some browsers (Firefox for example) don't support pushState - if (typeof(history.pushState) == 'function') { - history.pushState(null, document.title, newURL); - } - - try { - AspectFilters.activeRequest.abort(); - } catch(e) {} finally { - AspectFilters.activeRequest = null; - } - AspectFilters.activeRequest = $.ajax({ - url : newURL, - dataType : 'script', - success : function(data){ - // fill in publisher - // (not cached because this element changes) - - var textarea = $("#publisher textarea"); - var photozone = $('#photodropzone'); - - if( post !== "" ) { - textarea.val(post); - textarea.focus(); - } - - var photos_html = ""; - for(var key in photos){ - $("#publisher textarea").addClass("with_attachments"); - photos_html = photos_html + "