Forums / Developer / Date picker (pop-up)?

Date picker (pop-up)?

Author Message

Fraser Hore

Thursday 22 December 2005 3:38:02 am

I tried using the ifFormat line but for some reason i couldn't get the date object to have anything other than yyyy/mm/dd. No time. I figured out that i could use getHours() etc.

The showsTime: true parameter shows the time on the calendar so you can select it. You just have to change the time first and then select the date because of the close on selectDate part.

Next step to refine this is probably to have the calendar default to the date/date and time in the ezdate/ezdatetime attribute, if there it isn't empty. Right now both date and time default to the current date and time whether there is content in the attribute or not.

The time selection usability isn't great but it does fill in some content that can be edited, which is often faster, and it opens the possibility to improve the usability of the time selection in the calendar later, if anyone feels so inspired :-)

Do you see any problems with using the code as it is? I think I mentioned before that i'm no coder, i'm just good at googling and very stubborn :-)

Fraser Hore

Friday 23 December 2005 5:49:19 am

I created an extension which includes support for both the ezdate and ezdatetime attributes. It seems to work but please let me know if it doesn't.

Thanks a lot Xavier for the tip about Dynarch and thanks Paul for figuring out the code.

http://ez.no/community/contribs/hacks/ezdatetimeselect

Cheers,

Fraser

Łukasz Serwatka

Friday 23 December 2005 5:54:38 am

Hi Fraser,

Nice and useful contrib, thank you for sharing ;)

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Xavier Dutoit

Friday 23 December 2005 5:57:27 am

Thanks, I'll try and let you know if it works in other ez versions.

X+

http://www.sydesy.com

Fraser Hore

Friday 23 December 2005 6:23:04 am

Sorry guys, i may have put up the extension prematurely. It works fine on my local winxp machine running ezPublish 3.7, but doesn't seem to work on the linux server running ezPublish 3.7.1. Paul mentioned the problem earlier in this thread that the design.ini.append.php parameters don't seem to be picked up. Any ideas on how to solve this?

There also seems to be a problem with the layout of the calendar when it is viewed through the user interface rather than the edit interface. In the user interface the calendar spreads across the screen. Suggestions here would be great too. i think it will require setting a defined width for the calendar but í'd like to know which css div in the user interface css files are creating the problem.

Cheers,

Fraser

Fraser Hore

Friday 23 December 2005 3:25:27 pm

I think i've solved the css problem. The following lines in the classes.css file mess up the ezdatetimeselect calendar when using in the user (public) interface:

/* CALENDAR */

div.calendar table
{
width: 100%;
}

div.calendar td
{
padding: 0 2px 0 2px;
text-align: center;
font-size: 0.7em;
}

I created a new css file called classesfix.css and added it to the css file list in the design.ini.append.php. This seems to have solved the problem. It's a bit of a workaround but i didn't have any better ideas. I didn't want to edit all the different css files that come with the calendar. Partly because then it would be harder to upgrade the Dynarch calendar part if necessary.

These changes are updated in the contributions section.

Cheers,

Fraser

Bruce Morrison

Thursday 05 January 2006 8:46:29 pm

Hi Fraser

Fantastic extension.

Currently if you reedit an object and click on the calendar it will display the current date.

Heres a patch to set the default date/time to the stored date/time for ezdatetime.tpl

--- ezdatetime.tpl.orig Fri Jan  6 15:44:22 2006
+++ ezdatetime.tpl      Fri Jan  6 16:16:19 2006
@@ -39,8 +39,8 @@
 style="cursor: pointer; border: 1px solid blue; margin-top:20px;"
 title="Date & Time selector"
 alt="Select Date & Time"
-onmouseover="this.style.background=blue;"
-onmouseout="this.style.background=" />
+onmouseover="this.style.background='blue';"
+onmouseout="this.style.background=''" />

 <div class="break"></div>

@@ -49,11 +49,21 @@

 {literal}
 <script type="text/javascript">
+var year = document.getElementById("{/literal}{$attribute_base}_datetime_year_{$attribute.id}{literal}");
+var month= document.getElementById("{/literal}{$attribute_base}_datetime_month_{$attribute.id}{literal}");
+var day= document.getElementById("{/literal}{$attribute_base}_datetime_day_{$attribute.id}{literal}");
+var hour= document.getElementById("{/literal}{$attribute_base}_datetime_hour_{$attribute.id}{literal}");
+var minute= document.getElementById("{/literal}{$attribute_base}_datetime_minute_{$attribute.id}{literal}");
+var datetime =  year.value + '/' + month.value + '/' + day.value + ' ' + hour.value + ':' + minute.value;
+if (datetime == '// :')
+  datetime=null;
+
 Calendar.setup(
 {
 onSelect: OnSelectDateTime{/literal}{$attribute.id}{literal},
 showsTime: true,
-button : "trigger{/literal}{$attribute.id}{literal}"
+button : "trigger{/literal}{$attribute.id}{literal}",
+date: datetime
 }
 );
 function OnSelectDateTime{/literal}{$attribute.id}{literal}(calendar, date)

and for ezdate.tpl

--- ezdate.tpl.orig     Fri Jan  6 16:04:31 2006
+++ ezdate.tpl  Fri Jan  6 16:16:18 2006
@@ -21,8 +21,8 @@
 style="cursor: pointer; border: 1px solid blue; margin-top:20px;"
 title="Date selector"
 alt="Select Date"
-onmouseover="this.style.background=blue;"
-onmouseout="this.style.background=" />
+onmouseover="this.style.background='blue';"
+onmouseout="this.style.background=''" />

 <div class="break"></div>
 </div>
@@ -31,10 +31,18 @@

 {literal}
 <script type="text/javascript">
+var year = document.getElementById("{/literal}{$attribute_base}_date_year_{$attribute.id}{literal}");
+var month= document.getElementById("{/literal}{$attribute_base}_date_month_{$attribute.id}{literal}");
+var day= document.getElementById("{/literal}{$attribute_base}_date_day_{$attribute.id}{literal}");
+var datetime =  year.value + '/' + month.value + '/' + day.value;
+if (datetime == '//')
+  datetime=null;
+
 Calendar.setup(
 {
 onSelect: OnSelectDate{/literal}{$attribute.id}{literal},
-button : "trigger{/literal}{$attribute.id}{literal}"
+button : "trigger{/literal}{$attribute.id}{literal}",
+date: datetime
 }
 );
 function OnSelectDate{/literal}{$attribute.id}{literal}(calendar, date)

I can email you a new version to update the contribution if you like - contact me on bruce@designit.com.au

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Paul Forsyth

Friday 06 January 2006 4:52:08 am

Would it be an idea to stick this onto pubsvn? I can add if you want.

Paul

Xavier Dutoit

Saturday 07 January 2006 6:35:11 am

It's a very good idea indeed.

Fraser, do you have already a pubsvn account ? If not, contact Paul (the Borgermans one) so he can creates you one.

X+

http://www.sydesy.com

Fraser Hore

Tuesday 10 January 2006 11:41:46 am

I've uploaded Bruce's version which initializes the calendar to the previously entered date, if there is one, and corrects the capitalized S in the settings folder which was throwing off the ini. Thanks Bruce. I also slipped in a slightly nicer looking calendar icon.

There is an outstanding issue which is that the calendar will initialize to a previously entered date, but when a new date is selected, the calendar will not initialize to that new date when the calendar is reopened. It will only initialize to the new date if the object is saved and re-edited.

I think this may be because the calendar is only hidden after its initial use, rather than destroyed. I recall reading something about this in the Dynarch docs. Unfortunately I don't have time to look into it in the next few days but could try on this weekend or the next. If anyone else would like to take a crack at it, that would be even better :-)

It would be a good idea to put this on pub svn. I have to confess i've never used svn so i have no idea how to do it. Paul if you'd like to to do it that would be great!

Bruce Morrison

Tuesday 10 January 2006 2:39:28 pm

Hi Fraser

There seems to be an issue with the latest upload. It's doesn't appear that the upload worked - you may want to upload again.

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Paul Forsyth

Wednesday 11 January 2006 12:46:57 am

I've uploaded the extension to pubsvn:

http://pubsvn.ez.no/viewcvs/community/trunk/extension/ezdatetimeselect

Paul

Bruce Morrison

Wednesday 11 January 2006 3:05:11 pm

Howdy

I've modified the javascript so that the calendar and the fields are better synced. This fixes the issues outlined in Frasers last post.

I've emailed Fraser with the new files so he can update the contrib page. In the meantime the changes are on the pubsvn server.
tarball: http://pubsvn.ez.no/websvn/dl.php?repname=community&path=%2Ftrunk%2Fextension%2Fezdatetimeselect%2F&rev=0&isdir=1
svn: http://pubsvn.ez.no/community/trunk/extension/ezdatetimeselect/

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish