tabit 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/tabit/item.rb +26 -14
- data/lib/tabit/version.rb +1 -1
- data/tabit.gemspec +1 -1
- metadata +2 -2
data/lib/tabit/item.rb
CHANGED
@@ -9,29 +9,17 @@ module Tabit
|
|
9
9
|
attr_accessor :name
|
10
10
|
attr_accessor :url
|
11
11
|
attr_accessor :options
|
12
|
+
attr_accessor :active
|
12
13
|
|
13
14
|
def initialize(name, url = nil, options = {})
|
14
15
|
@name, @url, @options = name, url, options
|
15
|
-
|
16
|
+
|
16
17
|
@active = @options.delete(:active) || configuration.active_detect
|
17
18
|
@type = @options.delete(:type) || :default
|
18
|
-
|
19
19
|
@children = []
|
20
20
|
|
21
21
|
@options[:inner] ||= {}
|
22
22
|
@options[:outer] ||= {}
|
23
|
-
|
24
|
-
clazz = template.active_link_to_class(
|
25
|
-
url,
|
26
|
-
{
|
27
|
-
active: @active,
|
28
|
-
class_active: configuration.active_class
|
29
|
-
}
|
30
|
-
)
|
31
|
-
|
32
|
-
@options[:outer][:class] = '' if @options[:outer][:class].nil?
|
33
|
-
@options[:outer][:class] << " #{clazz}"
|
34
|
-
@options[:outer][:class].strip!
|
35
23
|
end
|
36
24
|
|
37
25
|
def add(name, url = nil, options = {})
|
@@ -42,6 +30,16 @@ module Tabit
|
|
42
30
|
end
|
43
31
|
|
44
32
|
def to_s
|
33
|
+
clazz = if active?
|
34
|
+
configuration.active_class
|
35
|
+
else
|
36
|
+
''
|
37
|
+
end
|
38
|
+
|
39
|
+
options[:outer][:class] = '' if @options[:outer][:class].nil?
|
40
|
+
options[:outer][:class] << " #{clazz}"
|
41
|
+
options[:outer][:class].strip!
|
42
|
+
|
45
43
|
case @type
|
46
44
|
when :dropdown
|
47
45
|
options[:outer][:class] = '' if @options[:outer][:class].nil?
|
@@ -75,6 +73,20 @@ module Tabit
|
|
75
73
|
end
|
76
74
|
end
|
77
75
|
|
76
|
+
def active?
|
77
|
+
if template.is_active_link? url, active
|
78
|
+
true
|
79
|
+
else
|
80
|
+
children.each do |child|
|
81
|
+
if child.active?
|
82
|
+
return true
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
false
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
78
90
|
protected
|
79
91
|
def output
|
80
92
|
if children.empty?
|
data/lib/tabit/version.rb
CHANGED
data/tabit.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tabit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -116,7 +116,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
116
116
|
version: '0'
|
117
117
|
segments:
|
118
118
|
- 0
|
119
|
-
hash: -
|
119
|
+
hash: -4368168093489379260
|
120
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
121
|
none: false
|
122
122
|
requirements:
|