8000 Merge pull request #3818 from ccallebs/3817-style-date-picker · stephancom/activeadmin@e5ce49a · GitHub
[go: up one dir, main page]

Skip to content

Commit e5ce49a

Browse files
committed
Merge pull request activeadmin#3818 from ccallebs/3817-style-date-picker
Style 'date' input type
2 parents 53e85d6 + 33b60e0 commit e5ce49a

File tree

4 files changed

+34
-4
lines changed

4 files changed

+34
-4
lines changed

app/assets/javascripts/active_admin/application.js.coffee

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
# Initializers
22
$(document).on 'ready page:load', ->
33
# jQuery datepickers (also evaluates dynamically added HTML)
4-
$(document).on 'focus', '.datepicker:not(.hasDatepicker)', ->
4+
$(document).on 'focus', 'input.datepicker:not(.hasDatepicker)', ->
5+
$input = $(@)
6+
7+
# Only applying datepicker to compatible browsers
8+
return if $input[0].type is 'date'
9+
510
defaults = dateFormat: 'yy-mm-dd'
6-
options = $(@).data 'datepicker-options'
7-
$(@).datepicker $.extend(defaults, options)
11+
options = $input.data 'datepicker-options'
12+
$input.datepicker $.extend(defaults, options)
813

914
# Clear Filters button
1015
$('.clear_filters_btn').click ->

app/assets/stylesheets/active_admin/_forms.scss

Lines changed: 12 additions & 1 deletion
10000
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,14 @@ form {
119119
}
120120

121121
/* Text Fields */
122-
input[type=text], input[type=password], input[type=email], input[type=number], input[type=url], input[type=tel], textarea {
122+
input[type=text],
123+
input[type=password],
124+
input[type=email],
125+
input[type=number],
126+
input[type=url],
127+
input[type=tel],
128+
input[type=date],
129+
textarea {
123130
width: calc(80% - #{$text-input-total-padding});
124131
border: $border-width solid #c9d0d6;
125132
@include rounded;
@@ -134,6 +141,10 @@ form {
134141
}
135142
}
136143

144+
input[type=date] {
145+
width: calc(100% - #{$text-input-total-padding});
146+
}
147+
137148
fieldset > ol > li {
138149

139150
/* Hints */

lib/active_admin/inputs.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module Filters
99

1010
autoload :Base
1111
autoload :StringInput
12+
autoload :DatePickerInput
1213
autoload :DateRangeInput
1314
autoload :NumericInput
1415
autoload :SelectInput
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module ActiveAdmin
2+
module Inputs
3+
module Filters
4+
class DatePickerInput < ::Formtastic::Inputs::DatePickerInput
5+
include Base
6+
7+
def input_html_options
8+
super.merge(class: "datepicker")
9+
end
10+
end
11+
end
12+
end
13+
end

0 commit comments

Comments
 (0)
0