What's new? | Help | Directory | Sign in
Google
calendardateselect
Rails Date Picker: Calendar Date Select
  
  
  
    
Search
for
Updated Mar 12, 2008 by timcharper
CalendarDateSelect  

Project Home

There is some rough documentation here: Documentation

The DEMO is the largest source for documentation. See the demo

This plugin is intended for rails users. If you want to use the JavaScript for a different framework, view the source code for the demo. There's plenty of example code there to help you learn how to use it.

Thanks!


Comment by zohaib.salsoft, Oct 20, 2007

i just want to try it.

Comment by HHugais, Oct 30, 2007

thank you

Comment by lukesneeringer, Jan 03, 2008

The demo server seems to be down. :(

Comment by incontrolsolutions, Jan 21, 2008

still down..

Comment by Jakub.Oboza, Jan 23, 2008

yep, still down ;>

Comment by sohaib.muneer, Jan 23, 2008

Baker from Pakistan says: I've integrated it in my CakeApp? ... thanks RoR ! soon you'd see it on the bakery :P

Comment by avocade, Jan 24, 2008

The demo site seems to be very, very down...

Comment by tolt3k, Jan 31, 2008

Deeeeeply down lol

Comment by quartermaster.branch, Feb 04, 2008

With that demo site down there's no documentation for how to use this plugin. The contents of the demo site need to be copied somewhere else. Who knows where to find a mirror or a cache?

Comment by sanjay.agravat, Feb 15, 2008

If you look at the functional tests it gives you pretty much all you need to know...

A quick example - in your view, you can do something like this: <%= f.calendar_date_select :employee_start_date, :year_range=>1970..Date.today.year, :class=>"text-input" %> or <%= calendar_date_select :employment_application, :employee_start_date, :year_range=>1970..Date.today.year, :class=>"text-input" %>

Comment by ahodgkin, Feb 21, 2008

Annoying that the site is down. Google's cache doesn't keep any of the stylesheets or JS code so it'll only give you the basic text and a few forms fields, but that's something:

http://www.google.com/search?q=cache:JmPh9EOWqjMJ:www.restatesman.com/static/calendar+http://www.restatesman.com/static/calendar

Add "&strip=1" to the end of that if you want to get the text-only version, which saves waiting for the browser to timeout while trying to load scripts, but gives slightly less context since you don't see where form elements and other (non-functioning) parts of the demo would have gone.

You'll probably only see a mostly-empty page with a few section links that don't work. It's because there's enough CSS embedded into the page that you'll need to disable styles to be able to see hidden parts (e.g. change to User mode in Opera; View -> Style -> User mode).

The Wayback Machine doesn't do any better with CSS or JS content and its newest archived copy of the page is much older than the Google cache copy. In case the Google cache version goes away, here's the basic text from the page - hopefully, nobody minds me reposting it here.

Embedded Calendars

No Time

<%= calendar_date_select_tag "e_date", nil, :embedded => true, :year_range => 10.years.ago..0.years.ago %>

With time

<%= calendar_date_select_tag "e_date_and_time", nil, :embedded => true, :time => true %>

Mixed

<%= calendar_date_select_tag "e_date_and_time_mixed", nil, :embedded => true, :time => :mixed %>

Popup Calendars

No Time

<%= calendar_date_select_tag "e_date" %>

With time

<= calendar_date_select_tag "p_date_and_time", "January 2, 2007 5:45 pm", :time => true %>

Form builder integration

Additionally, calendar_date_select can be used in a form builder, or bound to an instance variable. It's intelligent and will check the models data type to determine whether or not to use a time field (though you can still override this behavior, if you wish, by setting :time => false).

(Demo section below, crude ASCII-art added...)

Last followed up at: [ Input field ] [ Pop-up icon ]

<%
  @listing = Listing.new
  @listing.errors.add :last_follow_up_at, "They're all gonna laugh at you!"
  @listing.last_follow_up_at = "Apr 27, 2007 5:00 pm"
  %>
<%= calendar_date_select :listing, :last_follow_up_at %>

or

Created On: [ Input field ][ Pop-up icon ]

<% fields_for :listing do |f| %>
  Created On: <%= f.calendar_date_select :created_on, :embedded => true %>
<% end %>

Callbacks

Below is a list of all callbacks available to Calendar date select. all callbacks are executed from the context of the input element it is bound to (so, this.value will give you the value of the form element)

Output

(Various demo fields here, hard to understand without images/CSS; no ASCII art added)

<%= calendar_date_select_tag "event_demo", "", 
  :before_show => "log('Calendar Showing');" ,
  :after_show => "log('Calendar Shown');" ,
  :before_close => "log('Calendar closing');" ,
  :after_close => "log('Calendar closed');",
  :after_navigate => "log('Current month is ' + (param.getMonth()+1) + '/' + (param.getFullYear()));",
  :onchange => "log('value changed to - ' + $F(this));"
%>

Using callbacks to prevent date from being selected

One application of callbacks is to prevent the user from selecting dates in the past.

Other features

Remove buttons

<%= calendar_date_select_tag "no_buttons", nil, :embedded => true, :buttons => false %>

Look ma! Dropdowns stay behind!

Calendar Date Select shows on top of drop downs in IE 6... thanks to an infamous iframe hack.

(Demo went here; no ASCII art added)

Disabled form elements can't be updated

  <%= calendar_date_select_tag "disabled_field", "January 20, 2007", :disabled => true %>
  <%= calendar_date_select_tag "readonly_field", "January 20, 2007", :readonly => true %>

Month/year selector as a label

<%= calendar_date_select_tag "month_year_selector_label", "", :month_year => "label" %>

Force using the popup

Disables the input box so the user is coerced to use the popup control to input the date. <%= calendar_date_select_tag "month_year_selector_label", "", :popup => :force %>

Use a popup window with a hidden field

<%= calendar_date_select_tag "pop_up_hidden", "", :hidden => true %>

Limit the date selection to be in the past

<%= calendar_date_select_tag "birth_day", "", :valid_date_check => "date < (new Date()).stripTime()" %>

Comment by doug316, Mar 12, 2008

Great! Thanks for making this available.

Shouldn't this pick up the default formats from

ActiveSupport?::CoreExtensions?::Date::Conversions::DATE_FORMATS[:default] ActiveSupport?::CoreExtensions?::Time::Conversions::DATE_FORMATS[:default]

Comment by timcharper, Mar 12, 2008

doug316:

CDS requires a corresponding JavaScript? implementation of a parser and a formatter, so, it makes more sense to create a line of separation there.


Sign in to add a comment