Sha256: bb280b8477a40162648bbfcb6ff05a1b07b66c0a0a9ba641e59e9f06d85b4680

Contents?: true

Size: 940 Bytes

Versions: 4

Compression:

Stored size: 940 Bytes

Contents

module Trestle
  module NavigationHelper
    def current_navigation_item?(item)
      current_page?(item.path) || (item.admin && current_admin?(item.admin))
    end

    def current_admin?(admin)
      respond_to?(:admin) && self.admin && self.admin.name == admin.name
    end

    def navigation_group_collapsed?(group)
      if collapsed_navigation_groups.include?(group.id)
        # Explicitly collapsed by user
        true
      elsif group.collapse?
        # Default to collapsed unless expanded by user
        !expanded_navigation_groups.include?(group.id)
      end
    end

  private
    def collapsed_navigation_groups
      @collapsed_navigation_groups ||= navigation_groups(:collapsed)
    end

    def expanded_navigation_groups
      @expanded_navigation_groups ||= navigation_groups(:expanded)
    end

    def navigation_groups(state)
      cookies["trestle:navigation:#{state}"].try(:split, ",") || []
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
trestle-0.9.8 app/helpers/trestle/navigation_helper.rb
trestle-0.9.7 app/helpers/trestle/navigation_helper.rb
trestle-0.9.6 app/helpers/trestle/navigation_helper.rb
trestle-0.9.5 app/helpers/trestle/navigation_helper.rb