Sha256: 1fb43a718b93f1690845591f0285753932138249ad7c8638691e5c57bd3a4d26

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

module SimpleForm
  module Inputs
    class DateTimeInput < Base
      def input
        #@builder.send(:"#{input_type}_select", attribute_name, input_options, input_html_options)
        html = [@builder.text_field(attribute_name, input_html_options)]
        
        html << case input_type
          when :date then
            @builder.javascript_tag("$(function() {
		          $('##{@builder.object_name}_#{attribute_name}').datepicker({
			          numberOfMonths: 2,
			          showButtonPanel: true
		          });
	          });")
	        when :datetime then
	          @builder.javascript_tag("$(function() {
		          $('##{@builder.object_name}_#{attribute_name}').datetimepicker({
			          numberOfMonths: 2,
			          hourGrid: 4,
                minuteGrid: 10
		          });
	          });")
	      end

	      html.join.html_safe
      end

    private

      def has_required?
        false
      end

      def label_target
        case input_type
        when :date, :datetime
          "#{attribute_name}_1i"
        when :time
          "#{attribute_name}_4i"
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sunrise-core-0.1.2 lib/sunrise/views/inputs/date_time_input.rb
sunrise-core-0.1.1 lib/sunrise/views/inputs/date_time_input.rb
sunrise-core-0.1.0 lib/sunrise/views/inputs/date_time_input.rb