Skip to content

Instantly share code, notes, and snippets.

@yamaaki
Created August 11, 2015 03:16
Show Gist options
  • Save yamaaki/5d5238b9cdec947f7186 to your computer and use it in GitHub Desktop.
Save yamaaki/5d5238b9cdec947f7186 to your computer and use it in GitHub Desktop.
module ApplicationHelper
def nav_header(key)
active = false
if key == :sample_a
active = true if is_nav_active?(:sample_a1)
active = true if is_nav_active?(:sample_a2)
active = true if is_nav_active?(:sample_a3)
text = 'Sample A'
end
if active
link_to text, '#', class: 'collapsible-header waves-effect waves-teal active'
else
link_to text, '#', class: 'collapsible-header waves-effect waves-teal'
end
end
def nav_header_li(key)
active = false
active = true if is_nav_active?(key)
if key == :sample_b
text = 'Sample B'
path = '#'
end
if active
content_tag :li, class: 'active' do
link_to text, path, class: 'waves-effect waves-teal'
end
else
content_tag :li do
link_to text, path, class: 'waves-effect waves-teal'
end
end
end
def is_nav_active?(key)
if key == :sample_a
return true
end
if key == :sample_b
return true
end
if key == :sample_c
return true
end
return false
end
def nav_li(key)
active = false
active = true if is_nav_active?(key)
if key == :sample_a1
text = 'Sample A1'
path = '#'
method ='GET'
end
if key == :sample_a2
text = 'Sample A2'
path = '#'
method ='GET'
end
if key == :sample_a3
text = 'Sample A3'
path = '#'
method ='GET'
end
if active
content_tag :li, class: 'active' do
if method && method != 'GET'
link_to text, path, method: method
else
link_to text, path
end
end
else
content_tag :li do
if method && method != 'GET'
link_to text, path, method: method
else
link_to text, path
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment