1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
<?php
/**
* JQuery data picker(inline version)
*
* @package event_calendar
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
* @author Kevin Jardine <kevin@radagast.biz>
* @copyright Radagast Solutions 2008 -2011
* @link http://radagast.biz/
*
*/
if ($vars['group_guid']) {
$link_bit = $vars['url']."event_calendar/group/{$vars['group_guid']}/%s/{$vars['mode']}";
} else {
$link_bit = $vars['url']."event_calendar/list/%s/{$vars['mode']}/{$vars['filter']}";
}
if ($vars['mode'] == 'week') {
$selected_week = date('W',strtotime($vars['start_date'].' UTC'))+1;
} else {
$selected_week = '';
}
if ($vars['mode']) {
$wrapper_class = "event-calendar-filter-period-".$vars['mode'];
} else {
$wrapper_class = "event-calendar-filter-period-month";
}
// TODO - figure out how to move this JavaScript
?>
<script language="javascript">
var selectedWeek = "<?php echo $selected_week; ?>";
highlightWeek = function(d) {
if (!selectedWeek) { return [true,''];}
//var date = $(this).datepicker('getDate');
var dayOfWeek = d.getUTCDay();
var weekNumber = $.datepicker.iso8601Week(d);
if (dayOfWeek == 6) {
weekNumber += 1;
}
if (selectedWeek == weekNumber) {
return [true,'week-highlight'];
}
return [true,''];
}
$(document).ready(function(){
var done_loading = false;
$("#<?php echo $vars['name']; ?>").datepicker({
onChangeMonthYear: function(year, month, inst) {
if(inst.onChangeToday){
day=inst.selectedDay;
}else{
day=1;
}
if (done_loading) {
// in this case the mode is forced to month
document.location.href = "<?php echo $link_bit; ?>".replace('%s', year+'-'+month+'-1');
}
},
onSelect: function(date) {
// jump to the new page
document.location.href = "<?php echo $link_bit; ?>".replace('%s', date.substring(0,10));
},
dateFormat: "yy-mm-dd",
defaultDate: "<?php echo $vars['start_date'] .' - '.$vars['end_date']; ?>",
beforeShowDay: highlightWeek
});
var start_date = $.datepicker.parseDate("yy-mm-dd", "<?php echo $vars['start_date']; ?>");
var end_date = $.datepicker.parseDate("yy-mm-dd", "<?php echo $vars['end_date']; ?>");
// not sure why this is necessary, but it seems to be
if ("<?php echo $vars['mode'] ?>" == "month") {
end_date += 1;
}
$("#<?php echo $vars['name']; ?>").datepicker("setDate", start_date, end_date);
done_loading = true;
});
</script>
<div style="position:relative;" id="<?php echo $vars['name']; ?>" class="<?php echo $wrapper_class; ?>" ></div>
<p style="clear: both;"><!-- See day-by-day example for highlighting days code --></p>
|