jerome-localized-frontend 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/localized_frontend/date_helper.rb +23 -31
- metadata +1 -1
@@ -1,36 +1,28 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
month_number.to_s + ' - ' + month_names[month_number]
|
18
|
-
else
|
19
|
-
month_names[month_number]
|
20
|
-
end
|
21
|
-
|
22
|
-
month_options << ((val == month_number) ?
|
23
|
-
content_tag(:option, month_name, :value => month_number, :selected => "selected") :
|
24
|
-
content_tag(:option, month_name, :value => month_number)
|
25
|
-
)
|
26
|
-
month_options << "\n"
|
27
|
-
end
|
28
|
-
select_html(options[:field_name] || 'month', month_options.join, options, html_options)
|
29
|
-
end
|
1
|
+
module ActionView::Helpers::DateHelper
|
2
|
+
def select_month(date, options = {}, html_options = {})
|
3
|
+
val = date ? (date.kind_of?(Fixnum) ? date : date.month) : ''
|
4
|
+
if options[:use_hidden]
|
5
|
+
hidden_html(options[:field_name] || 'month', val, options)
|
6
|
+
else
|
7
|
+
month_options = []
|
8
|
+
month_names = options[:use_month_names] || (options[:use_short_month] ? LocalizedFrontend['month_names']['abbreviated']: LocalizedFrontend['month_names']['full'])
|
9
|
+
month_names.unshift(nil) if month_names.size < 13
|
10
|
+
1.upto(12) do |month_number|
|
11
|
+
month_name = if options[:use_month_numbers]
|
12
|
+
month_number
|
13
|
+
elsif options[:add_month_numbers]
|
14
|
+
month_number.to_s + ' - ' + month_names[month_number]
|
15
|
+
else
|
16
|
+
month_names[month_number]
|
30
17
|
end
|
18
|
+
|
19
|
+
month_options << ((val == month_number) ?
|
20
|
+
content_tag(:option, month_name, :value => month_number, :selected => "selected") :
|
21
|
+
content_tag(:option, month_name, :value => month_number)
|
22
|
+
)
|
23
|
+
month_options << "\n"
|
31
24
|
end
|
32
|
-
|
33
|
-
ActionView::Helpers::DateHelper.alias_method_chain :select_month, :localization
|
25
|
+
select_html(options[:field_name] || 'month', month_options.join, options, html_options)
|
34
26
|
end
|
35
27
|
end
|
36
28
|
end
|