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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
|
<?php echo $GLOBALS['cManager']->getJavaScript('eventform', 'category') ?>
<script type="text/javascript">
<?php if (!Util::nonInputVar('issearch')): ?>
function setInterval(field)
{
elt = document.eventform[field];
if (elt.value == "") {
elt.value = 1;
}
if (field == 'recur_daily_interval') clearFields(1);
else if (field == 'recur_weekly_interval') clearFields(2);
else if (field == 'recur_day_of_month_interval') clearFields(3);
else if (field == 'recur_week_of_month_interval') clearFields(4);
else if (field == 'recur_yearly_interval') clearFields(5);
}
function setRecur(index)
{
document.eventform.recur[index].checked = true;
clearFields(index);
}
function clearFields(index)
{
var f = document.eventform;
if (index != 1) f.recur_daily_interval.value = '';
if (index != 2) {
f.recur_weekly_interval.value = '';
for (var i = 0; i < f.elements.length; i++) {
if (f.elements[i].name == 'weekly[]') {
f.elements[i].checked = false;
}
}
}
if (index != 3) f.recur_day_of_month_interval.value = '';
if (index != 4) f.recur_week_of_month_interval.value = '';
if (index != 5) f.recur_yearly_interval.value = '';
}
<?php endif; ?>
function setWholeDay(wholeDay)
{
if (wholeDay == 1) {
<?php if ($GLOBALS['prefs']->getValue('twentyFour')): ?>
$('start_hour').selectedIndex = 0;
<?php else: ?>
$('start_hour').selectedIndex = 11;
$('am').checked = true;
<?php endif; ?>
$('start_min').selectedIndex = 0;
$('dur_day').value = 0;
$('dur_hour').selectedIndex = 23;
$('dur_min').selectedIndex = 12;
}
}
function updateWday(span)
{
<?php if ($GLOBALS['browser']->hasFeature('dom')): ?>
wdays = [
'<?php echo addslashes(_("Sunday")) ?>',
'<?php echo addslashes(_("Monday")) ?>',
'<?php echo addslashes(_("Tuesday")) ?>',
'<?php echo addslashes(_("Wednesday")) ?>',
'<?php echo addslashes(_("Thursday")) ?>',
'<?php echo addslashes(_("Friday")) ?>',
'<?php echo addslashes(_("Saturday")) ?>'
];
if (span == 'start_wday') {
spanObj = $('start_wday');
day = $('start_day').value;
month = $('start_month').value - 1;
year = $('start_year').value;
} else if (span == 'end_wday') {
spanObj = $('end_wday');
day = $('end_day').value;
month = $('end_month').value - 1;
year = $('end_year').value;
<?php if (!Util::nonInputVar('issearch')): ?>
} else if (span == 'recur_end_wday') {
spanObj = $('recur_end_wday');
day = $('recur_enddate_day').value;
month = $('recur_enddate_month').value - 1;
year = $('recur_enddate_year').value;
<?php endif; ?>
}
date = new Date(year, month, day)
spanObj.innerHTML = '(' + wdays[date.getDay()] + ')';
<?php endif; ?>
}
<?php if (!$GLOBALS['prefs']->getValue('twentyFour')): ?>
// Converts a 12 hour based number to its 24 hour format
function convertTo24Hour(in_hour, pm_elementName)
{
if ($F(pm_elementName)) {
if (in_hour != 12) {
in_hour += 12;
}
} else if (in_hour == 12) {
in_hour = 0;
}
return in_hour;
}
<?php endif; ?>
function updateDuration()
{
var startHour = parseInt($F('start_hour'));
var endHour = parseInt($F('end_hour'));
<?php if (!$GLOBALS['prefs']->getValue('twentyFour')): ?>
startHour = convertTo24Hour(startHour, 'pm');
endHour = convertTo24Hour(endHour, 'epm');
<?php endif; ?>
var startDate = Date.UTC($F('start_year'),
$F('start_month') - 1,
$F('start_day'),
startHour,
$F('start_min'));
var endDate = Date.UTC($F('end_year'),
$F('end_month') - 1,
$F('end_day'),
endHour,
$F('end_min'));
var failed = false;
if (endDate < startDate) {
<?php if (!$GLOBALS['prefs']->getValue('twentyFour')): ?>
// If the end hour is marked as the (default) AM, and the
// start hour is also AM, automatically default the end hour
// to PM if the date is otherwise the same - assume that the
// user wants a 9am-2pm event (for example), instead of
// throwing an error.
if ($F('start_year') == $F('end_year') &&
$F('start_month') == $F('end_month') &&
$F('start_day') == $F('end_day') &&
!$F('pm') && !$F('epm')) {
// Toggle the end date to PM.
$('epm').checked = true;
// Recalculate end time.
var endHour = parseInt($F('end_hour'));
endHour = convertTo24Hour(endHour, 'epm');
endDate = Date.UTC($F('end_year'),
$F('end_month') - 1,
$F('end_day'),
endHour,
$F('end_min'));
} else {
<?php endif; ?>
alert('<?php echo addslashes(_("The end date must be later than the start date.")) ?>');
endDate = startDate;
failed = true;
<?php if (!$GLOBALS['prefs']->getValue('twentyFour')): ?>
}
<?php endif; ?>
}
var duration = (endDate - startDate) / 1000;
$('dur_day').value = Math.floor(duration / 86400);
duration %= 86400;
var durHour = Math.floor(duration / 3600);
duration %= 3600;
var durMin = Math.floor(duration / 60 / 5);
$('dur_hour').selectedIndex = durHour;
$('dur_min').selectedIndex = durMin;
$('allday').checked = false;
if (failed) {
updateEndDate();
}
}
function updateEndDate()
{
var yearDiff = <?php echo date('Y') - 1 ?>;
var startHour = parseInt($F('start_hour'));
<?php if (!$GLOBALS['prefs']->getValue('twentyFour')): ?>
startHour = convertTo24Hour(startHour, 'pm');
<?php endif; ?>
var startDate = new Date($F('start_year'),
$F('start_month') - 1,
$F('start_day'),
startHour,
$F('start_min'));
var endDate = new Date();
var minutes = $F('dur_day') * 1440;
minutes += $F('dur_hour') * 60;
minutes += parseInt($F('dur_min'));
var msecs = minutes * 60000;
endDate.setTime(startDate.getTime() + msecs);
var endYear = endDate.getYear();
if (endYear < 1900) {
endYear += 1900;
}
$('end_year').value = endYear;
$('end_month').selectedIndex = endDate.getMonth();
$('end_day').selectedIndex = endDate.getDate() - 1;
var endHour = endDate.getHours()
<?php if (!$GLOBALS['prefs']->getValue('twentyFour')): ?>
if (endHour < 12) {
if (endHour == 0) {
endHour = 12;
}
$('eam').checked = true;
} else {
if (endHour > 12) {
endHour -= 12;
}
$('epm').checked = true;
}
endHour -= 1;
<?php endif; ?>
$('end_hour').selectedIndex = endHour;
$('end_min').selectedIndex = endDate.getMinutes() / 5;
updateWday('end_wday');
}
function setStartDate(date)
{
var startDate = new Date();
startDate.setTime(date * 1000);
var startYear = startDate.getYear();
if (startYear < 1900) {
startYear += 1900;
}
$('start_year').value = startYear;
$('start_month').selectedIndex = startDate.getMonth();
$('start_day').selectedIndex = startDate.getDate() - 1;
updateEndDate();
// Uncheck recurring weekdays.
$('mo').checked = false;
$('tu').checked = false;
$('we').checked = false;
$('th').checked = false;
$('fr').checked = false;
$('sa').checked = false;
$('su').checked = false;
}
<?php if (Util::getFormData('allday') == 1): ?>
Event.observe(window, 'load', function() {
$('allday').click;
});
<?php endif; ?>
function toggleSection(section)
{
var dir = '<?php echo $GLOBALS['registry']->getImageDir() ?>';
$('section_' + section).toggle();
if ($('section_' + section).visible()) {
$('toggle_' + section).src = dir + '/minus.png';
$('toggle_' + section).alt = '<?php addslashes(_("Hide")) ?>';
if ($('extra_' + section)) {
$('extra_' + section).hide();
}
} else {
$('toggle_' + section).src = dir + '/plus.png';
$('toggle_' + section).alt = '<?php addslashes(_("Show")) ?>';
if ($('extra_' + section)) {
$('extra_' + section).show();
}
}
}
Event.observe(window, 'load', function() {
toggleSection('description');
toggleSection('attendees');
toggleSection('recurrence');
<?php if ($GLOBALS['conf']['metadata']['keywords']): ?>
toggleSection('keywords');
<?php endif; ?>
});
</script>
|