diff options
Diffstat (limited to 'app/helpers/navigation_helper.rb')
| -rw-r--r-- | app/helpers/navigation_helper.rb | 37 | 
1 files changed, 23 insertions, 14 deletions
| diff --git a/app/helpers/navigation_helper.rb b/app/helpers/navigation_helper.rb index 8582391..a43eecd 100644 --- a/app/helpers/navigation_helper.rb +++ b/app/helpers/navigation_helper.rb @@ -1,18 +1,21 @@  module NavigationHelper    def has_side_column? -    second_level_children_count = Menu.menu.submenu(current_page_path.first).try(:size) +    if root_page? +      return false +    end +    second_level_children_count = site.menu.submenu(current_page_path.first).try(:size)      if second_level_children_count.nil?        false      else -      second_level_children_count > 1 +      second_level_children_count >= 1      end    end    def top_level_navigation_links      haml do        first = 'first' -      Menu.menu.each do |item| +      site.menu.each do |item|          active = current_page_path.first == item.name ? 'active' : ''          haml 'li.tab', :class => first do            haml 'a.tab', I18n.t('pages.' + item.name), :href => menu_item_path(item), :class => active @@ -23,7 +26,7 @@ module NavigationHelper    end    def side_column_navigation_links -    if menu = Menu.menu.submenu(current_page_path.first) +    if menu = site.menu.submenu(current_page_path.first)        haml do          haml 'ul.nav.nav-tabs.nav-stacked' do            display_menu(menu, 1) @@ -33,7 +36,7 @@ module NavigationHelper    end    def act_as(page) -    page = StaticPage.find(page) +    page = site.find_page(page)      @current_page_path = page.path      render_page(page)    end @@ -54,7 +57,17 @@ module NavigationHelper    end    def path_active(page_path, menu_item) -    array_starts_with(page_path, menu_item.path) ? 'active' : '' +    active = '' +    if menu_item.path == page_path +      active = 'active' +    elsif menu_item.path_prefix_of?(page_path) +      if menu_item.leaf_for_path?(page_path) +        active = 'active' +      else +        active = 'semi-active' +      end +    end +    active    end    def current_page_path @@ -70,15 +83,11 @@ module NavigationHelper    end    # -  # returns true if first part of array_long contains array_short +  # the usage of 'home' as the default root page is hardcoded right now in the routes. +  # this should be changed in the future.    # -  def array_starts_with(array_long, array_short) -    array_short.length.times do |i| -      if array_short[i] != array_long[i] -        return false -      end -    end -    return true +  def root_page? +    @page && @page.path == ['home']    end  end | 
