diff --git a/features/posts_from_main_page.feature b/features/posts_from_main_page.feature index 21376bafb..10d11a7df 100644 --- a/features/posts_from_main_page.feature +++ b/features/posts_from_main_page.feature @@ -38,7 +38,7 @@ Feature: posting from the main 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 not see "I am eating a yogurt" diff --git a/public/javascripts/widgets/aspect-navigation.js b/public/javascripts/widgets/aspect-navigation.js index e2a1e329c..704ed22cf 100644 --- a/public/javascripts/widgets/aspect-navigation.js +++ b/public/javascripts/widgets/aspect-navigation.js @@ -18,7 +18,6 @@ self.initializeSelectedAspects(); self.calculateToggleText(); self.aspectSelectors.click(self.toggleAspect); - self.aspectSelectors.debounce("click", self.performAjax, 250); self.toggleSelector.click(self.toggleAll); }); @@ -38,25 +37,32 @@ evt.preventDefault(); $(this).parent().toggleClass("active"); - self.calculateToggleText(); + self.perform(); }; this.toggleAll = function(evt) { evt.preventDefault(); - if (self.aspectLis.not(".active").length === 0) { + if (self.allSelected()) { self.aspectLis.removeClass("active"); + } else { + self.aspectLis.addClass("active"); + } + self.perform(); + }; + + this.perform = function() { + if (self.noneSelected()) { self.abortAjax(); self.fadeIn(); } else { - self.aspectLis.addClass("active"); self.performAjax(); } self.calculateToggleText(); }; this.calculateToggleText = function() { - if (self.aspectLis.not(".active").length === 0) { + if (self.allSelected()) { self.toggleSelector.text(Diaspora.I18n.t('aspect_navigation.deselect_all')); } else { self.toggleSelector.text(Diaspora.I18n.t('aspect_navigation.select_all')); @@ -98,10 +104,6 @@ photos[img.attr("data-id")] = img.attr("src"); }); - if (typeof(history.pushState) == 'function') { - history.pushState(null, document.title, newURL); - } - self.abortAjax(); self.fadeOut(); @@ -133,6 +135,14 @@ } }; + this.noneSelected = function() { + return self.aspectLis.filter(".active").length === 0; + } + + this.allSelected = function() { + return self.aspectLis.not(".active").length === 0; + } + this.fadeOut = function() { $("#aspect_stream_container").fadeTo(100, 0.4); $("#selected_aspect_contacts").fadeTo(100, 0.4);