Sha256: 434f09298c50f3ba1e1136208023e9c2ec0c8724028606378ac48e2ca5ef8b34
Contents?: true
Size: 840 Bytes
Versions: 47
Compression:
Stored size: 840 Bytes
Contents
module AmaLayout class NavigationItemDecorator < Draper::Decorator delegate_all def sub_nav object.sub_nav.map { |sn| sn.decorate } end def sub_nav_class "has-dropdown" if sub_nav.any? end def top_sub_nav h.render partial: "ama_layout/top_sub_nav", locals: { sub_nav: sub_nav } if sub_nav.any? end def sidebar_sub_nav h.render partial: "ama_layout/sub_nav", locals: { sub_nav: sub_nav } if sub_nav.any? end def active_class "side-nav__child-link--active-page" if active_link? end private def active_link? sub_nav.map(&:link).push(link).include? current_url_without_query end def current_url_without_query URI.parse(current_url).tap { |uri| uri.query = nil }.to_s rescue URI::InvalidURIError current_url end end end
Version data entries
47 entries across 47 versions & 1 rubygems