very_simple_menu 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/simple_menu/helper.rb +15 -15
- data/lib/simple_menu/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e87e0608cfabd5bde188fed4cc151a23274d8e8
|
4
|
+
data.tar.gz: d3713643d06f7202f8e8bd30089ff1d96dd5e9aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e97229aa7a9d9db8060ff9f80272568b42a42960585a381fd105fd2edda76748f4a4602ba9534d73bc224b1052ba7b79b05b2e893d7cb5b23b5fe4d7088aacd6
|
7
|
+
data.tar.gz: ca897d04d35b07989dc4a7f0f862eb395c225b8135a675e8019d784caa34a44080fe072ffdf9805ca857ef01e5b9bdce67906e9e3e1a71b7528cde79316a2694
|
data/lib/simple_menu/helper.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module SimpleMenu
|
2
2
|
class Helper
|
3
|
-
|
3
|
+
|
4
4
|
# can be initialized with the items passed through params
|
5
5
|
def initialize(params = {})
|
6
6
|
clear
|
@@ -8,12 +8,12 @@ module SimpleMenu
|
|
8
8
|
add(key, options[0], options[1], options[2])
|
9
9
|
end
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def clear
|
13
13
|
@items = ActiveSupport::OrderedHash.new
|
14
14
|
self
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def add(key, label = nil, url = nil, params = {})
|
18
18
|
if key.kind_of? Hash
|
19
19
|
key.each do |key, options|
|
@@ -24,47 +24,47 @@ module SimpleMenu
|
|
24
24
|
if items.has_key? key
|
25
25
|
raise("key #{key} has already been taken")
|
26
26
|
end
|
27
|
-
|
28
|
-
items[key] = [label, url, params]
|
27
|
+
|
28
|
+
items[key] = [label, url, params]
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
self
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
def items
|
35
35
|
@items
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
def active=(key)
|
39
39
|
if key
|
40
40
|
@active = key.to_sym
|
41
41
|
else
|
42
42
|
@active = nil
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
self
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
def active
|
49
49
|
@active
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
def to_s
|
53
53
|
html = []
|
54
|
-
|
54
|
+
|
55
55
|
items.each do |key, options|
|
56
56
|
if key == active
|
57
57
|
html << '<li class="active">'
|
58
58
|
else
|
59
59
|
html << '<li>'
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
html << "<a href=\"#{options[1]}\">#{options[0]}</a>"
|
63
63
|
html << '</li>'
|
64
64
|
end
|
65
|
-
|
65
|
+
|
66
66
|
if html.length > 0
|
67
|
-
"<ul>#{html.join('')}</ul>"
|
67
|
+
"<ul>#{html.join('')}</ul>".html_safe
|
68
68
|
else
|
69
69
|
""
|
70
70
|
end
|
data/lib/simple_menu/version.rb
CHANGED