8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/sunrise/views/date_time_input.rb', line 8
def input
input_html_options[:value] ||= formated_value
month_count = input_html_options[:month_count] || 1
icon = "<div class='but-holder icon'><div class='act-but'><a class='but-container calend' href='javascript:void(0);' id='#{@builder.object_name}_#{attribute_name}_icon'><img src='/assets/sunrise/empty.gif' /></a></div></div>".html_safe
html = [content_tag(:div, @builder.text_field(attribute_name, input_html_options) + icon, :class => 'calend-holder')]
html << case input_type
when :date then
@builder.javascript_tag("$(function() {
$('##{@builder.object_name}_#{attribute_name}').datepicker({
numberOfMonths: #{month_count},
showButtonPanel: true
});
$('##{@builder.object_name}_#{attribute_name}_icon').click(function(){
$('##{@builder.object_name}_#{attribute_name}').datepicker('show');
});
});")
when :datetime then
@builder.javascript_tag("$(function() {
$('##{@builder.object_name}_#{attribute_name}').datetimepicker({
numberOfMonths: #{month_count},
hourGrid: 4,
minuteGrid: 10
});
$('##{@builder.object_name}_#{attribute_name}_icon').click(function(){
$('##{@builder.object_name}_#{attribute_name}').datetimepicker('show');
});
});")
end
html.join.html_safe
end
|