Revision: 4849 http://sourceforge.net/p/vexi/code/4849 Author: mkpg2 Date: 2016-03-16 21:47:10 +0000 (Wed, 16 Mar 2016) Log Message: ----------- Fix/Refactor date picker. - Stop using old date util. - Fix select last day -> 1 issue - Fix day colouring glitches
Modified Paths: -------------- branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/datefield.t branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/datepicker.t Modified: branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/datefield.t =================================================================== --- branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/datefield.t 2016-03-16 21:35:57 UTC (rev 4848) +++ branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/datefield.t 2016-03-16 21:47:10 UTC (rev 4849) @@ -122,9 +122,7 @@ $select.action ++= function(v) { var date = value; if(date==null) date = thisbox["default"]; - $datepicker.day = date?.day; - $datepicker.month = date?.month; - $datepicker.year = date?.year; + $datepicker.date = date; // have to set day,month,year before popuping up as widget initialises based on values, but // they cannot be set later ... popup = true; @@ -288,7 +286,8 @@ /** popdown when monthview wants to popdown */ datepicker_box.action ++= function(v) { - datefield.value = new vexi.js.Date("YMD", datepicker_box.year, datepicker_box.month, datepicker_box.day); + datefield.value = datepicker_box.day==null?null + :new vexi.js.Date("YMD", datepicker_box.year, datepicker_box.month, datepicker_box.day); cascade = v; } Modified: branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/datepicker.t =================================================================== --- branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/datepicker.t 2016-03-16 21:35:57 UTC (rev 4848) +++ branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/datepicker.t 2016-03-16 21:47:10 UTC (rev 4849) @@ -8,7 +8,6 @@ xmlns="org.vexi.theme.classic.lib"> <role:focusable /> - <util:date /> <ui:Box align="topleft" layout="layer"> <ui:Box orient="vertical"> <ui:Box fill="white" vshrink="true"> @@ -81,6 +80,12 @@ </ui:Box> <ui:Box id="circle" display="false" fill=":image.datecircle" shrink="true" /> + const Date = vexi.js.Date; + + thisbox.day; + thisbox.month; + thisbox.year; + /** * required because mouse press on the popbox would * otherwise de-focus the widget attached to this @@ -94,6 +99,7 @@ thisbox.action; thisbox.popdown; + thisbox.date; var olddate; var showyear; var showmonth; @@ -101,8 +107,8 @@ var showmonthdays; /** test and return whether date v represents the current date */ - var isCurrent = function(v) { - return day!=null and year==showyear and month==showmonth and day==v; + const isCurrent = function(v) { + return date.day!=null and year==showyear and month==showmonth and day==v; } var today; // vexi.js.Date @@ -117,8 +123,10 @@ /** set the dates shown according to the month/year properties */ var layoutDates = function() { // establish starting day - showweekday = getWeekday(showyear, showmonth, 1); - showmonthdays = getDaysInMonth(showyear, showmonth); + showweekday = new Date("YMD",showyear,showmonth, 1).weekday-1; + showmonthdays = new Date("YMD",showyear,((showmonth+1)>12)?1:(showmonth+1), 1).addPeriod("day", -1).day; + + // FEATURE: show day dates for prev/next months //prevmonthdays = showmonth==1 ? getDaysInMonth(showyear-1, 12) : getDaysInMonth(showyear, showmonth+1); //nextmonthdays = showmonth==12 ? getDaysInMonth(showyear+1, 1) : getDaysInMonth(showyear, showmonth+1); @@ -136,7 +144,7 @@ } } - $month.text = getMonthName(showmonth); + $month.text = Date.nameOfMonth(showmonth); $year.text = showyear; // mark today @@ -153,27 +161,28 @@ } if (olddate) { - olddate.fill = "white"; - olddate[0].textcolor = "black"; + oldate.normal = true; } olddate = day ? $dategrid[showweekday+day-1] : null; if (olddate and isCurrent(day)) { - olddate.fill = "darkblue"; - olddate[0].textcolor = "white"; + oldate.normal = true; +// olddate.fill = "darkblue"; +// olddate[0].textcolor = "white"; } } /** trap to set selected date */ var actionTrap = function(v) { var d = trapee[0].text; + trace(d); day = d != " " ? d : null; year = day ? showyear : null; month = day ? showmonth : null; + action = true; popdown = true; if (olddate) { - olddate.fill = "white"; - olddate[0].textcolor = "black"; + olddate.normal = true; } olddate = trapee; return; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Transform Data into Opportunity. Accelerate data analysis in your applications with Intel Data Analytics Acceleration Library. Click to learn more. http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140 _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn