aboutsummaryrefslogtreecommitdiff
path: root/trunk/views/default/input/datepicker_inline.php
blob: 560074a2d43060263b00ca99ae39b200840145d3 (plain)
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
<?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
 * @link http://radagast.biz/
 * 
 */
?>

<script language="javascript">
$(document).ready(function(){
var done_loading = false;
$("#<?php echo $vars['internalname']; ?>").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 $vars['url'].'mod/event_calendar/show_events.php?mode=month&group_guid='.$vars['group_guid'].'&start_date='; ?>" + year+'-'+month+'-1';
		}
	},
    onSelect: function(date) {
		// jump to the new page
        document.location.href = "<?php echo $vars['url'].'mod/event_calendar/show_events.php?mode='.$vars['mode'].'&group_guid='.$vars['group_guid'].'&start_date='; ?>" + date.substring(0,10);
    },
    dateFormat: "yy-mm-dd",
    <?php echo $vars['range_bit']; ?>
    hideIfNoPrevNext: true,
    defaultDate: "<?php echo $vars['start_date'] .' - '.$vars['end_date']; ?>",
    <?php if ($vars['mode'] == 'week') echo 'highlightWeek: true,'; ?>
    rangeSelect: true
});
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['internalname']; ?>").datepicker("setDate", start_date, end_date);
var done_loading = true;
});
</script>
<div id="<?php echo $vars['internalname']; ?>" ></div>
<p style="clear: both;"><!-- See day-by-day example for highlighting days code --></p>