break;
}
$result = new stdClass;
- $result->event = $event;
+ $result->event = $event->toJSON(true, $prefs->getValue('twentyFour') ? 'H:i' : 'h:i A');
break;
case 'UpdateEvent':
editEvent: function(calendar, id)
{
- RedBox.loading();
- this.doAction('GetEvent', { 'cal': calendar, 'id': id }, this._editEvent.bind(this));
+ RedBox.onDisplay = function() {
+ $('kronolithEventForm').focusFirstElement();
+ RedBox.onDisplay = null;
+ };
+
+ if (id) {
+ RedBox.loading();
+ this.doAction('GetEvent', { 'cal': calendar, 'id': id }, this._editEvent.bind(this));
+ } else {
+ var d = new Date();
+ $('kronolithEventForm').reset();
+ $('kronolithEventDelete').hide();
+ $('kronolithEventStartDate').value = d.toString(Kronolith.conf.date_format);
+ $('kronolithEventStartTime').value = d.toString(Kronolith.conf.time_format);
+ d.add(1).hour();
+ $('kronolithEventEndDate').value = d.toString(Kronolith.conf.date_format);
+ $('kronolithEventEndTime').value = d.toString(Kronolith.conf.time_format);
+ RedBox.showHtml($('kronolithEventDialog').show());
+ this.eventForm = RedBox.getWindowContents();
+ }
},
/**
return;
}
- var ev = r.response.event;
- $('id_ttl').value = ev.title;
- $('id_local').value = ev.location;
- $('id_fullday').checked = ev.allday;
- $('id_from').value = ev.start._year + '-' + ev.start._month + '-' + ev.start._mday;
- $('tobechanged').from_Hi.value = ev.start._hour + ':' + ev.start._min;
- $('id_to').value = ev.end._year + '-' + ev.end._month + '-' + ev.end._mday;
- $('tobechanged').to_Hi.value = ev.end._hour + ':' + ev.end._min;
- $('id_tags').value = ev.tags.join(', ');
-
- RedBox.showHtml($('kronolithEventForm').show());
+ try {
+ var ev = r.response.event;
+ $('kronolithEventTitle').value = ev.t;
+ $('kronolithEventLocation').value = ev.l;
+ $('kronolithEventAllday').checked = ev.a;
+ $('kronolithEventStartDate').value = ev.sd
+ $('kronolithEventStartTime').value = ev.st;
+ $('kronolithEventEndDate').value = ev.ed;
+ $('kronolithEventEndTime').value = ev.et;
+ $('kronolithEventTags').value = ev.tg.join(', ');
+ if (ev.r) {
+ // @todo: refine
+ $A($('kronolithEventRecurrence').options).find(function(option) {
+ return option.value == ev.r;
+ }).selected = true;
+ }
+ if (ev.e) {
+ $('kronolithEventSave').show();
+ } else {
+ $('kronolithEventSave').hide();
+ }
+ if (ev.d) {
+ $('kronolithEventDelete').show();
+ } else {
+ $('kronolithEventDelete').hide();
+ }
+ } catch (e) {}
+
+ RedBox.showHtml($('kronolithEventDialog').show());
this.eventForm = RedBox.getWindowContents();
},
* Returns a simple object suitable for json transport representing this
* event.
*
+ * @param boolean $full Whether to return all event details.
+ * @param string $time_format The date() format to use for time formatting.
+ *
* @return object A simple object.
*/
- public function toJSON()
+ public function toJSON($full = false, $time_format = 'H:i')
{
$json = new stdClass;
$json->t = $this->getTitle();
$json->bg = $this->_backgroundColor;
$json->fg = $this->_foregroundColor;
$json->e = $this->hasPermission(PERMS_EDIT);
+ $json->d = $this->hasPermission(PERMS_DELETE);
+
+ if ($full) {
+ $json->l = $this->getLocation();
+ $json->a = $this->isAllDay();
+ $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->tg = array_values($this->tags);
+ if ($this->recurs()) {
+ $json->r = $this->recurrence->getRecurType();
+ }
+ }
+
return $json;
}
'is_ie6' => ($browser->isBrowser('msie') && ($browser->getMajor() < 7)),
'login_view' => $prefs->getValue('defaultview'),
'week_start' => (int)$prefs->getValue('week_start_monday'),
+ 'date_format' => str_replace(array('%e', '%d', '%a', '%A', '%m', '%h', '%b', '%B', '%y', '%Y'),
+ array('d', 'dd', 'ddd', 'dddd', 'MM', 'MMM', 'MMM', 'MMMM', 'yy', 'yyyy'),
+ NLS::getLangInfo(D_FMT)),
+ 'time_format' => $prefs->getValue('twentyFour') ? 'HH:mm' : 'hh:mm tt',
// Turn debugging on?
'debug' => !empty($conf['js']['debug']),
);
<!-- end menu -->
<!-- ini edit -->
-<div id="kronolithEventForm" style="display:none"><form id="tobechanged" action="#" method="post">
+<div id="kronolithEventDialog" style="display:none"><form id="kronolithEventForm">
<div>
- <label for="id_ttl"><?php echo _("Title") ?></label><br />
- <input type="text" name="ttl" id="id_ttl" class="kronolithLongField" />
+ <label for="kronolithEventTitle"><?php echo _("Title") ?></label><br />
+ <input type="text" name="title" id="kronolithEventTitle" class="kronolithLongField" />
</div>
<table cellspacing="2" cellpadding="0" border="0"><tbody>
<tr>
<td class="rightAlign">
- <label for="id_local"><?php echo _("Location") ?></label><br />
+ <label for="kronolithEventLocation"><?php echo _("Location") ?></label><br />
<small><a href="#"><?php echo _("Geolocation") ?></a></small>
</td>
- <td><input type="text" name="local" id="id_local" value="Porto, Portugal" class="kronolithLongField" /></td>
+ <td><input type="text" name="location" id="kronolithEventLocation" class="kronolithLongField" /></td>
</tr>
<tr>
- <td class="rightAlign"><label for="id_fullday"><?php echo _("All-day") ?></label></td>
- <td><input type="checkbox" name="fullday" id="id_fullday" /></td>
+ <td class="rightAlign"><label for="kronolithEventAllday"><?php echo _("All-day") ?></label></td>
+ <td><input type="checkbox" name="whole_day" id="kronolithEventAllday" /></td>
</tr>
<tr>
- <td class="rightAlign"><label for="id_from"><?php echo _("From") ?></label></td>
+ <td class="rightAlign"><label for="kronolithEventStartDate"><?php echo _("From") ?></label></td>
<td>
- <input type="text" name="from_ymd" id="id_from" value="2006-10-30" size="9" class="kronolithDatePicker" />
+ <input type="text" name="start_date" id="kronolithEventStartDate" size="9" class="kronolithDatePicker" />
<?php echo _("at") ?>
- <input type="text" name="from_Hi" value="10:30" size="4" />
+ <input type="text" name="start_time" id="kronolithEventStartTime" size="6" />
</td>
</tr>
<td class="rightAlign">
<label for="id_to"><?php echo _("To") ?></label></td>
<td>
- <input type="text" name="to_ymd" id="id_to" value="2006-10-30" size="9" class="kronolithDatePicker" />
+ <input type="text" name="end_date" id="kronolithEventEndDate" size="9" class="kronolithDatePicker" />
<?php echo _("at") ?>
- <input type="text" name="to_Hi" value="10:30" size="4" />
+ <input type="text" name="end_time" id="kronolithEventEndTime" size="6" />
</td>
</tr>
<tr>
- <td class="rightAlign"><label for="id_recur"><?php echo _("Repeat") ?></label></td>
- <td><select name="recur" id="id_recur" class="kronolithLongField">
+ <td class="rightAlign"><label for="kronolithEventRecurrence"><?php echo _("Repeat") ?></label></td>
+ <td><select name="recur" id="kronolithEventRecurrence" class="kronolithLongField">
<option value="0"><?php echo _("no repeat") ?></option>
<option value="1"><?php echo _("Every day") ?></option>
<option value="2"><?php echo _("Every week") ?></option>
- <option value="3"><?php echo _("Every 15 days") ?></option>
- <option value="4" selected><?php echo _("Every year") ?></option>
- <option value="5"><?php echo _("Custom...") ?></option>
+ <option value=""><?php echo _("Every 14 days") ?></option>
+ <option value="3"><?php echo _("Every month") ?></option>
+ <option value="5"><?php echo _("Every year") ?></option>
+ <option value="-1"><?php echo _("Custom...") ?></option>
</select></td>
</tr>
</tbody></table>
<div>
<label for="id_url"><?php echo _("URL") ?></label><br />
- <input type="text" name="url" id="id_url" class="kronolithLongField" />
+ <input type="text" name="url" id="kronolithEventUrl" class="kronolithLongField" />
</div>
<div>
<label for="id_tags"><?php echo _("Tags") ?></label><br />
- <textarea name="tags" id="id_tags" rows="2" class="kronolithLongField"></textarea>
+ <textarea name="tags" id="kronolithEventTags" rows="2" class="kronolithLongField"></textarea>
</div>
<div class="kronolithTags">
</div>
<div id="kronolithEventActions">
- <input type="button" value="<?php echo _("Save") ?>" class="button ok" />
- <input type="button" value="<?php echo _("Delete") ?>" class="button ko" />
+ <input id="kronolithEventSave" type="button" value="<?php echo _("Save") ?>" class="button ok" />
+ <input id="kronolithEventDelete" type="button" value="<?php echo _("Delete") ?>" class="button ko" />
<input type="button" value="<?php echo _("Cancel") ?>" class="button cancel" />
<span id="kronolithEventAdvancedLink">| <a href="#"><?php echo _("Advanced") ?></a></span><br />
</div>
}
/* Event form dialog */
-#kronolithEventForm {
+#kronolithEventDialog {
width: 400px;
padding: 10px 20px;
background: #efefef;
border: 1px #c0c0c0 solid;
}
-#kronolithEventForm div {
+#kronolithEventDialog div {
margin-bottom: 5px;
}
#kronolithEventForm label {