this.alarms.push(alarm.id);
- message = alarm.title.escapeHTML();
+ var message = alarm.title.escapeHTML();
if (alarm.params && alarm.params.notify) {
if (alarm.params.notify.ajax) {
message = new Element('a')
.insert(message)
- .observe('click', function() {
- this.Growler.ungrowl(growl);
+ .observe('click', function(e) {
+ this.Growler.ungrowl(e.findElement('div'));
this.go(alarm.params.notify.ajax);
- }.bind(this));
+ }.bindAsEventListener(this));
} else if (alarm.params.notify.url) {
message = new Element('a', { href: alarm.params.notify.url })
.insert(message);
$('kronolithLoading').hide();
}
if (r.response.view != 'search' ||
- r.response.query != this.eventsLoading['search']) {
+ r.response.query != this.eventsLoading.search) {
return;
}
if (Object.isUndefined(r.response.events)) {
$('kronolithAgendaNoItems').show();
return;
}
- delete this.eventsLoading['search'];
+ delete this.eventsLoading.search;
$H(r.response.events).each(function(calendars) {
$H(calendars.value).each(function(events) {
this.createAgendaDay(events.key);
case 'month':
var tbody = $('kronolithViewMonthBody'),
dates = this.viewDates(date, view),
- day = dates[0].clone(), row;
+ day = dates[0].clone();
$('kronolithViewMonth')
.down('caption span')
// Agenda days are only created on demand, if there are any events
// to add.
if (view == 'agenda') {
- var dates = this.viewDates(date, view),
- day = dates[0].clone();
+ var dates = this.viewDates(date, view);
$('kronolithAgendaDate')
.update(this.setTitle(Kronolith.text.agenda + ' ' + dates[0].toString('d') + ' - ' + dates[1].toString('d')));
$('kronolithAgendaNavigation').show();
createWeekRow: function(date, month, viewDates)
{
var day = date.clone(), today = new Date().dateString(),
- start = viewDates[0].dateString(), end = viewDates[1].dateString(),
row, cell, dateString;
// Create a copy of the row template.
var table = $('kronolithYearTemplate').cloneNode(true),
tbody = table.down('tbody');
table.removeAttribute('id');
- tbody.writeAttribute('id', 'kronolithYearTable' + month)
+ tbody.writeAttribute('id', 'kronolithYearTable' + month);
// Set month name.
table.down('span')
// FIXME: spacing is hardcoded for IE 7 because it doesn't know about
// border-spacing, but still uses it. WTF?
- spacing = spacing ? parseInt($w(spacing)[1]) : 2;
+ spacing = spacing ? parseInt($w(spacing)[1], 10) : 2;
this[storage] = {};
this[storage].height = layout.get('margin-box-height') + spacing;
this[storage].spacing = this[storage].height - layout.get('padding-box-height');
{
var dates = this.viewDates(date, 'month'), day = dates[0].clone(),
date7 = date.clone().add(1).week(), today = Date.today(),
- weekStart, weekEnd, weekEndDay, dateString, td, tr, i;
+ weekStart, weekEnd, dateString, td, tr, i;
// Remove old calendar rows. Maybe we should only rebuild the minical
// if necessary.
calendars.each(function(cal) {
var startDay = firstDay.clone(), endDay = lastDay.clone(),
- cals = this.ecache.get(cal[0]),
- events, date;
+ cals = this.ecache.get(cal[0]);
if (typeof cals != 'undefined' &&
typeof cals.get(cal[1]) != 'undefined') {
break;
}
- var day = dates[0].clone(), date, more;
+ var day = dates[0].clone(), date, more, title, busy;
while (!day.isAfter(dates[1])) {
date = day.dateString();
switch (view) {
break;
case 'year':
- td = $('kronolithYear' + date);
+ var td = $('kronolithYear' + date);
if (td.className == 'kronolithMinicalEmpty') {
continue;
}
var calendar = event.value.calendar.split('|');
event.value.nodeId = 'kronolithEvent' + view + event.value.calendar + date + event.key;
- _createElement = function(event) {
+ var _createElement = function(event) {
var className ='kronolithEvent';
switch (event.value.x) {
case 3:
if (event.value.pe) {
div.addClassName('kronolithEditable');
var layout = div.getLayout(),
- minLeft = $('kronolithViewWeekHead').down('.kronolithFirstCol').getWidth() + this[storage].spacing + (parseInt(div.getStyle('marginLeft')) || 0),
- minTop = $('kronolithViewWeekHead').down('thead').getHeight() + this[storage].spacing + (parseInt(div.getStyle('marginTop')) || 0),
+ minLeft = $('kronolithViewWeekHead').down('.kronolithFirstCol').getWidth() + this[storage].spacing + (parseInt(div.getStyle('marginLeft'), 10) || 0),
+ minTop = $('kronolithViewWeekHead').down('thead').getHeight() + this[storage].spacing + (parseInt(div.getStyle('marginTop'), 10) || 0),
maxLeft = $('kronolithViewWeekHead').getWidth() - layout.get('margin-box-width'),
maxTop = $('kronolithViewWeekHead').down('thead').getHeight() + $('kronolithViewWeekHead').down('.kronolithAllDay').getHeight(),
opts = {
var midnight = this.parseDate(date),
resizable = event.value.pe && (Object.isUndefined(event.value.vl) || event.value.vl),
innerDiv = new Element('div', { className: 'kronolithEventInfo' }),
- minHeight = 0, height,
+ minHeight = 0,
draggerTop, draggerBottom;
if (event.value.fi) {
if (resizable) {
minHeight += draggerBottom.getHeight();
}
if (!minHeight) {
- minHeight = parseInt(innerDiv.getStyle('lineHeight'))
- + (parseInt(innerDiv.getStyle('paddingTop')) || 0)
- + (parseInt(innerDiv.getStyle('paddingBottom')) || 0);
+ minHeight = parseInt(innerDiv.getStyle('lineHeight'), 10)
+ + (parseInt(innerDiv.getStyle('paddingTop'), 10) || 0)
+ + (parseInt(innerDiv.getStyle('paddingBottom'), 10) || 0);
}
div.setStyle({ height: Math.max(Math.round(event.value.start.getElapsed(event.value.end) / 60000) * this[storage].height / 60 - this[storage].spacing | 0, minHeight) + 'px' });
if (event.value.pe) {
div.addClassName('kronolithEditable');
// Number of pixels that cover 10 minutes.
- var step = this[storage].height / 6;
+ var step = this[storage].height / 6,
+ stepX, minLeft, maxLeft, maxTop,
+ minBottom, maxBottom, dragBottomHeight;
if (draggerBottom) {
// Height of bottom dragger
- var dragBottomHeight = draggerBottom.getHeight();
+ dragBottomHeight = draggerBottom.getHeight();
}
- // Top position of the whole event div
- var eventTop = div.cumulativeOffset().top;
if (draggerTop) {
// Bottom-most position (maximum y) of top dragger
- var maxTop = div.offsetTop
+ maxTop = div.offsetTop
- draggerTop.getHeight()
- - parseInt(innerDiv.getStyle('lineHeight'));
+ - parseInt(innerDiv.getStyle('lineHeight'), 10);
if (draggerBottom) {
maxTop += draggerBottom.offsetTop;
}
if (draggerBottom) {
// Top-most position (minimum y) of bottom dragger (upper
// edge)
- var minBottom = div.offsetTop
- + parseInt(innerDiv.getStyle('lineHeight')),
+ minBottom = div.offsetTop
+ + parseInt(innerDiv.getStyle('lineHeight'), 10);
// Bottom-most position (maximum y) of bottom dragger
// (upper edge)
maxBottom = 24 * this[storage].height
}
if (view == 'week') {
- var dates = this.viewDates(midnight, view),
- minLeft = $('kronolithEventsWeek' + dates[0].dateString()).offsetLeft - $('kronolithEventsWeek' + date).offsetLeft,
- maxLeft = $('kronolithEventsWeek' + dates[1].dateString()).offsetLeft - $('kronolithEventsWeek' + date).offsetLeft,
- stepX = (maxLeft - minLeft) / 6;
+ var dates = this.viewDates(midnight, view);
+ minLeft = $('kronolithEventsWeek' + dates[0].dateString()).offsetLeft - $('kronolithEventsWeek' + date).offsetLeft;
+ maxLeft = $('kronolithEventsWeek' + dates[1].dateString()).offsetLeft - $('kronolithEventsWeek' + date).offsetLeft;
+ stepX = (maxLeft - minLeft) / 6;
}
var d = new Drag(div, {
threshold: 5,
placeFound = false,
// The minimum (virtual) duration of each event, defined by the
// minimum height of an event DIV.
- minMinutes = (minHeight + this[storage].spacing) * 60 / this[storage].height,
- // The minimum (virtual) end of an event, defined by its start
- // time an minMinutes.
- minEnd;
+ minMinutes = (minHeight + this[storage].spacing) * 60 / this[storage].height;
// this.dayEvents contains all events of the current day.
// this.dayGroups contains conflict groups, i.e. all events that
this.dayEvents.each(function(ev) {
// Due to the minimum height of an event DIV, events might
// visually overlap, even if they physically don't.
- minEnd = ev.start.clone().add(minMinutes).minutes();
- end = ev.end.isAfter(minEnd) ? ev.end : minEnd;
+ var minEnd = ev.start.clone().add(minMinutes).minutes(),
+ end = ev.end.isAfter(minEnd) ? ev.end : minEnd;
// If it doesn't conflict with the current event, rember it
// as a possible event below that we can put the current event
// and go ahead.
if (!conflict) {
// This is the first conflicting event.
conflict = ev;
- for (i = 0; i < this.dayGroups.length; i++) {
+ for (var i = 0; i < this.dayGroups.length; i++) {
// Find the conflict group of the conflicting event.
if (this.dayGroups[i].indexOf(conflict) != -1) {
// If our possible candidate "above" is a member of
if (conflict) {
// We had a conflict, find the matching conflict group and add
// the current event there.
- for (i = 0; i < this.dayGroups.length; i++) {
+ for (var i = 0; i < this.dayGroups.length; i++) {
if (this.dayGroups[i].indexOf(conflict) != -1) {
pos = i;
break;
break;
case 'month':
dates.each(function(date) {
- day = $('kronolithMonthDay' + date);
+ var day = $('kronolithMonthDay' + date);
day.select('.kronolithEvent').invoke('remove');
day.select('.kronolithMore').invoke('remove');
date = this.parseDate(date);
.insert(new Element('img', { src: Kronolith.conf.images.recur.replace(/fff/, Kronolith.conf.calendars[calendar[0]][calendar[1]].fg.substr(1)), title: Kronolith.text.recur[event.r] }));
} else if (event.bid) {
div.insert(' ')
- .insert(new Element('img', { src: Kronolith.conf.images.exception.replace(/fff/, Kronolith.conf.calendars[calendar[0]][calendar[1]].fg.substr(1)), title: Kronolith.text.recur['Exception'] }));
+ .insert(new Element('img', { src: Kronolith.conf.images.exception.replace(/fff/, Kronolith.conf.calendars[calendar[0]][calendar[1]].fg.substr(1)), title: Kronolith.text.recur.exception }));
}
return div;
},
*/
insertTask: function(task)
{
- var body = $('kronolithViewTasksBody'),
- row = $('kronolithTasksTemplate').cloneNode(true),
- col = row.down(),
- div = col.down();
+ var row = $('kronolithTasksTemplate').cloneNode(true),
+ col = row.down();
row.removeAttribute('id');
row.store('tasklist', task.value.l);
$('kronolithTaskForm').down('.kronolithFormActions .kronolithSeparator').show();
this.updateTasklistDropDown();
this.disableAlarmMethods('Task');
- this.knl['kronolithTaskDueTime'].markSelected();
+ this.knl.kronolithTaskDueTime.markSelected();
if (id) {
RedBox.loading();
this.doAction('getTask', { list: tasklist, id: id }, this.editTaskCallback.bind(this));
if (task.a) {
$('kronolithTaskAlarmOn').setValue(true);
[10080, 1440, 60, 1].each(function(unit) {
- if (task.a % unit == 0) {
+ if (task.a % unit === 0) {
$('kronolithTaskAlarmValue').setValue(task.a / unit);
$('kronolithTaskAlarmUnit').setValue(unit);
throw $break;
if (calendar &&
(Object.isUndefined(Kronolith.conf.calendars[type]) ||
Object.isUndefined(Kronolith.conf.calendars[type][calendar]))) {
- switch (type) {
- case 'remote':
- newCalendar = true;
- break;
- default:
+ if (type != 'remote') {
this.closeRedBox();
this.go(this.lastLocation);
return;
}
+ newCalendar = true;
}
if (newCalendar) {
switch (type) {
i++;
}
$('kronolithCalendar' + type + i).hide();
- $('kronolithCalendar' + type + ++i).show();
+ $('kronolithCalendar' + type + (++i)).show();
if (this.colorPicker) {
this.colorPicker.hide();
}
event.value.start = Date.parse(event.value.s);
event.value.end = Date.parse(event.value.e);
event.value.sort = event.value.start.toString('HHmmss')
- + (240000 - parseInt(event.value.end.toString('HHmmss'))).toPaddedString(6);
+ + (240000 - parseInt(event.value.end.toString('HHmmss'), 10)).toPaddedString(6);
});
// Store events in cache.
break;
case 'kronolithSearchForm':
- this.go('search:' + this.search + ':' + $F('kronolithSearchTerm'))
+ this.go('search:' + this.search + ':' + $F('kronolithSearchTerm'));
e.stop();
break;
var elt = e.element(),
orig = e.element(),
- id, tmp, calendar, calendarClass;
+ id, tmp, calendar;
while (Object.isElement(elt)) {
id = elt.readAttribute('id');
return;
case 'kronolithEventsDay':
- date = this.date.clone();
+ var date = this.date.clone();
date.add(Math.round((e.pointerY() - elt.cumulativeOffset().top) / this.daySizes.height * 2) * 30).minutes();
this.go('event:' + date.toString('yyyyMMddHHmm'));
e.stop();
top = drag.ghost.cumulativeOffset().top,
scrollTop = $(this.view == 'day' ? 'kronolithViewDay' : 'kronolithViewWeek').down('.kronolithViewBody').scrollTop,
offset = 0,
- height, dates;
+ height;
// Check if view has scrolled since last call.
if (scrollTop != this.scrollLast) {
this.toggleAllDay(false);
this.openTab($('kronolithEventForm').down('.tabset a.kronolithTabLink'));
this.disableAlarmMethods('Event');
- this.knl['kronolithEventStartTime'].markSelected();
- this.knl['kronolithEventEndTime'].markSelected();
+ this.knl.kronolithEventStartTime.markSelected();
+ this.knl.kronolithEventEndTime.markSelected();
$('kronolithEventForm').reset();
kronolithEAttendeesAc.reset();
kronolithETagAc.reset();
topTagsCallback: function(update, tagclass, r)
{
- $('kronolithEventTabTags').select('label').each(function(e) {e.show()});
+ $('kronolithEventTabTags').select('label').invoke('show');
if (!r.response.tags) {
$(update).update();
return;
if (ev.a) {
$('kronolithEventAlarmOn').setValue(true);
[10080, 1440, 60, 1].each(function(unit) {
- if (ev.a % unit == 0) {
+ if (ev.a % unit === 0) {
$('kronolithEventAlarmValue').setValue(ev.a / unit);
$('kronolithEventAlarmUnit').setValue(unit);
throw $break;
$('kronolithEventRepeatLength').down('input[name=recur_end_type][value=none]').setValue(true);
}
} else if (ev.bid) {
- div = $('kronolithEventRepeatException');
+ var div = $('kronolithEventRepeatException');
div.down('span').update(ev.eod);
this.toggleRecurrence('Exception');
} else {
if (!ev.pe) {
$('kronolithEventSave').hide();
kronolithETagAc.disable();
- $('kronolithEventTabTags').select('label').each(function(e) {e.hide()});
+ $('kronolithEventTabTags').select('label').invoke('hide');
} else {
this.doAction('listTopTags', null, this.topTagsCallback.curry('kronolithEventTopTags', 'kronolithEventTag'));
}
var fb = this.freeBusy.get(email)[1],
tr = this.freeBusy.get(email)[0],
td = tr.select('td')[1],
- div = td.down('div'),
- i = 0;
+ div = td.down('div');
if (!td.getWidth()) {
this.insertFreeBusy.bind(this, email).defer();
return;
if (to.isAfter(end)) {
to = end.clone();
}
- if (to.getHours() == 0 && to.getMinutes() == 0) {
+ if (to.getHours() === 0 && to.getMinutes() === 0) {
to.add(-1).minutes();
}
left = from.getHours() + from.getMinutes() / 60;
time = d.toString(Kronolith.conf.time_format);
list.push({ l: time, v: time });
d.add(30).minutes();
- } while (d.getHours() != 0 || d.getMinutes() != 0);
+ } while (d.getHours() !== 0 || d.getMinutes() !== 0);
field = $(field);
opts = {
list: list,
domParent: field.up('.kronolithDialog'),
- onChoose: function(value) { field.setValue(value); this.updateTimeFields(field.identify()); }.bind(this)
- }
+ onChoose: function(value) {
+ field.setValue(value);
+ this.updateTimeFields(field.identify());
+ }.bind(this)
+ };
this.knl[field.id] = new KeyNavList(field, opts);
onGeocode: function(r)
{
r = r.shift();
- ll = new OpenLayers.LonLat(r.lon, r.lat);
this.placeMapMarker({ lat: r.lat, lon: r.lon }, true);
},
if (!this.mapInitialized) {
this.initializeMap();
}
- var dialog = $('kronolithEventForm')
+ var dialog = $('kronolithEventForm');
dialog.select('.kronolithTabsOption').invoke('hide');
dialog.select('.tabset li').invoke('removeClassName', 'activeTab');
$('kronolithEventTabMap').show();
timeFields.invoke('observe', 'blur', this.checkTime.bind(this));
timeFields.each(function(field) {
var dropDown = this.attachTimeDropDown(field);
- field.observe('click', function() { dropDown.show() });
+ field.observe('click', function() { dropDown.show(); });
}, this);
$('kronolithEventStartDate', 'kronolithEventStartTime').invoke('observe', 'change', this.updateEndTime.bind(this));
this.updateMinical(this.date);
/* Initialize the starting page. */
- tmp = location.hash;
+ var tmp = location.hash;
if (!tmp.empty() && tmp.startsWith('#')) {
tmp = (tmp.length == 1) ? '' : tmp.substring(1);
}
log: true,
location: 'br',
noalerts: Kronolith.text.noalerts,
- info: Kronolith.text.growlerinfo,
+ info: Kronolith.text.growlerinfo
});
this.Growler.growlerlog.observe('Growler:toggled', function(e) {
var button = $('kronolithNotifications');