Permalink
Browse files

Merge pull request #96 from jtomaszewski/patch/remove-timeish-hacks

Remove css hacks in Timeish input
  • Loading branch information...
2 parents cb936f1 + 633937e commit ad4360a8b6d650aeb39a331c609281c67302a84c @sodabrew sodabrew committed Feb 13, 2014
@@ -2,52 +2,50 @@ module FormtasticBootstrap
module Inputs
module Base
module Timeish
+ FRAGMENT_CLASSES = {
+ :year => "col-xs-2",
+ :month => "col-xs-3",
+ :day => "col-xs-1",
+ :hour => "col-xs-offset-3 col-xs-1",
+ :minute => "col-xs-1",
+ :second => "col-xs-1"
+ }
def to_html
- form_group_wrapping do
- label_html <<
+ bootstrap_wrapping do
hidden_fragments <<
- form_control_row_wrapping do
+ row_wrapping do
fragments.map do |fragment|
- fragment_input_html(fragment.to_sym)
+ fragment_html(fragment.to_sym)
end.join.html_safe
end
end
end
- def form_control_row_wrapping(&block)
+ def row_wrapping(&block)
template.content_tag(:div,
template.capture(&block).html_safe,
- form_control_row_wrapper_html_options
+ :class => 'row'
)
end
- def form_control_row_wrapper_html_options
- { :class => "form-control" }
- end
-
- def fragment_input_html(fragment)
- opts = input_options.merge(:prefix => fragment_prefix, :field_name => fragment_name(fragment), :default => value, :include_blank => include_blank?)
- template.send(:"select_#{fragment}", value, opts, fragment_input_html_options(fragment))
+ def fragment_html(fragment)
+ template.content_tag(:div, :class => fragment_class(fragment)) do
+ opts = input_options.merge(:prefix => fragment_prefix, :field_name => fragment_name(fragment), :default => value, :include_blank => include_blank?)
+ template.send(:"select_#{fragment}", value, opts, fragment_input_html_options(fragment))
+ end
end
def fragment_input_html_options(fragment)
input_html_options.tap do |options|
options[:id] = fragment_id(fragment)
- options[:class] = ((options[:class] || "").split << fragment_class(fragment)).join(" ")
+ options[:class] = ((options[:class] || "").split << "form-control").join(" ")
options[:placeholder] = fragment_placeholder(fragment)
end
end
def fragment_class(fragment)
- {
- :year => "col-xs-1",
- :month => "col-xs-2",
- :day => "col-xs-1",
- :hour => "col-xs-1",
- :minute => "col-xs-1",
- :second => "col-xs-1"
- }[fragment]
+ options[:fragment_classes] || self.class::FRAGMENT_CLASSES[fragment]
end
def fragment_placeholder(fragment)
@@ -1,8 +1,14 @@
module FormtasticBootstrap
module Inputs
class DateSelectInput < Formtastic::Inputs::DateSelectInput
+ FRAGMENT_CLASSES = {
+ :year => "col-xs-4",
+ :month => "col-xs-5",
+ :day => "col-xs-3"
+ }
+
include Base
include Base::Timeish
end
end
-end
+end
@@ -1,6 +1,12 @@
module FormtasticBootstrap
module Inputs
class TimeSelectInput < Formtastic::Inputs::TimeSelectInput
+ FRAGMENT_CLASSES = {
+ :hour => "col-xs-4",
+ :minute => "col-xs-4",
+ :secound => "col-xs-4"
+ }
+
include Base
include Base::Timeish
end
@@ -5,35 +5,3 @@
.alert.alert-error > ul.error-list {
margin-bottom: 0px;
}
-
-
-/*
-** Timeish fixes.
-*/
-
-.datetime_select .form-control,
-.date_select .form-control,
-.time_select .form-control,
-.datetime .form-control,
-.date .form-control,
-.time .form-control
- {
- border: none;
- -webkit-box-shadow: none;
- box-shadow: none;
- padding: 0px 0px;
-}
-
-.datetime_select .form-control select,
-.date_select .form-control select,
-.time_select .form-control select,
-.datetime .form-control select,
-.date .form-control select,
-.time .form-control select
-{
- /* This works for me in FireFox but does not work in
- Safari or Chrome (31.) If I set a background-color
- it will suddenly work in both of those browsers.
- */
- height: 34px;
-}

0 comments on commit ad4360a

Please sign in to comment.