rails_nav 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rails_nav.rb +17 -4
- data/rails_nav.gemspec +1 -1
- metadata +2 -2
data/lib/rails_nav.rb
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
module Nav
|
9
9
|
def Nav.version()
|
10
|
-
'0.0.
|
10
|
+
'0.0.2'
|
11
11
|
end
|
12
12
|
|
13
13
|
class Item
|
@@ -86,6 +86,14 @@
|
|
86
86
|
end
|
87
87
|
alias_method(:to_s, :to_html)
|
88
88
|
|
89
|
+
def List.html_strategy(*value)
|
90
|
+
@html_strategy ||= (value.first || :dl).to_s
|
91
|
+
end
|
92
|
+
|
93
|
+
def List.html_strategy=(value)
|
94
|
+
@html_strategy = value.first.to_s
|
95
|
+
end
|
96
|
+
|
89
97
|
def List.to_html(*args, &block)
|
90
98
|
list = args.shift
|
91
99
|
options = args.extract_options!.to_options!
|
@@ -112,12 +120,17 @@
|
|
112
120
|
|
113
121
|
options.update(list.options)
|
114
122
|
|
123
|
+
list_ = List.html_strategy =~ /dl/ ? :dl_ : :ul_
|
124
|
+
item_ = List.html_strategy =~ /dl/ ? :dd_ : :li_
|
125
|
+
|
115
126
|
nav_(options){
|
116
|
-
|
127
|
+
send(list_){
|
117
128
|
first_index = 0
|
118
129
|
last_index = list.size - 1
|
119
130
|
|
120
|
-
|
131
|
+
if List.html_strategy =~ /dl/
|
132
|
+
dt_{ list.label } unless list.label.blank?
|
133
|
+
end
|
121
134
|
|
122
135
|
list.each_with_index do |element, index|
|
123
136
|
css_id = "nav-#{ index }"
|
@@ -126,7 +139,7 @@
|
|
126
139
|
css_class += ' first' if index == first_index
|
127
140
|
css_class += ' last' if index == last_index
|
128
141
|
|
129
|
-
|
142
|
+
send(item_, :id => css_id, :class => css_class){
|
130
143
|
options = element.html_options || {}
|
131
144
|
options[:href] = helper.url_for(element.options)
|
132
145
|
options[:class] = active[index] ? 'active' : ''
|
data/rails_nav.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_nav
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-31 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: ! 'description: rails_nav kicks the ass'
|
15
15
|
email: ara.t.howard@gmail.com
|