diff --git a/calendar/inc/class.calendar_ui.inc.php b/calendar/inc/class.calendar_ui.inc.php index 4b661d1aae..18a4abbfe7 100644 --- a/calendar/inc/class.calendar_ui.inc.php +++ b/calendar/inc/class.calendar_ui.inc.php @@ -732,8 +732,14 @@ class calendar_ui unset($link_vars['date']); // gets set in jscal $link[$view] = $l = egw::link('/index.php',$link_vars,false); } - $jscalendar = $GLOBALS['egw']->jscalendar->flat($link['day'],$this->date, - $link['week'],lang('show this week'),$link['month'],lang('show this month')); + + if (($flatdate = $this->date)) // string if format YYYYmmdd or timestamp + { + $flatdate = is_int($flatdate) ? adodb_date('m/d/Y',$flatdate) : + substr($flatdate,4,2).'/'.substr($flatdate,6,2).'/'.substr($flatdate,0,4); + } + $jscalendar = '
'; + $file[++$n] = array('text' => $jscalendar,'no_lang' => True,'link' => False,'icon' => False); // set a baseurl for selectboxes, if we are not running inside calendar (eg. prefs or admin) @@ -802,7 +808,13 @@ class calendar_ui )+($this->view == 'listview' ? array('ajax' => 'true') : array()),false); $file[] = array( 'text' => " -\n". + \n". $this->accountsel->selection('owner','uical_select_owner',$accounts,'calendar+',count($accounts) > 1 ? 4 : 1,False, ' style="width: '.(count($accounts) > 1 && in_array($this->common_prefs['account_selection'],array('selectbox','groupmembers')) ? '99%' : '86%').';"'. diff --git a/calendar/js/navigation.js b/calendar/js/navigation.js index c92959b42e..b0b8919a25 100644 --- a/calendar/js/navigation.js +++ b/calendar/js/navigation.js @@ -11,15 +11,19 @@ /** * Sidebox navigation for calendar * - * @todo add code from jscalendar->flat(), or better replace it altogether ... */ (function() { var script_tag = document.getElementById('calendar-navigation-script'); - var current_view_url; + var current_view_url, link_day_url,link_week_url,link_month_url,flatdate, current_date; if (script_tag) { current_view_url = script_tag.getAttribute('data-current-view-url'); + link_day_url = script_tag.getAttribute('data-link-day-url'); + link_week_url = script_tag.getAttribute('data-link-week-url'); + link_month_url = script_tag.getAttribute('data-link-week-url'); + flatdate = script_tag.getAttribute('data-date'); + current_date = script_tag.getAttribute('data-current-date'); } function load_cal(url,id,no_reset) { var owner=''; @@ -65,6 +69,47 @@ return false; } + /* + * + * @param {type} calendar + * @returns {undefined} + */ + function dateChanged(calendar) { + + if (calendar.dateClicked) { + egw_link_handler(link_day_url+"&date=" + calendar.date.print("%Y%m%d"),"calendar"); + } + } + + /* + * + * @param {type} calendar + * @returns {undefined} + */ + function todayClicked(calendar) { + egw_link_handler(link_day_url+"&date="+ current_date ,"calendar"); + } + + /* + * + * @param {type} calendar + * @param {type} weekstart + * @returns {undefined} + */ + function weekClicked(calendar,weekstart) { + egw_link_handler(link_week_url+"&date=" + weekstart.print("%Y%m%d"),"calendar"); + } + + /* + * + * @param {type} calendar + * @param {type} monthstart + * @returns {undefined} + */ + function monthClicked(calendar,monthstart) { + egw_link_handler(link_month_url+"&date=" + monthstart.print("%Y%m%d"),"calendar"); + } + /** * Initialisation after DOM *and* jQuery is loaded */ @@ -104,5 +149,16 @@ } }); }); + Calendar.setup({ + flat : "calendar-container", + flatCallback : dateChanged, + flatWeekCallback : (link_week_url)?weekClicked:'', + flatWeekTTip : egw.lang('show this week'), + flatMonthCallback : (link_month_url)?monthClicked:'', + flatMonthTTip : egw.lang('show this month'), + flatTodayCallback : (flatdate)?todayClicked:'', + date : (flatdate)?flatdate:'', + + }); }); })(); \ No newline at end of file