added minSlotNumber and maxSlotNumber to be able to limit the size of the event that can be added.

This commit is contained in:
Solgema 2011-12-13 15:40:50 +01:00
parent 56ae9f1cbf
commit 74ba72cdfa

View file

@ -1,9 +1,10 @@
setDefaults({ setDefaults({
allDaySlot: true, allDaySlot: true,
allDayText: 'all-day', allDayText: 'all-day',
firstHour: 6, firstHour: 6,
slotMinutes: 30, slotMinutes: 30,
minSlotNumber: 0,
maxSlotNumber: 0,
defaultEventMinutes: 120, defaultEventMinutes: 120,
axisFormat: 'h(:mm)tt', axisFormat: 'h(:mm)tt',
timeFormat: { timeFormat: {
@ -736,17 +737,36 @@ function AgendaView(element, calendar, viewName) {
if (ev.which == 1 && opt('selectable')) { // ev.which==1 means left mouse button if (ev.which == 1 && opt('selectable')) { // ev.which==1 means left mouse button
unselect(ev); unselect(ev);
var dates; var dates;
var minSlotNumber = opt('minSlotNumber');
if (minSlotNumber <= 0) minSlotNumber = 1;
var maxSlotNumber = opt('maxSlotNumber');
hoverListener.start(function(cell, origCell) { hoverListener.start(function(cell, origCell) {
clearSelection(); clearSelection();
if (cell && cell.col == origCell.col && !cellIsAllDay(cell)) { if (cell && cell.col == origCell.col && !cellIsAllDay(cell)) {
var d1 = cellDate(origCell); var d1 = cellDate(origCell);
var d2 = cellDate(cell); var d2 = cellDate(cell);
if (d2>d1) {
var date1 = d1
var date2 = d2
} else {
var date1 = d2
var date2 = d1
}
if (maxSlotNumber != 0 && (date2-date1) >= maxSlotNumber*opt('slotMinutes')*60000) {
dates = [ dates = [
d1, date1,
addMinutes(cloneDate(d1), opt('slotMinutes')), addMinutes(cloneDate(date1), minSlotNumber*opt('slotMinutes')),
d2, date1,
addMinutes(cloneDate(d2), opt('slotMinutes')) addMinutes(cloneDate(date1), maxSlotNumber*opt('slotMinutes'))
].sort(cmp); ].sort(cmp);
} else {
dates = [
date1,
addMinutes(cloneDate(date1), minSlotNumber*opt('slotMinutes')),
date2,
addMinutes(cloneDate(date2), opt('slotMinutes'))
].sort(cmp);
}
renderSlotSelection(dates[0], dates[3]); renderSlotSelection(dates[0], dates[3]);
}else{ }else{
dates = null; dates = null;