diff options
author | vipsoft <vipsoft@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2009-11-18 19:22:41 +0300 |
---|---|---|
committer | vipsoft <vipsoft@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2009-11-18 19:22:41 +0300 |
commit | 5b3bdf813f7074ccf6ee17725d45e02340e7c4ed (patch) | |
tree | f13a533a95107bfddc9ed1142bb0e2ef17712efc /plugins/CoreHome | |
parent | a84203da4d49a63819f7d00b40f123d8e4d318c2 (diff) |
restore highlighting of current period; jquery.calendar's customDate hook was renamed to beforeShowDay in datepicker
Diffstat (limited to 'plugins/CoreHome')
-rw-r--r-- | plugins/CoreHome/templates/calendar.js | 73 | ||||
-rw-r--r-- | plugins/CoreHome/templates/styles.css | 5 |
2 files changed, 78 insertions, 0 deletions
diff --git a/plugins/CoreHome/templates/calendar.js b/plugins/CoreHome/templates/calendar.js index 8318555110..506f994e00 100644 --- a/plugins/CoreHome/templates/calendar.js +++ b/plugins/CoreHome/templates/calendar.js @@ -14,6 +14,78 @@ var todayMonth = todayDate.getMonth(); var todayYear = todayDate.getFullYear(); var todayDay = todayDate.getDate(); +function highlightCurrentPeriod( date ) +{ + var valid = false; + + var dateMonth = date.getMonth(); + var dateYear = date.getFullYear(); + var dateDay = date.getDate(); + var style = ''; + + // we don't color dates in the future + if( dateMonth == todayMonth + && dateYear == todayYear + && dateDay >= todayDay + ) + { + return [true, '']; + } + + // we don't color dates before the minimum date + if( dateYear < piwik.minDateYear + || ( dateYear == piwik.minDateYear + && + ( + (dateMonth == piwik.minDateMonth - 1 + && dateDay < piwik.minDateDay) + || (dateMonth < piwik.minDateMonth - 1) + ) + ) + ) + { + return [true, '']; + } + + // we color all day of the month for the same year for the month period + if(piwik.period == "month" + && dateMonth == currentMonth + && dateYear == currentYear + ) + { + valid = true; + } + // we color all day of the year for the year period + else if(piwik.period == "year" + && dateYear == currentYear + ) + { + valid = true; + } + else if(piwik.period == "week" + && date.getWeek() == currentDate.getWeek() + && dateYear == currentYear + ) + { + valid = true; + } + else if( piwik.period == "day" + && dateDay == currentDay + && dateMonth == currentMonth + && dateYear == currentYear + ) + { + valid = true; + } + + if(valid) + { + return [true, 'ui-datepicker-current-period']; + } + + return [true, '']; +} + function updateDate(dateText, inst) { var date = dateText; @@ -33,6 +105,7 @@ $(document).ready(function(){ prevText: "", nextText: "", currentText: "", + beforeShowDay: highlightCurrentPeriod, defaultDate: currentDate, changeMonth: true, changeYear: true, diff --git a/plugins/CoreHome/templates/styles.css b/plugins/CoreHome/templates/styles.css index df3eb30bf0..0e35c66947 100644 --- a/plugins/CoreHome/templates/styles.css +++ b/plugins/CoreHome/templates/styles.css @@ -50,6 +50,11 @@ div.ui-datepicker { font-size: 62.5%; } +.ui-datepicker-current-period a, .ui-datepicker-current-period a:link, .ui-datepicker-current-period a:visited { + border: 1px solid #2E85FF; + color: #2E85FF; +} + #otherPeriods a { text-decoration: none; } |