Class: Spark::Nav::Item
Instance Method Summary
collapse
#selector, #to_s, #unique_id
Constructor Details
#initialize ⇒ Item
Returns a new instance of Item.
11
12
13
14
15
16
17
18
|
# File 'app/components/spark/nav/item.rb', line 11
def initialize(*)
super
@href = @href || "#"
tag_attrs.add attr_hash(:target, :tabindex, :role)
classname.base = "nav-item"
classname.add(:active) if active?
end
|
Instance Method Details
#active? ⇒ Boolean
36
37
38
|
# File 'app/components/spark/nav/item.rb', line 36
def active?
@href != "#" && @active || @view_context && @view_context.current_page?(@href)
end
|
#label ⇒ Object
20
21
22
23
24
25
26
|
# File 'app/components/spark/nav/item.rb', line 20
def label
if new?
"new"
elsif @beta
"beta"
end
end
|
#new? ⇒ Boolean
28
29
30
31
32
33
34
|
# File 'app/components/spark/nav/item.rb', line 28
def new?
if @new.is_a?(String)
30.days.ago <= Time.zone.parse( @new )
else
@new
end
end
|