Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.snapsPerSlot = snapsPerSlot;
// might be an array value (for TimelineView).
// if so, getting the most granular entry (the last one probably).
input = this.opt('slotLabelFormat');
if (Array.isArray(input)) {
input = input[input.length - 1];
}
this.labelFormat = createFormatter(input || {
hour: 'numeric',
minute: '2-digit',
omitZeroMinute: true,
meridiem: 'short'
});
input = this.opt('slotLabelInterval');
this.labelInterval = input ?
createDuration(input) :
this.computeLabelInterval(slotDuration);
};
// Computes an automatic value for slotLabelInterval
jsEvent: ev.origEvent as MouseEvent, // Is this always a mouse event? See #4655
view
}
])
if (this.validMutation) {
calendar.dispatch({
type: 'MERGE_EVENTS',
eventStore: mutatedRelevantEvents
})
calendar.publiclyTrigger('eventResize', [
{
el: this.draggingSeg.el,
startDelta: this.validMutation.startDelta || createDuration(0),
endDelta: this.validMutation.endDelta || createDuration(0),
prevEvent: eventApi,
event: new EventApi( // the data AFTER the mutation
calendar,
mutatedRelevantEvents.defs[eventDef.defId],
eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null
),
revert: function() {
calendar.dispatch({
type: 'MERGE_EVENTS',
eventStore: relevantEvents
})
},
jsEvent: ev.origEvent,
view
}
])
el: _this.draggingSeg.el,
event: eventApi,
jsEvent: ev.origEvent,
view: view
}
]);
if (_this.validMutation) {
calendar.dispatch({
type: 'MERGE_EVENTS',
eventStore: mutatedRelevantEvents
});
calendar.publiclyTrigger('eventResize', [
{
el: _this.draggingSeg.el,
startDelta: _this.validMutation.startDelta || createDuration(0),
endDelta: _this.validMutation.endDelta || createDuration(0),
prevEvent: eventApi,
event: new EventApi(// the data AFTER the mutation
calendar, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null),
revert: function () {
calendar.dispatch({
type: 'MERGE_EVENTS',
eventStore: relevantEvents
});
},
jsEvent: ev.origEvent,
view: view
}
]);
}
else {
calendar.publiclyTrigger('_noEventResize');
// if so, getting the most granular entry (the last one probably).
input = options.slotLabelFormat
if (Array.isArray(input)) {
input = input[input.length - 1]
}
this.labelFormat = createFormatter(input || {
hour: 'numeric',
minute: '2-digit',
omitZeroMinute: true,
meridiem: 'short'
})
input = options.slotLabelInterval
this.labelInterval = input ?
createDuration(input) :
this.computeLabelInterval(slotDuration)
}
event: eventApi,
jsEvent: ev.origEvent as MouseEvent, // Is this always a mouse event? See #4655
view
}
])
if (this.validMutation) {
calendar.dispatch({
type: 'MERGE_EVENTS',
eventStore: mutatedRelevantEvents
})
calendar.publiclyTrigger('eventResize', [
{
el: this.draggingSeg.el,
startDelta: this.validMutation.startDelta || createDuration(0),
endDelta: this.validMutation.endDelta || createDuration(0),
prevEvent: eventApi,
event: new EventApi( // the data AFTER the mutation
calendar,
mutatedRelevantEvents.defs[eventDef.defId],
eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null
),
revert: function() {
calendar.dispatch({
type: 'MERGE_EVENTS',
eventStore: relevantEvents
})
},
jsEvent: ev.origEvent,
view
}
computeLabelInterval(slotDuration) {
let i
let labelInterval
let slotsPerLabel
// find the smallest stock label interval that results in more than one slots-per-label
for (i = AGENDA_STOCK_SUB_DURATIONS.length - 1; i >= 0; i--) {
labelInterval = createDuration(AGENDA_STOCK_SUB_DURATIONS[i])
slotsPerLabel = wholeDivideDurations(labelInterval, slotDuration)
if (slotsPerLabel !== null && slotsPerLabel > 1) {
return labelInterval
}
}
return slotDuration // fall back
}
{
el: _this.draggingSeg.el,
event: eventApi,
jsEvent: ev.origEvent,
view: view
}
]);
if (_this.validMutation) {
calendar.dispatch({
type: 'MERGE_EVENTS',
eventStore: mutatedRelevantEvents
});
calendar.publiclyTrigger('eventResize', [
{
el: _this.draggingSeg.el,
startDelta: _this.validMutation.startDelta || createDuration(0),
endDelta: _this.validMutation.endDelta || createDuration(0),
prevEvent: eventApi,
event: new EventApi(// the data AFTER the mutation
calendar, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null),
revert: function () {
calendar.dispatch({
type: 'MERGE_EVENTS',
eventStore: relevantEvents
});
},
jsEvent: ev.origEvent,
view: view
}
]);
}
else {
it('accepts just hours and minutes', function() {
var dur = createDuration('01:02')
expect(dur).toEqual({
years: 0,
months: 0,
days: 0,
milliseconds:
1 * 60 * 60 * 1000 +
2 * 60 * 1000
})
})
it('accepts whole day in string', function() {
var dur = createDuration('2.00:00:00')
expect(dur).toEqual({
years: 0,
months: 0,
days: 2,
milliseconds: 0
})
})
computeDateTop(when: DateMarker, startOfDayDate?: DateMarker) {
if (!startOfDayDate) {
startOfDayDate = startOfDay(when)
}
return this.computeTimeTop(createDuration(when.valueOf() - startOfDayDate.valueOf()))
}