diff options
Diffstat (limited to 'mod/event_calendar/views/default/input')
3 files changed, 172 insertions, 0 deletions
diff --git a/mod/event_calendar/views/default/input/datepicker_inline.php b/mod/event_calendar/views/default/input/datepicker_inline.php new file mode 100644 index 000000000..3fd9c37af --- /dev/null +++ b/mod/event_calendar/views/default/input/datepicker_inline.php @@ -0,0 +1,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>
\ No newline at end of file diff --git a/mod/event_calendar/views/default/input/timepicker.php b/mod/event_calendar/views/default/input/timepicker.php new file mode 100644 index 000000000..2cc95ced7 --- /dev/null +++ b/mod/event_calendar/views/default/input/timepicker.php @@ -0,0 +1,51 @@ +<?php +$time_format = elgg_get_plugin_setting('timeformat', 'event_calendar'); +if (!$time_format) { + $time_format = '24'; +} + +$value = $vars['value']; +if (is_numeric($value)) { + $hour = floor($value/60); + $minute = ($value -60*$hour); +} else { + $hour = 0; + $minute = 0; +} + +$hours = array(); +$minutes = array(); + +if ($time_format == '12') { + $meridians = array('am'=>'am','pm'=>'pm'); + if ($hour == 0) { + $hour = 12; + $meridian = 'am'; + } else if ($hour == 12) { + $meridian = 'pm'; + } else if ($hour < 12) { + $meridian = 'am'; + } else { + $hour -= 12; + $meridian = 'pm'; + } + for($h=1;$h<=12;$h++) { + $hours[$h] = $h; + } +} else { + for($h=0;$h<=23;$h++) { + $hours[$h] = $h; + } +} + +for($m=0;$m<60;$m=$m+5) { + $mt = sprintf("%02d",$m); + $minutes[$m] = $mt; +} + +echo elgg_view('input/dropdown',array('name'=>$vars['name'].'_hour','value'=>$hour,'options_values'=>$hours)); +echo " <b>:</b> "; +echo elgg_view('input/dropdown',array('name'=>$vars['name'].'_minute','value'=>$minute,'options_values'=>$minutes)); +if ($time_format == '12') { + echo elgg_view('input/dropdown',array('name'=>$vars['name'].'_meridian','value'=>$meridian,'options_values'=>$meridians)); +} diff --git a/mod/event_calendar/views/default/input/timepicker_old.php b/mod/event_calendar/views/default/input/timepicker_old.php new file mode 100644 index 000000000..1d2156cda --- /dev/null +++ b/mod/event_calendar/views/default/input/timepicker_old.php @@ -0,0 +1,38 @@ +<?php + +$time_format = elgg_get_plugin_setting('timeformat', 'event_calendar'); +if (!$time_format) { + $time_format = 24; +} + +$value = $vars['value']; +if (is_numeric($value)) { + $hour = floor($value/60); + $minute = ($value -60*$hour); + + // add 1 to avoid pulldown 0 bug + $hour++; + $minute++; +} else { + $hour = '-'; + $minute = '-'; +} + +$hours = array(); +$hours['-'] = '-'; + +for($i=0;$i<$time_format;$i++) { + $hours[$i+1] = $i; +} + +$minutes = array(); +$minutes['-'] = '-'; + +for($i=0;$i<60;$i=$i+15) { + $minutes[$i+1] = sprintf("%02d",$i); +} + +echo elgg_view('input/dropdown',array('name'=>$vars['name'].'_h','value'=>$hour,'options_values'=>$hours)); +echo elgg_view('input/dropdown',array('name'=>$vars['name'].'_m','value'=>$minute,'options_values'=>$minutes)); + +?>
\ No newline at end of file |