<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mindtonic &#187; prototype</title>
	<atom:link href="http://blog.mindtonic.net/tag/prototype/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mindtonic.net</link>
	<description>Thoughts on Music and Application Development</description>
	<lastBuildDate>Fri, 30 Jul 2010 18:08:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Calendar Date Select Magic For Rails</title>
		<link>http://blog.mindtonic.net/calendar-date-select/</link>
		<comments>http://blog.mindtonic.net/calendar-date-select/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 00:51:00 +0000</pubDate>
		<dc:creator>mindtonic</dc:creator>
				<category><![CDATA[Gems]]></category>
		<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://blog.mindtonic.net/?p=71</guid>
		<description><![CDATA[Calendar Date Select is a new(ish) &#8220;date and time picker&#8221;, developed by Tim Harper, designed primarily for developers to use in Rails applications. It uses the standard Prototype JavaScript library, and is easily installed as a Rails plugin: script/plugin install http://calendardateselect.googlecode.com/svn/tags/calendar_date_select The demo seems to be down, but here is some more detailed info: http://ianli.com/site/HowTo/UseCalendarDateSelectRailsPlugin. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://code.google.com/p/calendardateselect/">Calendar Date Select</a> is a new(ish) &#8220;date and time picker&#8221;, developed by Tim Harper, designed primarily for developers to use in Rails applications. It uses the standard Prototype JavaScript library, and is easily installed as a Rails plugin:</p>
<p><code>script/plugin install http://calendardateselect.googlecode.com/svn/tags/calendar_date_select</code></p>
<p>The <a href="http://electronicholas.com/calendar">demo</a> seems to be down, but here is some more detailed info:  <a href="http://ianli.com/site/HowTo/UseCalendarDateSelectRailsPlugin">http://ianli.com/site/HowTo/UseCalendarDateSelectRailsPlugin</a>.  You can also see the original contents of the demo site about halfway down the Google Code wiki for the project: <a href="http://code.google.com/p/calendardateselect/wiki/CalendarDateSelect">http://code.google.com/p/calendardateselect/wiki/CalendarDateSelect</a></p>
<p>On the surface this is a very easy plugin to install and use.  It seems the common problem is that there is very little documentation available and the demo server is down.  After installing the gem, I was able to run &#8220;gem server&#8221; and view the rdoc for the plugin.  A couple of things I thought would be helpful to repost here:</p>
<hr />
<p>Form Helpers:</p>
<pre>
<strong>calendar_date_select(object, method, options={})</strong>

Similar to the difference between text_field_tag and text_field, this method behaves like text_field

It receives the same options as calendar_date_select_tag. Need for time selection is automatically detected by checking the corresponding column meta information of Model#columns_hash

<strong>calendar_date_select_tag( name, value = nil, options = {})</strong>

Similar to text_field_tag, but adds a calendar picker, naturally.
Arguments

  +name+ - the html name of the tag
  +value+ - When specified as a string, uses value verbatim.  When Date, DateTime, Time, it converts it to a string basd off the format set by CalendarDateSelect#format=
  +options+ - ...

Options
:embedded

Put the calendar straight into the form, rather than using a popup type of form.

  <%= calendar_date_select_tag "name", "2007-01-01", :embedded => true %>

:hidden

Use a hidden element instead of a text box for a pop up calendar. Not compatible with :embedded => true. You‘ll probably want to use an onchange callback to do something with the value.

  <span id='cds_value' />
  <%= calendar_date_select_tag "hidden_date_selector", "", :hidden => "true", :onchange => "$('cds_value').update($F(this));" %>

:image

Specify an alternative icon to use for the date picker.

To use /images/groovy.png:

  <%= calendar_date_select_tag "altered_image", "", :image => "groovy.png" %>

:minute_interval

Specifies the minute interval used in the hour/minute selector. Default is 5.

  <%= calendar_date_select_tag "month_year_selector_label", "", :minute_interval => 15 %>

:month_year

Customize the month and year selectors at the top of the control.

Valid values:

 * "dropdowns" (default) - Use a separate dropdown control for both the month and year
 * "label" - Use static text to show the month and the year.

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

:popup => ‘force‘

Forces the user to use the popup calendar by making it‘s text-box read-only and causing calendar_date_select to override it‘s default behavior of not allowing selection of a date on a target element that is read-only.

  <%= calendar_date_select_tag "name", "2007-01-01", :popup => "force" %>

:time

Show time in the controls. There‘s three options:

 * +true+ - show an hour/minute selector.
 * +false+ - don't show an hour/minute selector.
 * +"mixed"+ - Show an hour/minute selector, but include a "all day" option - allowing them to choose whether or not to specify a time.

:year_range

Limit the year range. You can pass in an array or range of ruby Date/Time objects or FixNum‘s.

  <%= calendar_date_select_tag "e_date", nil, :year_range => 10.years.ago..0.years.from_now %>
  <%= calendar_date_select_tag "e_date", nil, :year_range => [0.years.ago, 10.years.from_now] %>
  <%= calendar_date_select_tag "e_date", nil, :year_range => 2000..2007 %>
  <%= calendar_date_select_tag "e_date", nil, :year_range => [2000, 2007] %>

CALLBACKS

The following callbacks are available:

 * before_show / after_show
 * before_close / after_close
 * after_navigate - Called when navigating to a different month. Passes first parameter as a date object refering to the current month viewed
 * onchange - Called when the form input value changes

  <%= 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));"

}}}

All callbacks are executed within the context of the target input element. If you‘d like to access the CalendarDateSelect object itself, you can access it via "this.calendar_date_select".

For example:

  <%= calendar_date_select_tag "event_demo", "", :after_navigate => "alert('The current selected month is ' + this.calendar_date_select.selected_date.getMonth());" ,
</pre>
<hr />
<p>For use with Form Builders</p>
<p><strong>calendar_date_select(method, options = {})</strong></p>
<hr />
<p><strong>Controllers:</strong></p>
<p>In my application, I am using a custom form builder, so I used the calendar_date_elect with the form builder.  The options hash appears to be the same as in the other view tags, so I just passed along what I needed:</p>
<p><code><%= f.calendar_date_select "date", :embedded => true, :year_range => 1.year.ago..5.years.from_now, :time => false %></code></p>
<p>I was pleased to discover that, utilizing some of the magic of Rails, the date property on my event was automatically turned into a datetime attribute, and on editing, was reloaded into the calendar as expected.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mindtonic.net/calendar-date-select/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
