From 583dd20249f9c1592d230312c9d20e72679f5d96 Mon Sep 17 00:00:00 2001 From: Gonzalo Rodriguez Date: Sat, 8 Oct 2011 23:14:04 -0200 Subject: [PATCH] Refactor selected aspects ui setup --- app/views/aspects/_aspect_listings.haml | 2 +- app/views/aspects/index.html.haml | 2 +- public/javascripts/widgets/aspect-navigation.js | 13 ------------- 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/app/views/aspects/_aspect_listings.haml b/app/views/aspects/_aspect_listings.haml index 7a2c9e1ff..d899a1567 100644 --- a/app/views/aspects/_aspect_listings.haml +++ b/app/views/aspects/_aspect_listings.haml @@ -9,7 +9,7 @@ %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)} + %li{:data => {:aspect_id => aspect.id}, :class => ("active" if defined?(selected_aspects) && selected_aspects.include?(aspect.id))} .edit = link_to image_tag("icons/pencil.svg", :height => 12, :title => t('.edit_aspect', :name => aspect.name)), edit_aspect_path(aspect), :rel => "facebox" diff --git a/app/views/aspects/index.html.haml b/app/views/aspects/index.html.haml index 005764d9a..2d20e1478 100644 --- a/app/views/aspects/index.html.haml +++ b/app/views/aspects/index.html.haml @@ -19,7 +19,7 @@ = link_to "Welcome", getting_started_path, :class => "home_selector" .section - = render 'aspects/aspect_listings' + = render 'aspects/aspect_listings', :selected_aspects => @stream.aspect_ids .section %ul.left_nav diff --git a/public/javascripts/widgets/aspect-navigation.js b/public/javascripts/widgets/aspect-navigation.js index 66d283d8b..144f3e7cf 100644 --- a/public/javascripts/widgets/aspect-navigation.js +++ b/public/javascripts/widgets/aspect-navigation.js @@ -15,7 +15,6 @@ toggleSelector: aspectNavigation.find("a.toggle_selector") }); - self.initializeSelectedAspects(); self.calculateToggleText(); self.aspectSelectors.click(self.toggleAspect); self.toggleSelector.click(self.toggleAll); @@ -25,18 +24,6 @@ return self.aspectNavigation.find("li.active[data-aspect_id]").map(function() { return $(this).data('aspect_id') }); }; - this.initializeSelectedAspects = function() { - if (location.href.search("a_ids..=") == -1) { - self.aspectLis.addClass("active"); - } else { - self.aspectSelectors.each(function() { - guid = $(this).data('guid'); - if (guid && location.href.search("a_ids..=" + guid + "(#|&|$)") != -1) - $(this).parent().addClass('active'); - }); - } - }; - this.toggleAspect = function(evt) { evt.preventDefault();