modified dob for member profile

This commit is contained in:
Harry Bomrah 2015-06-24 01:38:12 +08:00
parent ed24126648
commit 3dc625e34f
5 changed files with 28 additions and 2 deletions

View File

@ -791,6 +791,15 @@ legend {
display: block;
}
.simple-date-picker input:first-child {
margin-right: 3px;
}
.simple-date-picker select {
margin-right: 3px;
}
/* IE go die */
:root #sidebar .sub-nav-block:before {
display: block\9;

View File

@ -41,6 +41,10 @@ module OrbitBackendHelper
concat hidden_field(object_name, method, :value => options[:value])
concat separated_picker(object_name, method, options)
end
when 'simple'
content_tag :div, :id => options[:id], :class => options[:class] do
simple_picker(object_name, method, options)
end
else
content_tag :div, :id => options[:id], :class => options[:class] do
default_picker(object_name, method, options)

View File

@ -32,6 +32,19 @@ module OrbitFormHelper
end
end
def simple_picker(object_name, method, options)
html = "<div class='simple-date-picker'>
<input type='text' class='span1' #{(options[:value] ? "value='#{options[:value].day}'" : "")} placeholder='Date' onkeypress='return (event.charCode >= 48 && event.charCode <= 57) || event.keyCode == 8 || event.keyCode == 46 || (event.keyCode >= 37 && event.keyCode <= 40) || event.keyCode == 9' onkeyup='this.value=(this.value.length <= 2 ? (parseInt(this.value) > 0 && parseInt(this.value) < 32 ? this.value : this.value.substring(0,this.value.length-1)) : this.value.substring(0,this.value.length-1))' onblur='var el = document.getElementById(\"#{object_name.to_s}_#{method.to_s}\");var k = el.value.split(\"-\");if(this.value){k[2]=this.value; el.value = k.join(\"-\")};'>
<select class='span2' onchange='var el = document.getElementById(\"#{object_name.to_s}_#{method.to_s}\");var k = el.value.split(\"-\");if(this.value){k[1]=this.value; el.value = k.join(\"-\")};'>"
["January","February","March","April","May","June","July","August","September","October","November","December"].each_with_index do |mon,index|
html = html + "<option value='#{(index < 9 ? "0" : "")}#{(index + 1).to_s}' #{(options[:value] && options[:value].month == (index + 1) ? "selected='selected'" : "")}>#{mon}</option>"
end
html = html + "</select><input type='text' class='span1' #{(options[:value] ? "value='#{options[:value].year}'" : "")} placeholder='Year' onkeypress='return (event.charCode >= 48 && event.charCode <= 57) || event.keyCode == 8 || event.keyCode == 46 || (event.keyCode >= 37 && event.keyCode <= 40) event.keyCode == 9' onkeyup='this.value=(this.value.length == 4 ? (parseInt(this.value) > 1900 && parseInt(this.value) < 3000 ? this.value : this.value.substring(0,this.value.length-1)) : (this.value.length > 4 ? this.value.substring(0,this.value.length-1) : this.value))' onblur='var el = document.getElementById(\"#{object_name.to_s}_#{method.to_s}\");var k = el.value.split(\"-\");if(this.value){k[0]=this.value; el.value = k.join(\"-\")};'>"
html = html + hidden_field(object_name, method, :value => options[:value] || "1901-01-01")
html = html + "</div>"
html.html_safe
end
def date_picker(object_name, method, options)
custom = {}
custom[:format] = options[:format] || 'yyyy/MM'

View File

@ -13,7 +13,7 @@ class MemberProfile
field :sex
field :sid
field :office_tel
field :birthday, type: DateTime
field :birthday, type: Date
field :address, type: String, localize: true
field :personal_website
field :autobiography, type: String, localize: true

View File

@ -116,7 +116,7 @@
<div class="control-group">
<label for="birthday" class="control-label muted"><%= t("users.birthday")%></label>
<div class="controls">
<%= f.datetime_picker :birthday, :no_label => true, :format=>"yyyy/MM/dd" %>
<%= f.datetime_picker :birthday, :no_label => true, :format=>"yyyy/MM/dd", :picker_type => "simple" %>
</div>
</div>