Commit 6bb07f97315bc589efc6093e01732dd69af51246

Authored by Andrey Karpikov
1 parent 29e357b5

check menu selected

... ... @@ -47,9 +47,11 @@ module Kanjai
47 47 when 'text'
48 48 content = item[:source].to_s.strip
49 49 if current_page
  50 + is_current_page = session[:url] == current_page.menu_url(session[:scheme], I18n.locale).gsub("/#{I18n.locale}", "")
  51 +
50 52 content = content.gsub('###link###', current_page.menu_url(session[:scheme], lang = nil).to_s)
51 53 .gsub('###title###', current_page.lang_attributes(I18n.locale, :title).to_s)
52   - .gsub('###active_class###', 'active')
  54 + .gsub('###active_class###', is_current_page ? 'active' : '')
53 55 end
54 56 subparts << content
55 57 when 'repeat'
... ... @@ -159,10 +161,12 @@ module Kanjai
159 161 else
160 162 attributes = item[:attributes]
161 163 if current_page
  164 + is_current_page = session[:url] == current_page.menu_url(session[:scheme], I18n.locale).gsub("/#{I18n.locale}", "")
  165 +
162 166 attributes = replace_attributes_marker(attributes, {
163 167 '###link###' => current_page.menu_url(session[:scheme], lang = nil),
164 168 '###title###' => current_page.lang_attributes(I18n.locale, :title),
165   - '###active_class###' => 'active'
  169 + '###active_class###' => is_current_page ? 'active' : ''
166 170 })
167 171 end
168 172 subparts.send(item[:name].to_s, attributes) do |next_subparts|
... ...
1 1 module Kanjai
2   - VERSION = "0.0.370"
  2 + VERSION = "0.0.371"
3 3 end
... ...