Class: DatePicker::Styles::Bootstrap

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

Instance Method Summary collapse

Instance Method Details

#mappingObject



12
13
14
# File 'lib/date_picker/styles/bootstrap.rb', line 12

def mapping()
  :moment
end

#optionsObject



7
8
9
10
11
# File 'lib/date_picker/styles/bootstrap.rb', line 7

def options()
  {
    class: 'form-control'
  }
end

#templateObject



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
41
# File 'lib/date_picker/styles/bootstrap.rb', line 15

def template() 
  %{
    <div id="<%= input_id %>_container" class="input-group">
      <div class="input-group-addon" style="cursor: pointer">
        <span class="glyphicon glyphicon-calendar"></span>
      </div>
      <%= input_html %>
    </div>
    <input id="<%= input_id %>_hidden" type="hidden" value="<%= formatted_value %>" name="<%= name %>"/>
    <script>
      (function() {
        var
          datepicker = $('#<%= input_id %>_container').datetimepicker($.extend({}, <%= json_options %>, {
            locale: <%= locale.to_json %>,
            format: <%= format.to_json %>
          }))
          .on('dp.change', function(e) {
            $('#<%= input_id %>_hidden').val(e.date.format('<%= data_format %>'));
          }).data('DateTimePicker'),
          date = new Date(<%= time; %>);
        <% if type.to_s == 'datetime' %>
          datepicker.date(moment(date))
        <% end %>
      })();
    </script>
  }
end

#typesObject



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

def types
  [:date, :datetime, :time]
end