type: widget
release: 0.0
status: in planning
demo/documentation: http://jqueryui.com/demos/datepicker/
refactor branch demo: http://jquery-ui.googlecode.com/svn/branches/labs/datepicker/demos/index.html#datepicker|default
1 - Description:
This is a brand new planning page to discuss the code re-factor of the current datepicker plugin:
http://jqueryui.com/demos/datepicker/
To have a fresh start on the planning on this re-factor, the older wiki page that covered current and future datepicker and calendar ideas is archived here: DatePickerCalendar
The specific code and functionality changes we want to address in this refactor are:
-
Add the ability to customize the buttons in the bottom button bar. This would allow users to add a "clear form" button, shortcuts like "today" or "next delivery date". This would be similar to the dialog widget. I'd imagine it would looks something like this:
$('.selector').datepicker({
buttons: {
'clear': function(event, ui){
$(this).val('');
}
}
});
-
Improve datepicker positioning/zi-ndex issues in dialogs and overlays, especially in IE
-
Re-factor the code to better match the jQuery UI API
Sampling of feature requests that we might want to consider adding or accomodating as an extension to core picker:
-
Show week numbers - worth including?
-
Select multiple days on a calendar
-
Select a range on a calendar
-
Disable list of specific dates or days of the week
-
Highlightlist of specific or days of the week (maybe with an optional custom class)
-
Assign custom events to days (use case: inline datepicker with tooltips on days)
-
Allow datepicker to show on hover or allow this to be customised in the showOn option to accept any event.
2 - Visual Design:
3 - Functional Specifications/Requirements:
(Detailed description of how the script will be structured: defaults, options, architecture, extensibility, etc.)
4 - Markup & Style:
4.1 Initial markup examples
<input type="text" name="myDatepicker">
<input type="date" name="myDatepicker" min="1970-01-01" max="2020-12-31" value="2009-05-22">
4.2 Recommended transformed HTML markup
(The HTML markup structure and classes that will be used by the scripts in the enhanced version)
4.3 Accessibility recommendation
(Detailed recommendations for ARIA, HTML markup, CSS and javascript that will contribute to universal access and full section 508 accessibility for screen readers, mobile devices and any other devices)
Issues with current datepicker:
- focus is indicated using color alone
- the next/prev month icons are invisble in high contrast mode, not indication of focused day is available.
- thecontrols/links in the date picker do not recieve programmtaic focus.
- table caption not explictly associated.
- Expansions for day abbreviations not provided
4.4 CSS & Theme
(Description of the CSS classes to be used for all states, how custom theming and Themeroller support will work.)
5 - Latest version of plugin:
http://jquery-ui.googlecode.com/svn/trunk/demos/datepicker/index.html
6 - Open issues being discussed
- What's the best way to deal with backwards compatibility? Should this be built-in for now as deprecated code for removal in 1.next + 1? Or should we provide a compatibility script which means by default if a user upgrades their existing code will break unless they also add this compatility script.
- Should the datepicker support any DOM element?
Comments (Show all 49)
GS said
at 8:43 am on May 1, 2009
Need an event for 'OnAfterShow' to allow a more robust ui interaction with the datepicker.
Jörn Zaefferer said
at 5:38 am on May 7, 2009
Should the today button do more then just select the day? http://dev.jqueryui.com/ticket/4045
Jörn Zaefferer said
at 5:39 am on May 7, 2009
Could showing the datepicker on hover improve the interaction? http://dev.jqueryui.com/ticket/4329
Ca-Phun Ung said
at 10:10 am on May 13, 2009
In fact I'd like to see the datepicker support any event specified by the developer. Whether we show it on click, on hover or on blur is a decision for the situation.
JasonReed said
at 3:51 pm on May 13, 2009
I agree completely- then again, that was my ticket so nor surprise there. :)
Jörn Zaefferer said
at 5:41 am on May 7, 2009
Support week numbers? http://dev.jqueryui.com/ticket/4131
shamun toha said
at 12:22 pm on May 8, 2009
#Feature add:
1. allow a parameters to highlight multi dates with different color (diary , agenda or other tasks need it)
2. Zoom in , Zoom out ( to use it in any container or to full screen mode)
Jörn Zaefferer said
at 10:06 am on May 12, 2009
Support custom cell highlighting? http://dev.jqueryui.com/ticket/4528
Dan said
at 8:51 am on May 18, 2009
I'm not sure if this has already been covered in the CSS changes but I've noticed some problems in IE 6 and 7...
1. The hover state only works while hovering over the anchor text for the date not the entire td element.
2. When using the changeMonth and changeYear options, the width is not calculating correctly causing the left and right floats to "overlap".
Dan said
at 9:02 am on May 18, 2009
It seems the 2nd issue is being caused because the containing div (ui-datepicker-title) does not have a width set which would allow the floated selects to get their percentages...
Dan said
at 11:58 am on May 18, 2009
Ok, a proper DTD fixes the 2nd issue but it should probably work in quirks mode too.
shamun toha said
at 2:16 pm on May 18, 2009
#Feature suggest:
1. Better the width, height of the date picker or putting a zoom in or out parameter.
example of problem issues screen shot:
http://picasaweb.google.com/lh/photo/eAuHtoMdDCHjIMbjZlGOfA?feat=directlink
Ca-Phun Ung said
at 4:30 am on May 22, 2009
Looks odd. Could you add a ticket to our bug tracker with a minimal test page? Thanks!
David Rodriguez said
at 7:44 am on May 21, 2009
I'd like to be able to separate the month day and years into three different input fields but use the datepicker to update all three inputs at the same time.
kbwood said
at 8:44 pm on May 23, 2009
See an example on the original datepicker at http://keith-wood.name/datepick.html#misc. The same should be possible with the current UI datepicker.
kbwood said
at 8:50 pm on May 23, 2009
For backwards compatibility I would prefer a separate compatibility script. This would remove unnecessary code from the head version and would encourage users to migrate. Of course, there would have to be ample warnings and documentation to inform people of the differences and ease their upgrade path.
For other DOM elements, what is the purpose of attaching the datepicker to other than an input field, a division or span?
John Worrall said
at 5:28 pm on Jun 10, 2009
Would it be possible to add to the DatePicker the ability to select Time as well?
Ca-Phun Ung said
at 1:54 am on Jun 11, 2009
I think this could be implemented as a combo widget. There is a time picker planned and the spinner may also support time. So in theory you could have both the datepicker and spinner acting upon the same input element to enhance functionality.
Ca-Phun Ung said
at 1:51 am on Jun 11, 2009
Some recent feedback about needing datepicker improvements:
http://groups.google.com/group/jquery-ui/browse_thread/thread/afe5816aaf1bd19d
Apart from complaints about needing more tuts and demos, which we know is lacking, I think the jist of the above discussion is:
* Should we change the formatDate option so it's more inline with PHP's Date function
* Should we make the callback parameters more consistent? i.e. onSelect and onClose has dateText (string) but beforeShowDay has date (date object)
Jörn Zaefferer said
at 5:02 am on Jul 8, 2009
This depends on Marc calendar engine, right?
Scott González said
at 7:09 am on Jul 8, 2009
That's the plan. Here's the code: http://github.com/1Marc/calendar-engine/tree/master
Ca-Phun Ung said
at 7:56 am on Jul 8, 2009
Sorry for my ignorance but I did not realise the plan would be to use Marc's calendar engine. Could we document this?
Ca-Phun Ung said
at 6:21 am on Jul 14, 2009
So I don't waste my limited time could we please be more specific on what the plan is? If we use Marc's calendar engine could I deduce that we won't be needing much of the existing datepicker code, hence better to start from scratch rather than refactoring?
Scott González said
at 7:10 am on Jul 14, 2009
The plan is to review Marc's calendar engine to see if we want to use it (my guess is yes, since he specifically wrote it to address all of the issues of our current datepicker). If I was working on this, I'd be starting from scratch.
Chiefs said
at 1:15 pm on Jul 15, 2009
I really like that widget. Question for u: how can I call t popup from a div, a link etc. let's say "Choose Date" or something. Do I always need to call it from input type="date"?
Blaz said
at 2:31 am on Aug 4, 2009
Most of the users with more experiences probably already know this but
others can have problems when implementing datepicker to ASP.NET
controls, for example textbox (especially if they are inside other
control - web form, repeater).
This is a solution somebody posted on asp.net forums:
1.) "Change the TextBox's CssClass property to "dateTextBox". Then,
use exactly this JavaScript (remove the other inline script in that
area so there are no extraneous errors):"
1.) (inside web form, control, etc.)
<script type="text/javascript">
$(document).ready(function() {
$('.dateTextBox').datepicker();
});
</script>
2.) if you do not have web control. You also don't need the css.
<script type="text/javascript">
$(function ()
{$('#date').datepicker();}
);
</script>
also you must have in masterpage the following code:
<link type="text/css" href="../CSS/jquery-
ui-1.7.2.calendar.css"rel="stylesheet" />
<script type="text/javascript" src="../JS/jquery-1.3.2.min.js" ></
script>
<script type="text/javascript" src="../JS/jquery-
ui-1.7.2.custom.min.js"></script>
<script type="text/javascript">
$(function(){
// Datepicker
$('#datepicker').datepicker({
inline: true
});
//hover states on the static widgets
$('#dialog_link, ul#icons li').hover(
function() { $(this).addClass('ui-state-hover'); },
function() { $(this).removeClass('ui-state-hover'); }
);
});
</script>
There can be better options to do this. Also you must notice that this
don't work in IE ("appearing" effect) as same as is working if you
have input type on page without any controls.
Any additional comments are welcome.
Jörn Zaefferer said
at 1:32 pm on Sep 1, 2009
Of the options on the current datepicker, appendText is a good candidate to be dropped. It specifies the text to append after the input element. That is really easy enough do to with regular jQuery methods and outside the scope of the datepicker plugin.
Jörn Zaefferer said
at 1:39 pm on Sep 1, 2009
The showOn, buttonText, buttonImage, and buttonImageOnly options could be refactored. Instead of exposing all these options, let the user create the input and pass that along for binding a click event; or open the datepicker on focus of the input by default, and let the user specify other events to open the picker, via datepicker("open").
Jörn Zaefferer said
at 1:41 pm on Sep 1, 2009
The animation-options are odd at best. You have to set duration to an empty string (or any falsy? not sure) to disable animations. Then there is also showAnim and showOptions...
Jörn Zaefferer said
at 1:42 pm on Sep 1, 2009
numberOfMonths, stepMonths and showCurrentAtPos are certainly useful, but the names don't suggest any relation between those, while they are actually closely related.
Jörn Zaefferer said
at 1:50 pm on Sep 1, 2009
The altField option can be easily implemented using the select-callback.
Jörn Zaefferer said
at 1:54 pm on Sep 1, 2009
onChangeMonthYear, onSelect and onClose need renaming.
Jörn Zaefferer said
at 1:58 pm on Sep 1, 2009
The isDisabled method needs to be replaced with option-disabled. enable/disable methods, too.
get/setDate should be merged into one method.
show/hide could be renamed to open/close, to be more consistent with dialog.
The dalog-method is odd...
Jörn Zaefferer said
at 1:59 pm on Sep 1, 2009
The beforeShow API is, well, odd. Returning arrays with two elements??
Jaggi said
at 9:48 am on Sep 2, 2009
i'd like to see some access to some of datepickers date functions. This came about when i needed to do something with max date. I had to do it manually in the end but basically what i did was have a start date and end date (range) and i set the minDate of end date to the value returned by start date by doing ($('#startDate').datepicker('getDate') ) then i needed to set the maxDate of the end date to two months in the future of minDate. There was no easy way to do this with jquery so had to create a function to do using the date modifiers but we can change the date pretty easily on maxDate by doing maxDate: '+2'; what i'd like to be able to do is something that would support something like:
maxDate: $('#startDate').datepicker('getDate')+ '+1m'; (this isn't actually a proper way it should or can work i'm just trying to show it in laymens terms).
it might be done by being able to access one of datepickers actual functions that works it out and have the ability to set the date to start from but i think it'd be useful all the same. What i actually discovered here however i would consider a bug to be honest, maxDate works out the date based off todays date but doesn't take into account values set by minDate/defaultDate which i think it should as we're kinda already telling you where to take the date from.
Jörn Zaefferer said
at 1:43 pm on Sep 2, 2009
This should be trivial with Marc's calendar engine. I'll ping Marc about it.
gtraxx said
at 8:46 am on Sep 30, 2009
Hello, after building a site into several languages.
I found that using $. Datepicker.setDefaults ($. Datepicker.regional ['en']); dynamic does not work very well with the "fr".
The locale does not work with English.
Example in PHP:
if ($ lang == 'en') (
print '$.datepicker.regional [ "en"]';
) elseif ($ lang == 'fr') (
print '$.datepicker.regional [ "fr"]';
)
My files for english params :
/* English initialisation for the jQuery UI date picker plugin. */
/* Written by Gerits Aurelien. (gerits point aurelien at gmail point com)*/
jQuery(function($){
$.datepicker.regional['en'] = {
closeText: 'Done', // Display text for close link
prevText: 'Prev', // Display text for previous month link
nextText: 'Next', // Display text for next month link
currentText: 'Today', // Display text for current month link
monthNames: ['January','February','March','April','May','June',
'July','August','September','October','November','December'], // Names of months for drop-down and formatting
monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], // For formatting
dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting
dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting
dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Column headings for days starting at Sunday
dateFormat: 'mm/dd/yy', // See format options on parseDate
firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
isRTL: false // True if right-to-left language, false if left-to-right
};
$.datepicker.setDefaults($.datepicker.regional['en']);
});
David Petersen said
at 6:11 pm on Feb 27, 2010
I have made a lot of progress in refactoring the datepicker code. Got it using the widget factory and Marc's calendar. Will post the code after the switch to github, (gives me more time to clean up the code)
One question I had while working through that code was, is datepicker('dialog') really necessary? Doesn't that option just create glorified inline datepicker that is absolute positioned on the screen? Seems like with the new position plugin there is no need to support this as an option of the datepicker. It could easily be handled by doing this:
$('#inl2').datepicker({
select: function(){
// do something with the selected date then hide it
$(this).hide();
}
}).position({my:'center', at:'center', of:window});
Is it worth the extra code needed to support it as an option when it is so easy to do it outside the plugin, also considering how little use this option really gets?
Scott González said
at 8:47 pm on Feb 27, 2010
Hey David,
As a general rule you should leave out everything that's not needed by 90% of the users. I'd start with the essentials and then we can figure out which options we want built in, which options should be built as extensions and which options should be left out.
kbwood said
at 2:14 am on Mar 7, 2010
I've done a refactor of the datepicker to conform to the current widget standard. It's available for review at https://jquery-ui.googlecode.com/svn/branches/labs/datepicker2.
As well as converting it to a widget, I've added the following:
* a templating ability to allow the end-user more control over the appearance of the datepicker,
* a command structure to allow end-users to add/change command buttons on the datepicker,
* common date routines for general use,
* use of the position plugin for placement,
* an extension module (jquery.ui.datepicker.ext.js) with less common usage requirements.
Please have a look through the demos and comment...
You don't have permission to comment on this page.