%PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
Server IP : 49.231.201.246 / Your IP : 216.73.216.149 Web Server : Apache/2.4.18 (Ubuntu) System : Linux 246 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : root ( 0) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : exec,passthru,shell_exec,system,proc_open,popen,pcntl_exec MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /proc/11585/cwd/html/ppaobm/vendor/bower-asset/fullcalendar/src/core/structs/ |
Upload File : |
import { Duration, asRoughMs, durationsEqual } from '../datelib/duration' import { EventStore, createEmptyEventStore } from './event-store' import { EventDef, EventInstance } from './event' import Calendar from '../Calendar' import { computeAlignedDayRange } from '../util/misc' import { startOfDay } from '../datelib/marker' import { EventUiHash, EventUi } from '../component/event-ui' import { compileEventUis } from '../component/event-rendering' /* A data structure for how to modify an EventDef/EventInstance within an EventStore */ export interface EventMutation { startDelta?: Duration endDelta?: Duration standardProps?: any // for the def. should not include extendedProps extendedProps?: any // for the def } // applies the mutation to ALL defs/instances within the event store export function applyMutationToEventStore(eventStore: EventStore, eventConfigBase: EventUiHash, mutation: EventMutation, calendar: Calendar): EventStore { let eventConfigs = compileEventUis(eventStore.defs, eventConfigBase) let dest = createEmptyEventStore() for (let defId in eventStore.defs) { let def = eventStore.defs[defId] dest.defs[defId] = applyMutationToEventDef(def, eventConfigs[defId], mutation, calendar.pluginSystem.hooks.eventDefMutationAppliers, calendar) } for (let instanceId in eventStore.instances) { let instance = eventStore.instances[instanceId] let def = dest.defs[instance.defId] // important to grab the newly modified def dest.instances[instanceId] = applyMutationToEventInstance(instance, def, eventConfigs[instance.defId], mutation, calendar) } return dest } export type eventDefMutationApplier = (eventDef: EventDef, mutation: EventMutation, calendar: Calendar) => void function applyMutationToEventDef(eventDef: EventDef, eventConfig: EventUi, mutation: EventMutation, appliers: eventDefMutationApplier[], calendar: Calendar): EventDef { let standardProps = mutation.standardProps || {} // if hasEnd has not been specified, guess a good value based on deltas. // if duration will change, there's no way the default duration will persist, // and thus, we need to mark the event as having a real end if ( standardProps.hasEnd == null && eventConfig.durationEditable && willDeltasAffectDuration( eventConfig.startEditable ? mutation.startDelta : null, mutation.endDelta || null ) ) { standardProps.hasEnd = true // TODO: is this mutation okay? } let copy: EventDef = { ...eventDef, ...standardProps, ui: { ...eventDef.ui, ...standardProps.ui } // the only prop we want to recursively overlay } if (mutation.extendedProps) { copy.extendedProps = { ...copy.extendedProps, ...mutation.extendedProps } } for (let applier of appliers) { applier(copy, mutation, calendar) } if (!copy.hasEnd && calendar.opt('forceEventDuration')) { copy.hasEnd = true } return copy } function willDeltasAffectDuration(startDelta: Duration | null, endDelta: Duration | null) { if (startDelta && !asRoughMs(startDelta)) { startDelta = null } if (endDelta && !asRoughMs(endDelta)) { endDelta = null } if (!startDelta && !endDelta) { return false } if (Boolean(startDelta) !== Boolean(endDelta)) { return true } return !durationsEqual(startDelta, endDelta) } function applyMutationToEventInstance( eventInstance: EventInstance, eventDef: EventDef, // must first be modified by applyMutationToEventDef eventConfig: EventUi, mutation: EventMutation, calendar: Calendar ): EventInstance { let dateEnv = calendar.dateEnv let forceAllDay = mutation.standardProps && mutation.standardProps.allDay === true let clearEnd = mutation.standardProps && mutation.standardProps.hasEnd === false let copy = { ...eventInstance } as EventInstance if (forceAllDay) { copy.range = computeAlignedDayRange(copy.range) } if (mutation.startDelta && eventConfig.startEditable) { copy.range = { start: dateEnv.add(copy.range.start, mutation.startDelta), end: copy.range.end } } if (clearEnd) { copy.range = { start: copy.range.start, end: calendar.getDefaultEventEnd(eventDef.allDay, copy.range.start) } } else if ( mutation.endDelta && ( eventConfig.durationEditable || !willDeltasAffectDuration( // TODO: nonDRY logic above eventConfig.startEditable ? mutation.startDelta : null, mutation.endDelta ) ) ) { copy.range = { start: copy.range.start, end: dateEnv.add(copy.range.end, mutation.endDelta) } } // in case event was all-day but the supplied deltas were not // better util for this? if (eventDef.allDay) { copy.range = { start: startOfDay(copy.range.start), end: startOfDay(copy.range.end) } } // handle invalid durations if (copy.range.end < copy.range.start) { copy.range.end = calendar.getDefaultEventEnd(eventDef.allDay, copy.range.start) } return copy }