added minSlotNumber and maxSlotNumber to be able to limit the size of the event that can be added.
This commit is contained in:
parent
56ae9f1cbf
commit
74ba72cdfa
1 changed files with 27 additions and 7 deletions
|
@ -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);
|
||||||
dates = [
|
if (d2>d1) {
|
||||||
d1,
|
var date1 = d1
|
||||||
addMinutes(cloneDate(d1), opt('slotMinutes')),
|
var date2 = d2
|
||||||
d2,
|
} else {
|
||||||
addMinutes(cloneDate(d2), opt('slotMinutes'))
|
var date1 = d2
|
||||||
].sort(cmp);
|
var date2 = d1
|
||||||
|
}
|
||||||
|
if (maxSlotNumber != 0 && (date2-date1) >= maxSlotNumber*opt('slotMinutes')*60000) {
|
||||||
|
dates = [
|
||||||
|
date1,
|
||||||
|
addMinutes(cloneDate(date1), minSlotNumber*opt('slotMinutes')),
|
||||||
|
date1,
|
||||||
|
addMinutes(cloneDate(date1), maxSlotNumber*opt('slotMinutes'))
|
||||||
|
].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;
|
||||||
|
|
Loading…
Reference in a new issue