$(id).update();
$H(Kronolith.conf.calendars.internal).each(function(cal) {
if (cal.value.edit) {
- $(id).insert(new Element('OPTION', { 'value': cal.key })
+ $(id).insert(new Element('OPTION', { 'value': 'internal|' + cal.key })
.setStyle({ 'backgroundColor': cal.value.bg, 'color': cal.value.fg })
.update(cal.value.name.escapeHTML()));
}
return;
case 'kronolithEventAllday':
- $('kronolithEventStartTimeLabel').setStyle({ 'visibility': $('kronolithEventStartTimeLabel').getStyle('visibility') == 'visible' ? 'hidden' : 'visible' });
- $('kronolithEventEndTimeLabel').setStyle({ 'visibility': $('kronolithEventEndTimeLabel').getStyle('visibility') == 'visible' ? 'hidden' : 'visible' });
+ this.toggleAllDay();
return;
case 'kronolithEventLinkDescription':
case 'kronolithEventLinkMonthly':
case 'kronolithEventLinkYearly':
case 'kronolithEventLinkLength':
- $('kronolithEventTabRecur').select('DIV').invoke('hide');
- if (id != 'kronolithEventLinkNone') {
- $(id.replace(/Link/, 'Repeat')).show();
- $('kronolithEventRepeatLength').show();
- }
+ this.toggleRecurrence(id.substring(18));
return;
case 'kronolithEventSave':
RedBox.onDisplay = null;
};
- this.updateCalendarDropDown('kronolithEventCalendars');
+ this.updateCalendarDropDown('kronolithEventCalendar');
$('kronolithEventTags').autocompleter.init();
$('kronolithEventForm').enable();
$('kronolithEventForm').reset();
return;
}
- $('kronolithEventId').value = ev.id;
- $('kronolithEventCalendar').value = ev.ty + '|' + ev.c;
- $('kronolithEventTitle').value = ev.t;
- $('kronolithEventLocation').value = ev.l;
- $('kronolithEventAllday').checked = ev.al;
- $('kronolithEventStartDate').value = ev.sd
- $('kronolithEventStartTime').value = ev.st;
- $('kronolithEventEndDate').value = ev.ed;
- $('kronolithEventEndTime').value = ev.et;
- $('kronolithEventTags').autocompleter.init(ev.tg);
+ /* Basic information */
+ $('kronolithEventId').setValue(ev.id);
+ $('kronolithEventCalendar').setValue(ev.ty + '|' + ev.c);
+ $('kronolithEventTitle').setValue(ev.t);
+ $('kronolithEventLocation').setValue(ev.l);
+ $('kronolithEventAllday').setValue(ev.al);
+ this.toggleAllDay(ev.al);
+ $('kronolithEventStartDate').setValue(ev.sd);
+ $('kronolithEventStartTime').setValue(ev.st);
+ $('kronolithEventEndDate').setValue(ev.ed);
+ $('kronolithEventEndTime').setValue(ev.et);
+ $('kronolithEventDescription').setValue(ev.d);
+
+ /* Alarm */
+ if (ev.a) {
+ $('kronolithEventAlarmOn').setValue(true);
+ [10080, 1440, 60, 1].each(function(unit) {
+ if (ev.a % unit == 0) {
+ $('kronolithEventAlarmValue').setValue(ev.a / unit);
+ $('kronolithEventAlarmUnit').setValue(unit);
+ throw $break;
+ }
+ });
+ } else {
+ $('kronolithEventAlarmOff').setValue(true);
+ }
+
+ /* Recurrence */
if (ev.r) {
- // @todo: refine
- $A($('kronolithEventRecurrence').options).find(function(option) {
- return option.value == ev.r || option.value == -1;
- }).selected = true;
+ var scheme = Kronolith.conf.recur[ev.r.t],
+ div = $('kronolithEventRepeat' + scheme);
+ $('kronolithEventLink' + scheme).setValue(true);
+ this.toggleRecurrence(scheme);
+ if (scheme == 'Monthly' || scheme == 'Yearly') {
+ div.down('input[name=recur_' + scheme.toLowerCase() + '_scheme][value=' + ev.r.t + ']').setValue(true);
+ }
+ if (scheme == 'Weekly') {
+ div.select('input[type=checkbox]').each(function(input) {
+ if (input.name == 'weekly[]' &&
+ input.value & ev.r.d) {
+ input.setValue(true);
+ }
+ });
+ }
+ if (ev.r.i == 1) {
+ div.down('input[name=recur_' + scheme.toLowerCase() + '][value=1]').setValue(true);
+ } else {
+ div.down('input[name=recur_' + scheme.toLowerCase() + '][value=0]').setValue(true);
+ div.down('input[name=recur_' + scheme.toLowerCase() + '_interval]').setValue(ev.r.i);
+ }
+ if (!Object.isUndefined(ev.r.e)) {
+ $('kronolithEventRepeatLength').down('input[name=recur_enddate_type][value=date]').setValue(true);
+ $('kronolithEventRecurDate').setValue(Date.parse(ev.r.e).toString(Kronolith.conf.date_format));
+ } else if (!Object.isUndefined(ev.r.c)) {
+ $('kronolithEventRepeatLength').down('input[name=recur_enddate_type][value=count]').setValue(true);
+ $('kronolithEventRecurCount').setValue(ev.r.c);
+ } else {
+ $('kronolithEventRepeatLength').down('input[name=recur_enddate_type][value=none]').setValue(true);
+ }
+ }
+
+ /* Attendees */
+ if (!Object.isUndefined(ev.at)) {
+ $('kronolithEventAttendees').setValue(ev.at.pluck('l').join(', '));
+ var table = $('kronolithEventTabAttendees').down('tbody');
+ ev.at.each(function(attendee) {
+ var tr = new Element('tr'), i;
+ tr.insert(new Element('td').writeAttribute('title', attendee.l).insert(attendee.e.escapeHTML()));
+ for (i = 0; i < 24; i++) {
+ tr.insert(new Element('td'));
+ }
+ table.insert(tr);
+ });
}
+
+ /* Tags */
+ $('kronolithEventTags').autocompleter.init(ev.tg);
+
if (ev.pe) {
$('kronolithEventSave').show();
$('kronolithEventForm').enable();
this.eventForm = RedBox.getWindowContents();
},
+ /**
+ * Toggles the start and end time fields of the event edit form on and off.
+ *
+ * @param boolean on Whether the event is an all-day event, i.e. the time
+ * fields should be turned off. If not specified, the
+ * current state is toggled.
+ */
+ toggleAllDay: function(on)
+ {
+ if (Object.isUndefined(on)) {
+ on = $('kronolithEventStartTimeLabel').getStyle('visibility') == 'visible';
+ }
+ $('kronolithEventStartTimeLabel').setStyle({ 'visibility': on ? 'hidden' : 'visible' });
+ $('kronolithEventEndTimeLabel').setStyle({ 'visibility': on ? 'hidden' : 'visible' });
+ },
+
+ /**
+ * Toggles the recurrence fields of the event edit form.
+ *
+ * @param string recur The recurrence part of the field name, i.e. 'None',
+ * 'Daily', etc.
+ */
+ toggleRecurrence: function(recur)
+ {
+ $('kronolithEventTabRecur').select('div').invoke('hide');
+ if (recur != 'None') {
+ $('kronolithEventRepeat' + recur).show();
+ $('kronolithEventRepeatLength').show();
+ }
+ },
+
_closeRedBox: function()
{
RedBox.close();
*
* Possible properties are:
* - t: title
+ * - d: description
* - c: calendar id
* - s: start date
* - e: end date
* - fg: foreground color
* - pe: edit permissions?
* - pd: delete permissions?
- * - a: alarm text
- * - r: recurrence type (Horde_Date_Recurrence::RECUR_* constant)
+ * - a: alarm text or minutes
+ * - r: recurrence type (Horde_Date_Recurrence::RECUR_* constant) or json
+ * representation of Horde_Date_Recurrence object.
* - ic: icon
* - ln: link
* - aj: ajax link
* - st: formatted start time
* - ed: formatted end date
* - et: formatted end time
+ * - at: attendees
* - tg: tag list
*
* @param boolean $allDay If not null, overrides whether the event is
if ($full) {
$json->id = $this->getId();
$json->ty = $this->_calendarType;
+ $json->d = $this->getDescription();
$json->l = $this->getLocation();
$json->sd = $this->start->strftime('%x');
$json->st = $this->start->format($time_format);
$json->ed = $this->end->strftime('%x');
$json->et = $this->end->format($time_format);
+ $json->a = $this->alarm;
$json->tg = array_values($this->tags);
+ if ($this->recurs()) {
+ $json->r = $this->recurrence->toJson();
+ }
+ if ($this->attendees) {
+ $attendees = array();
+ foreach ($this->attendees as $email => $info) {
+ $attendees[] = array('e' => $email,
+ 'l' => empty($info['name']) ? $email : ($info['name'] . ' <' . $email . '>'),
+ 'a' => $info['attendance'],
+ 'r' => $info['response']);
+ }
+ $json->at = $attendees;
+ }
}
return $json;
'confirmed' => self::STATUS_CONFIRMED,
'cancelled' => self::STATUS_CANCELLED,
'free' => self::STATUS_FREE),
+ 'recur' => array(Horde_Date_Recurrence::RECUR_NONE => 'None',
+ Horde_Date_Recurrence::RECUR_DAILY => 'Daily',
+ Horde_Date_Recurrence::RECUR_WEEKLY => 'Weekly',
+ Horde_Date_Recurrence::RECUR_MONTHLY_DATE => 'Monthly',
+ Horde_Date_Recurrence::RECUR_MONTHLY_WEEKDAY => 'Monthly',
+ Horde_Date_Recurrence::RECUR_YEARLY_DATE => 'Yearly',
+ Horde_Date_Recurrence::RECUR_YEARLY_DAY => 'Yearly',
+ Horde_Date_Recurrence::RECUR_YEARLY_WEEKDAY => 'Yearly'),
// Turn debugging on?
'debug' => !empty($conf['js']['debug']),
);
<div id="kronolithEventDialog" style="display:none">
<form id="kronolithEventForm" action="">
-<input id="kronolithEventCalendar" type="hidden" name="cal" />
<input id="kronolithEventId" type="hidden" name="id" />
<div>
<table cellspacing="0" cellpadding="0" border="0"><tbody><tr>
<td>
- <label for="kronolithEventCalendars"><?php echo _("Calendar") ?>:</label><br />
- <select name="targetcalendar" id="kronolithEventCalendars">
+ <label for="kronolithEventCalendar"><?php echo _("Calendar") ?>:</label><br />
+ <select name="cal" id="kronolithEventCalendar">
</select>
</td>
<td>
</div>
<div id="kronolithEventTabReminder" class="kronolithTabsOption" style="display:none">
- <label><input type="radio" name="alarm" value="0" checked="checked" /> <?php echo _("don't set") ?></label>
+ <label><input type="radio" name="alarm" id="kronolithEventAlarmOff" value="0" checked="checked" /> <?php echo _("don't set") ?></label>
<?php echo _("or") ?>
- <label><input type="radio" name="alarm" value="1" /> <?php echo _("set") ?></label>
+ <label><input type="radio" name="alarm" id="kronolithEventAlarmOn" value="1" /> <?php echo _("set") ?></label>
+ <input type="text" name="alarm_value" id="kronolithEventAlarmValue" size="2" value="15" class="kronolithEventValue" />
<label>
- <input type="text" name="alarm_value" size="2" value="15" class="kronolithEventValue" />
- <select name="alarm_unit">
+ <select name="alarm_unit" id="kronolithEventAlarmUnit">
<option value="1"><?php echo _("minutes") ?></option>
<option value="60"><?php echo _("hours") ?></option>
<option value="1440"><?php echo _("days") ?></option>
<?php echo _("Repeat") ?>
<label><input type="radio" name="recur_monthly" value="1" checked="checked" /> <?php echo _("every month") ?></label>
<?php echo _("or") ?>
- <label><input type="radio" name="recur_monthly" value="1" /> <?php echo _("every") ?></label>
+ <label><input type="radio" name="recur_monthly" value="0" /> <?php echo _("every") ?></label>
<label><input type="text" size="3" name="recur_monthly_interval" value="" class="kronolithEventValue" /> <?php echo _("months") ?></label>,
<?php echo _("on the same") ?>
- <label><input type="radio" name="recur_monthly_weekday" value="0" /> <?php echo _("date") ?></label>
- <label><input type="radio" name="recur_monthly_weekday" value="1" /> <?php echo _("weekday") ?></label>
+ <label><input type="radio" name="recur_monthly_scheme" value="<?php echo Horde_Date_Recurrence::RECUR_MONTHLY_DATE ?>" /> <?php echo _("date") ?></label>
+ <label><input type="radio" name="recur_monthly_scheme" value="<?php echo Horde_Date_Recurrence::RECUR_MONTHLY_WEEKDAY ?>" /> <?php echo _("weekday") ?></label>
</div>
<div id="kronolithEventRepeatYearly" style="display:none">
<?php echo _("Repeat") ?>
<label><input type="radio" name="recur_yearly" value="1" checked="checked" /> <?php echo _("every year") ?></label>
<?php echo _("or") ?>
- <label><input type="radio" name="recur_yearly" value="1" /> <?php echo _("every") ?></label>
+ <label><input type="radio" name="recur_yearly" value="0" /> <?php echo _("every") ?></label>
<label><input type="text" size="3" name="recur_yearly_interval" value="" class="kronolithEventValue" /> <?php echo _("years") ?></label>
<?php echo _("on the same") ?>
- <label><input type="radio" name="recur_yearly_weekday" value="0" /> <?php echo _("day of the year") ?></label>
- <label><input type="radio" name="recur_yearly_weekday" value="1" /> <?php echo _("month and weekday") ?></label>
+ <label><input type="radio" name="recur_yearly_scheme" value="<?php echo Horde_Date_Recurrence::RECUR_YEARLY_DATE ?>" /> <?php echo _("date of the year") ?></label>
+ <label><input type="radio" name="recur_yearly_scheme" value="<?php echo Horde_Date_Recurrence::RECUR_YEARLY_DAY ?>" /> <?php echo _("day of the year") ?></label>
+ <label><input type="radio" name="recur_yearly_scheme" value="<?php echo Horde_Date_Recurrence::RECUR_YEARLY_WEEKDAY ?>" /> <?php echo _("month and weekday") ?></label>
</div>
<div id="kronolithEventRepeatLength" style="display:none">
<?php echo _("Stop") ?>
<input type="text" name="recur_end_date" id="kronolithEventRecurDate" size="10" class="kronolithDatePicker" />
<?php echo _(", or") ?>
<label><input type="radio" name="recur_enddate_type" value="count" /> <?php echo _("after") ?></label>
- <label><input type="text" name="recur_count" value="" size="2" class="kronolithEventValue" /> <?php echo _("recurrences") ?></label>
+ <label><input type="text" name="recur_count" id="kronolithEventRecurCount" value="" size="2" class="kronolithEventValue" /> <?php echo _("recurrences") ?></label>
<br />
</div>
</div>
<input type="text" name="url" id="kronolithEventUrl" class="kronolithLongField" value="http://" />
</div>
-<?php $part = array('john@exmple.com', 'jane@example.com'); ?>
<div id="kronolithEventTabAttendees" class="kronolithTabsOption" style="display:none">
- <input type="text" name="participants" id="eventParticipants" class="kronolithLongField" value="<?php echo implode(', ', $part) ?>" /><br />
+ <input type="text" name="participants" id="kronolithEventAttendees" class="kronolithLongField" value="" /><br />
<label><input type="checkbox" name="sendupdates" value="" /> <?php echo _("send invites") ?></label> <?php echo _("to all attendees") ?><br />
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<thead>
</tr>
</thead>
<tbody>
- <?php foreach ($part as $p): ?>
- <tr>
- <td title="<?php echo $p ?>"><?php echo $p ?></td>
- <?php for ($i = 0; $i < 24; $i++): ?>
- <td></td>
- <?php endfor; ?>
- </tr>
- <?php endforeach; ?>
</tbody>
</table>
</div>