Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#1386 closed enhancement (fixed)

[patch][cla] DatePicker Rewritten

Reported by: ktiedt@… Owned by: bill
Priority: high Milestone:
Component: Widgets Version: 0.3
Keywords: datepicker Cc: ktiedt@…
Blocked By: Blocking:

Description

I have rewritten datepicker to get rid of a lot of long loops (previous version looped several times to build the calendarUI, this one goes straigt from day1 of the display to dayEnd (I say dayEnd because this version also does not display 42 days everytime)

New features:

startDate/endDate any dates before/after (respectively) are disabled from clicking and incremental functions are disabled in the appropriate directions if your current display shows all available days. IE. if startDate = Oct 10th 2006 and your display showed October 1 through 25, you couldnt scroll back a week or month or year... but you could still go forwards if no endDate was set startWeekOn: i18n support for first day of week or you can force any weekday as first day by setting startWeekOn="X" where X is the day index 0-6 improved currentMonth detection: previously whatever month started in week1 of the display was the month that the label showed now whichever month has more than half their days displayed is the current month and the label is updated accordingly adjustWeeks: true/false -- if you set this to true, the calendar will automatically remove/add weeks in order to fully display the current month, if set to false, DatePicker? reverts to 42 day display like the previous version displayed

I believe thats it.. This version takes advantage of Date() objects for almost everything date related, a few things simple math was easier to do. There are a few new functions inside of dojo.widget.DatePicker?.util, daysBetween(dateA,dateB) returns the # of days between those 2 dates.. (used for start/endDate features) and getAdjustedDays(date,startOfWeek) is a i18n'ified version of dateObject.getDay() that will return the modified day index for weeks

I think that about covers it... -Karl

Attachments (10)

DatePicker.rar (5.1 KB) - added by ktiedt@… 13 years ago.
new Datepicker files (not in diff files due to the size of chage in the JS file)
DatePicker.diff (24.1 KB) - added by ktiedt@… 13 years ago.
Diff of DatePicker?.js with current more recent fixes
test_DatePicker.html.diff (1.8 KB) - added by ktiedt@… 13 years ago.
test_DatePicker.html for new datePicker features
DatePicker.js.diff (25.3 KB) - added by ktiedt@… 13 years ago.
refactored new version of the DatePicker?.js (major changes thanks to Adams i18n refactor :P)
DatePicker.html.diff (1.4 KB) - added by ktiedt@… 13 years ago.
new DatePicker?.html template, lighter and slimmer than the previous versions
DatePicker.css.diff (343 bytes) - added by ktiedt@… 13 years ago.
new DatePicker?.css file... adds style to support start/endDates
DatePicker_fixed.js.diff (25.1 KB) - added by ktiedt@… 13 years ago.
Missed fixing my template paths... Go me! (renamed templates back to what they should be)
DatePicker_+_DropDownDatePicker_fix.diff (25.2 KB) - added by ktiedt@… 13 years ago.
Adam Peller pointed out a problem with DropDownDatePicker?, this patch fixes the problem in the rewritten DatePicker?
final_test_DatePicker.html.diff (2.8 KB) - added by ktiedt@… 13 years ago.
Maybe I'm over doing it.. but I included the last 3 features that I didnt previously include a test case for…
DatePicker.zip (17.9 KB) - added by tk 13 years ago.
All the correct diffs zipped into, one file and renamed to the filename they are diff's of. Per Dylan's request.

Download all attachments as: .zip

Change History (20)

Changed 13 years ago by ktiedt@…

Attachment: DatePicker.rar added

new Datepicker files (not in diff files due to the size of chage in the JS file)

comment:1 Changed 13 years ago by Adam Peller

It would be great if we could move some of the Date "math" utilities into dojo.date.common for reuse. For example, daysBetween sounds a lot like dojo.date.diff (see #1385)

comment:2 Changed 13 years ago by dylan

Milestone: 0.4
Summary: DatePicker Rewritten[patch][cla] DatePicker Rewritten

I need to review and test this... will do that by Wednesday.

comment:3 Changed 13 years ago by ktiedt@…

Milestone: 0.4

I will be submitting another file (probably even in diff format since Adam pointed out a valid point (you can view the file in trac then) that fiexes a few problems.. One problem I am stuck on though is if I have more than 1 DatePicker? with different weekStartsOn (or locales defined that use different first days of the week) All datePickers will redraw the header to match the last one used the 1st time you interact with it by selecting a date...

Any thoughts on what I could do to avoid that?

comment:4 Changed 13 years ago by ktiedt@…

Milestone: 0.4

Current diff with the navigation bug fixes (I forgot to write the disable code for start/endDate)

-Karl

Changed 13 years ago by ktiedt@…

Attachment: DatePicker.diff added

Diff of DatePicker?.js with current more recent fixes

comment:5 Changed 13 years ago by ktiedt@…

Due to changes in i18n and date files, here is an even more recent patch... (and I think SVN b0rked that patch file anyways)

This version implements dojo.date.add, and dojo.date.diff, removing code behind dojo.widget.DatePicker?.util.daysBetween() it's now just used as an alias to dojo.date.diff()

Also added a check for incremental functions (which also now use dojo.date.add() instead of home baked incremental functions) so if you have a startDate or endDate and click next/previous year/month and you will over jump the start/endDate it will automatically take you to the farthest date you could get to in that direction...

Fixed problem with days of Week changing on click.. turns out that in JS calling the dojo.date.getNames function and then modifiny the resulting array was modifying the array in dojo.date.getNames... Without further delay, here is diff file for each file including a new and improved test_ case :)

Changed 13 years ago by ktiedt@…

Attachment: test_DatePicker.html.diff added

test_DatePicker.html for new datePicker features

Changed 13 years ago by ktiedt@…

Attachment: DatePicker.js.diff added

refactored new version of the DatePicker?.js (major changes thanks to Adams i18n refactor :P)

Changed 13 years ago by ktiedt@…

Attachment: DatePicker.html.diff added

new DatePicker?.html template, lighter and slimmer than the previous versions

Changed 13 years ago by ktiedt@…

Attachment: DatePicker.css.diff added

new DatePicker?.css file... adds style to support start/endDates

Changed 13 years ago by ktiedt@…

Attachment: DatePicker_fixed.js.diff added

Missed fixing my template paths... Go me! (renamed templates back to what they should be)

Changed 13 years ago by ktiedt@…

Adam Peller pointed out a problem with DropDownDatePicker?, this patch fixes the problem in the rewritten DatePicker?

Changed 13 years ago by ktiedt@…

Maybe I'm over doing it.. but I included the last 3 features that I didnt previously include a test case for...

comment:6 Changed 13 years ago by ktiedt@…

The DDDP fix basically moves the storeDate value out of the initializer function and so that it can be passed as a "default value".

The test_ patch includes tests for staticDisplay=true and start/endDate that is only a few weeks long but over laps from the end of a month to the beginning of the next. (this should force the display to start at the earliest week before the startDate and lock a staticDisplay so you cant scroll past the start/endDates.

Live version can be view here: http://dojo.xnet.org/tests/widget/test_DatePicker.html

-Karl

comment:7 Changed 13 years ago by dylan

ok, can you please add or send me an archive with the patches I should apply... the list above is a bit unclear.

Changed 13 years ago by tk

Attachment: DatePicker.zip added

All the correct diffs zipped into, one file and renamed to the filename they are diff's of. Per Dylan's request.

comment:8 Changed 13 years ago by dylan

Resolution: fixed
Status: newclosed

(In [5566]) substantial improvements and rewrite of the DatePicker?, fixes #1386

comment:9 Changed 13 years ago by dylan

(In [5597]) references #1386, improvements to the rewritten DatePicker? widger, courtesy of tk (Karl Tiedt)

comment:10 Changed 12 years ago by (none)

Milestone: 0.4

Milestone 0.4 deleted

Note: See TracTickets for help on using tickets.