From 977ac2a8fe15daeb09a4b42b46b13f33e392156e Mon Sep 17 00:00:00 2001 From: Afaque Hussain Date: Mon, 29 Apr 2013 12:15:38 -0700 Subject: [PATCH] Highlighting the current day in calendar. Summary: Highlights the current day :) I am not great in choosing colors. @chad can suggest some improvements :) Test Plan: {F41738} Reviewers: epriestley Reviewed By: epriestley CC: chad, aran, Korvin, AnhNhan Maniphest Tasks: T2627 Differential Revision: https://secure.phabricator.com/D5790 --- src/__celerity_resource_map__.php | 2 +- .../controller/PhabricatorCalendarBrowseController.php | 9 ++++++++- .../calendar/view/AphrontCalendarMonthView.php | 9 ++++++++- webroot/rsrc/css/aphront/calendar-view.css | 4 ++++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/__celerity_resource_map__.php b/src/__celerity_resource_map__.php index 6f9c5bd6e4..79d53f0d7a 100644 --- a/src/__celerity_resource_map__.php +++ b/src/__celerity_resource_map__.php @@ -741,7 +741,7 @@ celerity_register_resource_map(array( ), 'aphront-calendar-view-css' => array( - 'uri' => '/res/73061a31/rsrc/css/aphront/calendar-view.css', + 'uri' => '/res/ae6f5b54/rsrc/css/aphront/calendar-view.css', 'type' => 'css', 'requires' => array( diff --git a/src/applications/calendar/controller/PhabricatorCalendarBrowseController.php b/src/applications/calendar/controller/PhabricatorCalendarBrowseController.php index bf7ac621e1..5ab0928687 100644 --- a/src/applications/calendar/controller/PhabricatorCalendarBrowseController.php +++ b/src/applications/calendar/controller/PhabricatorCalendarBrowseController.php @@ -11,6 +11,8 @@ final class PhabricatorCalendarBrowseController $year = $request->getInt('year', $year_d); $month_d = phabricator_format_local_time($now, $user, 'm'); $month = $request->getInt('month', $month_d); + $day = phabricator_format_local_time($now, $user, 'j'); + $holidays = id(new PhabricatorCalendarHoliday())->loadAllWhere( 'day BETWEEN %s AND %s', @@ -23,7 +25,12 @@ final class PhabricatorCalendarBrowseController strtotime("{$year}-{$month}-01"), strtotime("{$year}-{$month}-01 next month")); - $month_view = new AphrontCalendarMonthView($month, $year); + if ($month == $month_d && $year == $year_d) { + $month_view = new AphrontCalendarMonthView($month, $year, $day); + } else { + $month_view = new AphrontCalendarMonthView($month, $year); + } + $month_view->setBrowseURI($request->getRequestURI()); $month_view->setUser($user); $month_view->setHolidays($holidays); diff --git a/src/applications/calendar/view/AphrontCalendarMonthView.php b/src/applications/calendar/view/AphrontCalendarMonthView.php index d8dec5367b..3597857a8d 100644 --- a/src/applications/calendar/view/AphrontCalendarMonthView.php +++ b/src/applications/calendar/view/AphrontCalendarMonthView.php @@ -2,6 +2,7 @@ final class AphrontCalendarMonthView extends AphrontView { + private $day; private $month; private $year; private $holidays = array(); @@ -27,7 +28,8 @@ final class AphrontCalendarMonthView extends AphrontView { return $this; } - public function __construct($month, $year) { + public function __construct($month, $year, $day = null) { + $this->day = $day; $this->month = $month; $this->year = $year; } @@ -65,6 +67,11 @@ final class AphrontCalendarMonthView extends AphrontView { $holiday = idx($this->holidays, $day->format('Y-m-d')); $class = 'aphront-calendar-day'; $weekday = $day->format('w'); + + if ($day_number == $this->day) { + $class .= ' aphront-calendar-today'; + } + if ($holiday || $weekday == 0 || $weekday == 6) { $class .= ' aphront-calendar-not-work-day'; } diff --git a/webroot/rsrc/css/aphront/calendar-view.css b/webroot/rsrc/css/aphront/calendar-view.css index 693dbbf78e..ac60ae82ba 100644 --- a/webroot/rsrc/css/aphront/calendar-view.css +++ b/webroot/rsrc/css/aphront/calendar-view.css @@ -75,6 +75,10 @@ table.aphront-calendar-view td div.aphront-calendar-day { background-color: #fdfae7; } +.aphront-calendar-today { + background-color: #A6FAAD; +} + .aphront-calendar-empty { background-color: #ededed; }