10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/date_picker/styles/jquery_ui.rb', line 10
def template()
%{
<%= input_html %>
<input id="<%= input_id %>_hidden" type="hidden" value="<%= value %>" name="<%= name %>"/>
<script>
(function($) {
$('#<%= input_id %>').datepicker($.extend({
monthNames: <%= month_names.to_json %>,
monthNamesShort: <%= abbr_month_names.to_json %>,
dayNames: <%= day_names.to_json %>,
dayNamesMin: <%= abbr_day_names.to_json %>,
dayNamesShort: <%= abbr_day_names.to_json %>,
minDate: <%= min ? 'new Date("' + min.to_s + '")' : 'undefined' %>,
maxDate: <%= max ? 'new Date("' + max.to_s + '")' : 'undefined' %>
}, <%= picker_options %>, {
dateFormat: '<%= picker_format %>'
})).on('change', function(e) {
$('#<%= input_id %>_hidden').val($.datepicker.formatDate('<%= data_format %>', $('#<%= input_id %>').datepicker('getDate')));
});
<% if time %> $('#<%= input_id %>').datepicker('setDate', new Date(<%= time %>)); <% end %>
})(jQuery);
</script>
}
end
|