Class: DatePicker::Styles::JqueryUi

Inherits:
Object
  • Object
show all
Defined in:
lib/date_picker/styles/jquery_ui.rb

Instance Method Summary collapse

Instance Method Details

#mappingObject



7
8
9
# File 'lib/date_picker/styles/jquery_ui.rb', line 7

def mapping()
  :jquery_ui
end

#templateObject



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

#typesObject



4
5
6
# File 'lib/date_picker/styles/jquery_ui.rb', line 4

def types
  [:date]
end