I wrote one not too long ago that uses prototype. It's not too advanced 
but makes for a decent date-chooser. It has an onSelect() hook that 
fires when a day is clicked, and allows you to cycle through 
next/previous months.

If you want to check it out you can test it here (just click the little 
calendar icon).

http://www.realtown.com/sandbox/calendar

I know it can be improved but this was just a quick thing I put together 
for one of our admins.

Here's the JS script, written as a plugin (only requirement is prototype).

http://www.realtown.com/js/realtown/plugins/calendar.js

When used, the plugin automatically loads this stylesheet:

http://www.realtown.com/css/calendar.css

Here's the javascript snippet that is used to add the calendar icon next 
to the date field:

<script type="text/javascript">
<!--

var img = $(document.createElement('img'));
img.setAttribute('src', '/images/icons/calendar.png');
img.setAttribute('id', 'calendar-button');
img.setAttribute('class', 'icon');
img.setAttribute('alt', 'Date Selector');
img.style.cursor = 'pointer';
$('mdy').appendChild(img);

img.observe('click', function(event) {
    date = new Date();
    date.setMonth($('month').value - 1);
    date.setDate($('day').value);
    date.setYear($('year').value);
    var calendar = new RT.calendar({
        selected: date,
        onSelect:   function(date)
        {
            $('month').value = date.getMonth() + 1;
            $('day').value = date.getDate();
            $('year').value = date.getFullYear();
        }
    });
    var container = calendar.getCalendar();
    var position = $('calendar-button').cumulativeOffset();
    container.style.top = position.top + 'px';
    container.style.left = position.left + 'px';
});

//-->
</script>


louis w wrote:
> Looking for recommendations on date pickers which use prototype.
>
> I found this one:
> http://www.eulerian.com/en/opensource/datepicker-prototype-scriptaculous
> But it has some positioning issues in Safari.
>
> Thanks.
> >
>
>   

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to rubyonrails-spinoffs@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to