*/
updateCalendarList: function()
{
- var ext = $H(), extNames = $H();
+ var ext = $H(), extNames = $H(),
+ extContainer = $('kronolithExternalCalendars');
$H(Kronolith.conf.calendars.internal).each(function(cal) {
this.insertCalendarInList('internal', cal.key, cal.value);
extNames.set(api, cal.value.api);
});
ext.each(function(api) {
- $('kronolithExternalCalendars')
+ extContainer
.insert(new Element('h3')
.insert({ bottom: extNames.get(api.key).escapeHTML() }))
.insert(new Element('div', { id: 'kronolithExternalCalendar' + api.key, className: 'kronolithCalendars' }));
break;
}
- var day = dates[0].clone(), date, more, title, busy, events;
+ var day = dates[0].clone(), date, more, title, busy, events, monthDay;
while (!day.isAfter(dates[1])) {
date = day.dateString();
switch (view) {
break;
case 'month':
- $('kronolithMonthDay' + date)
- .select('div')
+ monthDay = $('kronolithMonthDay' + date);
+ monthDay.select('div')
.findAll(function(el) { return el.retrieve('calendar') == calendar; })
.invoke('remove');
break;
this.holidays.push(event.key);
}
if (view == 'month' && Kronolith.conf.max_events) {
- more = $('kronolithMonthDay' + date).down('.kronolithMore');
+ more = monthDay.down('.kronolithMore');
if (more) {
more.purge();
more.remove();
}
}
if (view == 'month' && Kronolith.conf.max_events) {
- var events = $('kronolithMonthDay' + date).select('.kronolithEvent');
+ var events = monthDay.select('.kronolithEvent');
if (events.size() >= Kronolith.conf.max_events) {
if (date == (new Date().dateString())) {
// This is today.
if (view == 'day') {
$('kronolithViewDay').down('.kronolithAllDayContainer').insert(div.setStyle(style));
} else {
- var existing = $('kronolithAllDay' + date).childElements();
+ var allDay = $('kronolithAllDay' + date),
+ existing = allDay.childElements(),
+ weekHead = $('kronolithViewWeekHead');
if (existing.size() == 3) {
if (existing[2].className != 'kronolithMore') {
existing[2].purge();
existing[2].remove();
- $('kronolithAllDay' + date).insert({ bottom: new Element('span', { className: 'kronolithMore' }).store('date', date).insert(Kronolith.text.more) });
+ allDay.insert({ bottom: new Element('span', { className: 'kronolithMore' }).store('date', date).insert(Kronolith.text.more) });
}
} else {
- $('kronolithAllDay' + date).insert(div.setStyle(style));
+ allDay.insert(div.setStyle(style));
if (event.value.pe) {
div.addClassName('kronolithEditable');
var layout = div.getLayout(),
- 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(),
+ minLeft = weekHead.down('.kronolithFirstCol').getWidth() + this[storage].spacing + (parseInt(div.getStyle('marginLeft'), 10) || 0),
+ minTop = weekHead.down('thead').getHeight() + this[storage].spacing + (parseInt(div.getStyle('marginTop'), 10) || 0),
+ maxLeft = weekHead.getWidth() - layout.get('margin-box-width'),
+ maxTop = weekHead.down('thead').getHeight() + weekHead.down('.kronolithAllDay').getHeight(),
opts = {
threshold: 5,
parentElement: function() {
var midnight = this.parseDate(date),
resizable = event.value.pe && (Object.isUndefined(event.value.vl) || event.value.vl),
innerDiv = new Element('div', { className: 'kronolithEventInfo' }),
+ parentElement = $(view == 'day' ? 'kronolithEventsDay' : 'kronolithEventsWeek' + date),
minHeight = 0,
draggerTop, draggerBottom;
if (event.value.fi) {
if (draggerBottom) {
div.insert(draggerBottom);
}
- $(view == 'day' ? 'kronolithEventsDay' : 'kronolithEventsWeek' + date).insert(div);
+ parentElement.insert(div);
if (draggerTop) {
minHeight += draggerTop.getHeight();
}
scroll: 'kronolithBody',
nodrop: true,
parentElement: function() {
- return $(view == 'day' ? 'kronolithEventsDay' : 'kronolithEventsWeek' + date);
+ return parentElement;
}
};
+ var scrollArea = $(view == 'day' ? 'kronolithViewDay' : 'kronolithViewWeek').down('.kronolithViewBody');
if (draggerTop) {
opts.snap = function(x, y) {
- y += $(view == 'day' ? 'kronolithViewDay' : 'kronolithViewWeek').down('.kronolithViewBody').scrollTop - this.scrollTop;
+ y += scrollArea.scrollTop - this.scrollTop;
y = Math.max(0, step * (Math.min(maxTop, y) / step | 0));
return [0, y];
}.bind(this);
if (draggerBottom) {
opts.snap = function(x, y) {
- y += $(view == 'day' ? 'kronolithViewDay' : 'kronolithViewWeek').down('.kronolithViewBody').scrollTop - this.scrollTop;
+ y += scrollArea.scrollTop - this.scrollTop;
y = Math.min(maxBottom + dragBottomHeight + KronolithCore[storage].spacing, step * ((Math.max(minBottom, y) + dragBottomHeight + KronolithCore[storage].spacing) / step | 0)) - dragBottomHeight - KronolithCore[storage].spacing;
return [0, y];
}.bind(this);
var d = new Drag(div, {
threshold: 5,
nodrop: true,
- parentElement: function() { return $(view == 'day' ? 'kronolithEventsDay' : 'kronolithEventsWeek' + date); },
+ parentElement: function() { return parentElement; },
snap: function(x, y) {
x = (view == 'week')
? Math.max(minLeft, stepX * ((Math.min(maxLeft, x - (x < 0 ? stepX : 0)) + stepX / 2) / stepX | 0))
: 0;
- y += $(view == 'day' ? 'kronolithViewDay' : 'kronolithViewWeek').down('.kronolithViewBody').scrollTop - this.scrollTop;
+ y += scrollArea.scrollTop - this.scrollTop;
y = Math.max(0, step * (Math.min(maxDiv, y) / step | 0));
return [x, y];
}.bind(this)
break;
case 'month':
- var div = _createElement(event)
+ var monthDay = $('kronolithMonthDay' + date),
+ div = _createElement(event)
.setStyle({ backgroundColor: Kronolith.conf.calendars[calendar[0]][calendar[1]].bg,
color: Kronolith.conf.calendars[calendar[0]][calendar[1]].fg });
- $('kronolithMonthDay' + date).insert(div);
+ monthDay.insert(div);
if (event.value.pe) {
div.setStyle({ cursor: 'move' });
new Drag(event.value.nodeId, { threshold: 5, parentElement: function() { return $('kronolithViewMonthContainer'); }, snapToParent: true });
}
if (Kronolith.conf.max_events) {
- var more = $('kronolithMonthDay' + date).down('.kronolithMore');
+ var more = monthDay.down('.kronolithMore');
if (more) {
- $('kronolithMonthDay' + date).insert({ bottom: more.remove() });
+ monthDay.insert({ bottom: more.remove() });
}
}
break;
*/
insertMore: function(date)
{
- var more = $('kronolithMonthDay' + date).down('.kronolithMore');
+ var monthDay = $('kronolithMonthDay' + date),
+ more = monthDay.down('.kronolithMore');
if (more) {
- $('kronolithMonthDay' + date).insert({ bottom: more.remove() });
+ monthDay.insert({ bottom: more.remove() });
} else {
- $('kronolithMonthDay' + date).insert({ bottom: new Element('span', { className: 'kronolithMore' }).store('date', date).insert(Kronolith.text.more) });
+ monthDay.insert({ bottom: new Element('span', { className: 'kronolithMore' }).store('date', date).insert(Kronolith.text.more) });
}
},
*/
loadTasks: function(tasktype, tasklists)
{
- var tasktypes = this.getTaskStorage(tasktype), loading = false;
+ var tasktypes = this.getTaskStorage(tasktype), loading = false,
+ spinner = $('kronolithLoading');
if (Object.isUndefined(tasklists)) {
tasklists = [];
Object.isUndefined(this.tcache.get(type).get(list))) {
loading = true;
this.loading++;
- $('kronolithLoading').show();
+ spinner.show();
this.doAction('listTasks',
{ type: type,
list: list },
*/
updateTasklistDropDown: function()
{
- $('kronolithTaskList').update();
+ var tasklist = $('kronolithTaskList');
+ tasklist.update();
$H(Kronolith.conf.calendars.tasklists).each(function(cal) {
if (cal.value.edit) {
- $('kronolithTaskList').insert(new Element('option', { value: cal.key.substring(6) })
- .setStyle({ backgroundColor: cal.value.bg, color: cal.value.fg })
- .update(cal.value.name.escapeHTML()));
+ tasklist.insert(new Element('option', { value: cal.key.substring(6) })
+ .setStyle({ backgroundColor: cal.value.bg, color: cal.value.fg })
+ .update(cal.value.name.escapeHTML()));
}
});
},