Procházet zdrojové kódy

deleted a bunch of files

Adam Shaw před 7 roky
rodič
revize
2a9890f0b4

+ 0 - 375
src/models/EventManager.ts

@@ -1,375 +0,0 @@
-import { removeExact } from '../util/array'
-import EventPeriod from './EventPeriod'
-import ArrayEventSource from './event-source/ArrayEventSource'
-import EventSource from './event-source/EventSource'
-import EventSourceParser from './event-source/EventSourceParser'
-import SingleEventDef from './event/SingleEventDef'
-import EventInstanceGroup from './event/EventInstanceGroup'
-import { default as EmitterMixin, EmitterInterface } from '../common/EmitterMixin'
-import { default as ListenerMixin, ListenerInterface } from '../common/ListenerMixin'
-
-
-export default class EventManager {
-
-  on: EmitterInterface['on']
-  one: EmitterInterface['one']
-  off: EmitterInterface['off']
-  trigger: EmitterInterface['trigger']
-  triggerWith: EmitterInterface['triggerWith']
-  hasHandlers: EmitterInterface['hasHandlers']
-  listenTo: ListenerInterface['listenTo']
-  stopListeningTo: ListenerInterface['stopListeningTo']
-
-  currentPeriod: EventPeriod
-
-  calendar: any
-  stickySource: any
-  otherSources: any // does not include sticky source
-
-
-  constructor(calendar) {
-    this.calendar = calendar
-    this.stickySource = new ArrayEventSource(calendar)
-    this.otherSources = []
-  }
-
-
-  requestEvents(start, end, dateEnv, force, callback) {
-    if (
-      force ||
-      !this.currentPeriod ||
-      !this.currentPeriod.isWithinRange(start, end) ||
-      dateEnv !== this.currentPeriod.dateEnv
-    ) {
-      this.setPeriod( // will change this.currentPeriod
-        new EventPeriod(start, end, dateEnv)
-      )
-    }
-
-    this.currentPeriod.whenReleased(callback)
-  }
-
-
-  // Source Adding/Removing
-  // -----------------------------------------------------------------------------------------------------------------
-
-
-  addSource(eventSource) {
-    this.otherSources.push(eventSource)
-
-    if (this.currentPeriod) {
-      this.currentPeriod.requestSource(eventSource) // might release
-    }
-  }
-
-
-  removeSource(doomedSource) {
-    removeExact(this.otherSources, doomedSource)
-
-    if (this.currentPeriod) {
-      this.currentPeriod.purgeSource(doomedSource) // might release
-    }
-  }
-
-
-  removeAllSources() {
-    this.otherSources = []
-
-    if (this.currentPeriod) {
-      this.currentPeriod.purgeAllSources() // might release
-    }
-  }
-
-
-  // Source Refetching
-  // -----------------------------------------------------------------------------------------------------------------
-
-
-  refetchSource(eventSource) {
-    let currentPeriod = this.currentPeriod
-
-    if (currentPeriod) {
-      currentPeriod.freeze()
-      currentPeriod.purgeSource(eventSource)
-      currentPeriod.requestSource(eventSource)
-      currentPeriod.thaw()
-    }
-  }
-
-
-  refetchAllSources() {
-    let currentPeriod = this.currentPeriod
-
-    if (currentPeriod) {
-      currentPeriod.freeze()
-      currentPeriod.purgeAllSources()
-      currentPeriod.requestSources(this.getSources())
-      currentPeriod.thaw()
-    }
-  }
-
-
-  // Source Querying
-  // -----------------------------------------------------------------------------------------------------------------
-
-
-  getSources() {
-    return [ this.stickySource ].concat(this.otherSources)
-  }
-
-
-  // like querySources, but accepts multple match criteria (like multiple IDs)
-  multiQuerySources(matchInputs) {
-
-    // coerce into an array
-    if (!matchInputs) {
-      matchInputs = []
-    } else if (!Array.isArray(matchInputs)) {
-      matchInputs = [ matchInputs ]
-    }
-
-    let matchingSources = []
-    let i
-
-    // resolve raw inputs to real event source objects
-    for (i = 0; i < matchInputs.length; i++) {
-      matchingSources.push.apply( // append
-        matchingSources,
-        this.querySources(matchInputs[i])
-      )
-    }
-
-    return matchingSources
-  }
-
-
-  // matchInput can either by a real event source object, an ID, or the function/URL for the source.
-  // returns an array of matching source objects.
-  querySources(matchInput) {
-    let sources = this.otherSources
-    let i
-    let source
-
-    // given a proper event source object
-    for (i = 0; i < sources.length; i++) {
-      source = sources[i]
-
-      if (source === matchInput) {
-        return [ source ]
-      }
-    }
-
-    // an ID match
-    source = this.getSourceById(EventSource.normalizeId(matchInput))
-    if (source) {
-      return [ source ]
-    }
-
-    // parse as an event source
-    matchInput = EventSourceParser.parse(matchInput, this.calendar)
-    if (matchInput) {
-
-      return sources.filter(function(source) {
-        return isSourcesEquivalent(matchInput, source)
-      })
-    }
-  }
-
-
-  /*
-  ID assumed to already be normalized
-  */
-  getSourceById(id) {
-    return this.otherSources.filter(function(source: any) {
-      return source.id && source.id === id
-    })[0]
-  }
-
-
-  // Event-Period
-  // -----------------------------------------------------------------------------------------------------------------
-
-
-  setPeriod(eventPeriod) {
-    if (this.currentPeriod) {
-      this.unbindPeriod(this.currentPeriod)
-      this.currentPeriod = null
-    }
-
-    this.currentPeriod = eventPeriod
-    this.bindPeriod(eventPeriod)
-
-    eventPeriod.requestSources(this.getSources())
-  }
-
-
-  bindPeriod(eventPeriod) {
-    this.listenTo(eventPeriod, 'release', function(eventsPayload) {
-      this.trigger('release', eventsPayload)
-    })
-  }
-
-
-  unbindPeriod(eventPeriod) {
-    this.stopListeningTo(eventPeriod)
-  }
-
-
-  // Event Getting/Adding/Removing
-  // -----------------------------------------------------------------------------------------------------------------
-
-
-  getEventDefByUid(uid) {
-    if (this.currentPeriod) {
-      return this.currentPeriod.getEventDefByUid(uid)
-    }
-  }
-
-
-  addEventDef(eventDef, isSticky) {
-    if (isSticky) {
-      this.stickySource.addEventDef(eventDef)
-    }
-
-    if (this.currentPeriod) {
-      this.currentPeriod.addEventDef(eventDef) // might release
-    }
-  }
-
-
-  removeEventDefsById(eventId) {
-    this.getSources().forEach(function(eventSource) {
-      eventSource.removeEventDefsById(eventId)
-    })
-
-    if (this.currentPeriod) {
-      this.currentPeriod.removeEventDefsById(eventId) // might release
-    }
-  }
-
-
-  removeAllEventDefs() {
-    this.getSources().forEach(function(eventSource) {
-      eventSource.removeAllEventDefs()
-    })
-
-    if (this.currentPeriod) {
-      this.currentPeriod.removeAllEventDefs()
-    }
-  }
-
-
-  // Event Mutating
-  // -----------------------------------------------------------------------------------------------------------------
-
-
-  /*
-  Returns an undo function.
-  */
-  mutateEventsWithId(eventDefId, eventDefMutation) {
-    let currentPeriod = this.currentPeriod
-    let eventDefs
-    let undoFuncs = []
-
-    if (currentPeriod) {
-
-      currentPeriod.freeze()
-
-      eventDefs = currentPeriod.getEventDefsById(eventDefId)
-      eventDefs.forEach(function(eventDef) {
-        // add/remove esp because id might change
-        currentPeriod.removeEventDef(eventDef)
-        undoFuncs.push(eventDefMutation.mutateSingle(eventDef))
-        currentPeriod.addEventDef(eventDef)
-      })
-
-      currentPeriod.thaw()
-
-      return function() {
-        currentPeriod.freeze()
-
-        for (let i = 0; i < eventDefs.length; i++) {
-          currentPeriod.removeEventDef(eventDefs[i])
-          undoFuncs[i]()
-          currentPeriod.addEventDef(eventDefs[i])
-        }
-
-        currentPeriod.thaw()
-      }
-    }
-
-    return function() { /* nothing to undo */ }
-  }
-
-
-  /*
-  copies and then mutates
-  */
-  buildMutatedEventInstanceGroup(eventDefId, eventDefMutation) {
-    let eventDefs = this.getEventDefsById(eventDefId)
-    let i
-    let defCopy
-    let allInstances = []
-
-    for (i = 0; i < eventDefs.length; i++) {
-      defCopy = eventDefs[i].clone()
-
-      if (defCopy instanceof SingleEventDef) {
-        eventDefMutation.mutateSingle(defCopy)
-
-        allInstances.push.apply(allInstances, // append
-          defCopy.buildInstances()
-        )
-      }
-    }
-
-    return new EventInstanceGroup(allInstances)
-  }
-
-
-  // Freezing
-  // -----------------------------------------------------------------------------------------------------------------
-
-
-  freeze() {
-    if (this.currentPeriod) {
-      this.currentPeriod.freeze()
-    }
-  }
-
-
-  thaw() {
-    if (this.currentPeriod) {
-      this.currentPeriod.thaw()
-    }
-  }
-
-
-  // methods that simply forward to EventPeriod
-
-  getEventDefsById(eventDefId) {
-    return this.currentPeriod.getEventDefsById(eventDefId)
-  }
-
-  getEventInstances() {
-    return this.currentPeriod.getEventInstances()
-  }
-
-  getEventInstancesWithId(eventDefId) {
-    return this.currentPeriod.getEventInstancesWithId(eventDefId)
-  }
-
-  getEventInstancesWithoutId(eventDefId) {
-    return this.currentPeriod.getEventInstancesWithoutId(eventDefId)
-  }
-
-}
-
-
-EmitterMixin.mixInto(EventManager)
-ListenerMixin.mixInto(EventManager)
-
-
-function isSourcesEquivalent(source0, source1) {
-  return source0.getPrimitive() === source1.getPrimitive()
-}

+ 0 - 344
src/models/EventPeriod.ts

@@ -1,344 +0,0 @@
-import { removeExact, removeMatching } from '../util/array'
-import { isEmptyObject } from '../util/object'
-import { default as EmitterMixin, EmitterInterface } from '../common/EmitterMixin'
-import UnzonedRange from './UnzonedRange'
-import EventInstanceGroup from './event/EventInstanceGroup'
-import { DateEnv } from '../datelib/env'
-import { DateMarker } from '../datelib/marker'
-
-export default class EventPeriod {
-
-  on: EmitterInterface['on']
-  one: EmitterInterface['one']
-  off: EmitterInterface['off']
-  trigger: EmitterInterface['trigger']
-  triggerWith: EmitterInterface['triggerWith']
-  hasHandlers: EmitterInterface['hasHandlers']
-
-  start: DateMarker
-  end: DateMarker
-  dateEnv: DateEnv
-
-  unzonedRange: UnzonedRange
-
-  requestsByUid: any
-  pendingCnt: number = 0
-
-  freezeDepth: number = 0
-  stuntedReleaseCnt: number = 0
-  releaseCnt: number = 0
-
-  eventDefsByUid: any
-  eventDefsById: any
-  eventInstanceGroupsById: any
-
-
-  constructor(start: DateMarker, end: DateMarker, dateEnv: DateEnv) {
-    this.start = start
-    this.end = end
-    this.dateEnv = dateEnv
-
-    this.unzonedRange = new UnzonedRange(start, end)
-
-    this.requestsByUid = {}
-    this.eventDefsByUid = {}
-    this.eventDefsById = {}
-    this.eventInstanceGroupsById = {}
-  }
-
-
-  isWithinRange(start, end) {
-    return start >= this.start && end <= this.end
-  }
-
-
-  // Requesting and Purging
-  // -----------------------------------------------------------------------------------------------------------------
-
-
-  requestSources(sources) {
-    this.freeze()
-
-    for (let i = 0; i < sources.length; i++) {
-      this.requestSource(sources[i])
-    }
-
-    this.thaw()
-  }
-
-
-  requestSource(source) {
-    let request = { source: source, status: 'pending', eventDefs: null }
-
-    this.requestsByUid[source.uid] = request
-    this.pendingCnt += 1
-
-    source.fetch(this.start, this.end, this.dateEnv, (eventDefs) => {
-      if (request.status !== 'cancelled') {
-        request.status = 'completed'
-        request.eventDefs = eventDefs
-
-        this.addEventDefs(eventDefs)
-        this.pendingCnt--
-        this.tryRelease()
-      }
-    }, () => { // failure
-      if (request.status !== 'cancelled') {
-        request.status = 'failed'
-
-        this.pendingCnt--
-        this.tryRelease()
-      }
-    })
-  }
-
-
-  purgeSource(source) {
-    let request = this.requestsByUid[source.uid]
-
-    if (request) {
-      delete this.requestsByUid[source.uid]
-
-      if (request.status === 'pending') {
-        request.status = 'cancelled'
-        this.pendingCnt--
-        this.tryRelease()
-      } else if (request.status === 'completed') {
-        request.eventDefs.forEach(this.removeEventDef.bind(this))
-      }
-    }
-  }
-
-
-  purgeAllSources() {
-    let requestsByUid = this.requestsByUid
-    let uid
-    let request
-    let completedCnt = 0
-
-    for (uid in requestsByUid) {
-      request = requestsByUid[uid]
-
-      if (request.status === 'pending') {
-        request.status = 'cancelled'
-      } else if (request.status === 'completed') {
-        completedCnt++
-      }
-    }
-
-    this.requestsByUid = {}
-    this.pendingCnt = 0
-
-    if (completedCnt) {
-      this.removeAllEventDefs() // might release
-    }
-  }
-
-
-  // Event Definitions
-  // -----------------------------------------------------------------------------------------------------------------
-
-
-  getEventDefByUid(eventDefUid) {
-    return this.eventDefsByUid[eventDefUid]
-  }
-
-
-  getEventDefsById(eventDefId) {
-    let a = this.eventDefsById[eventDefId]
-
-    if (a) {
-      return a.slice() // clone
-    }
-
-    return []
-  }
-
-
-  addEventDefs(eventDefs) {
-    for (let i = 0; i < eventDefs.length; i++) {
-      this.addEventDef(eventDefs[i])
-    }
-  }
-
-
-  addEventDef(eventDef) {
-    let eventDefsById = this.eventDefsById
-    let eventDefId = eventDef.id
-    let eventDefs = eventDefsById[eventDefId] || (eventDefsById[eventDefId] = [])
-    let eventInstances = eventDef.buildInstances(this.unzonedRange)
-    let i
-
-    eventDefs.push(eventDef)
-
-    this.eventDefsByUid[eventDef.uid] = eventDef
-
-    for (i = 0; i < eventInstances.length; i++) {
-      this.addEventInstance(eventInstances[i], eventDefId)
-    }
-  }
-
-
-  removeEventDefsById(eventDefId) {
-    this.getEventDefsById(eventDefId).forEach((eventDef) => {
-      this.removeEventDef(eventDef)
-    })
-  }
-
-
-  removeAllEventDefs() {
-    let hasEventDefs = !isEmptyObject(this.eventDefsByUid)
-
-    this.eventDefsByUid = {}
-    this.eventDefsById = {}
-    this.eventInstanceGroupsById = {}
-
-    if (hasEventDefs) {
-      this.tryRelease()
-    }
-  }
-
-
-  removeEventDef(eventDef) {
-    let eventDefsById = this.eventDefsById
-    let eventDefs = eventDefsById[eventDef.id]
-
-    delete this.eventDefsByUid[eventDef.uid]
-
-    if (eventDefs) {
-      removeExact(eventDefs, eventDef)
-
-      if (!eventDefs.length) {
-        delete eventDefsById[eventDef.id]
-      }
-
-      this.removeEventInstancesForDef(eventDef)
-    }
-  }
-
-
-  // Event Instances
-  // -----------------------------------------------------------------------------------------------------------------
-
-
-  getEventInstances() { // TODO: consider iterator
-    let eventInstanceGroupsById = this.eventInstanceGroupsById
-    let eventInstances = []
-    let id
-
-    for (id in eventInstanceGroupsById) {
-      eventInstances.push.apply(eventInstances, // append
-        eventInstanceGroupsById[id].eventInstances
-      )
-    }
-
-    return eventInstances
-  }
-
-
-  getEventInstancesWithId(eventDefId) {
-    let eventInstanceGroup = this.eventInstanceGroupsById[eventDefId]
-
-    if (eventInstanceGroup) {
-      return eventInstanceGroup.eventInstances.slice() // clone
-    }
-
-    return []
-  }
-
-
-  getEventInstancesWithoutId(eventDefId) { // TODO: consider iterator
-    let eventInstanceGroupsById = this.eventInstanceGroupsById
-    let matchingInstances = []
-    let id
-
-    for (id in eventInstanceGroupsById) {
-      if (id !== eventDefId) {
-        matchingInstances.push.apply(matchingInstances, // append
-          eventInstanceGroupsById[id].eventInstances
-        )
-      }
-    }
-
-    return matchingInstances
-  }
-
-
-  addEventInstance(eventInstance, eventDefId) {
-    let eventInstanceGroupsById = this.eventInstanceGroupsById
-    let eventInstanceGroup = eventInstanceGroupsById[eventDefId] ||
-      (eventInstanceGroupsById[eventDefId] = new EventInstanceGroup())
-
-    eventInstanceGroup.eventInstances.push(eventInstance)
-
-    this.tryRelease()
-  }
-
-
-  removeEventInstancesForDef(eventDef) {
-    let eventInstanceGroupsById = this.eventInstanceGroupsById
-    let eventInstanceGroup = eventInstanceGroupsById[eventDef.id]
-    let removeCnt
-
-    if (eventInstanceGroup) {
-      removeCnt = removeMatching(eventInstanceGroup.eventInstances, function(currentEventInstance) {
-        return currentEventInstance.def === eventDef
-      })
-
-      if (!eventInstanceGroup.eventInstances.length) {
-        delete eventInstanceGroupsById[eventDef.id]
-      }
-
-      if (removeCnt) {
-        this.tryRelease()
-      }
-    }
-  }
-
-
-  // Releasing and Freezing
-  // -----------------------------------------------------------------------------------------------------------------
-
-
-  tryRelease() {
-    if (!this.pendingCnt) {
-      if (!this.freezeDepth) {
-        this.release()
-      } else {
-        this.stuntedReleaseCnt++
-      }
-    }
-  }
-
-
-  release() {
-    this.releaseCnt++
-    this.trigger('release', this.eventInstanceGroupsById)
-  }
-
-
-  whenReleased(callback) {
-    if (this.releaseCnt) {
-      callback(this.eventInstanceGroupsById)
-    } else {
-      this.one('release', callback)
-    }
-  }
-
-
-  freeze() {
-    if (!(this.freezeDepth++)) {
-      this.stuntedReleaseCnt = 0
-    }
-  }
-
-
-  thaw() {
-    if (!(--this.freezeDepth) && this.stuntedReleaseCnt && !this.pendingCnt) {
-      this.release()
-    }
-  }
-
-}
-
-EmitterMixin.mixInto(EventPeriod)

+ 0 - 87
src/models/event-source/ArrayEventSource.ts

@@ -1,87 +0,0 @@
-import { removeMatching } from '../../util/array'
-import EventSource from './EventSource'
-
-
-export default class ArrayEventSource extends EventSource {
-
-  rawEventDefs: any = [] // unparsed. initialized here in the case of no parsing
-  dynamicEventDefs: any = [] // parsed
-  eventDefs: any
-  currentDateEnv: any
-
-
-  static parse(rawInput, calendar) {
-    let rawProps
-
-    // normalize raw input
-    if (Array.isArray(rawInput.events)) { // extended form
-      rawProps = rawInput
-    } else if (Array.isArray(rawInput)) { // short form
-      rawProps = { events: rawInput }
-    }
-
-    if (rawProps) {
-      return EventSource.parse.call(this, rawProps, calendar)
-    }
-
-    return false
-  }
-
-
-  fetch(start, end, dateEnv, onSuccess, onFailure) {
-
-    if (
-      !this.eventDefs || // first time
-      this.currentDateEnv !== dateEnv
-    ) {
-      this.eventDefs = this.parseEventDefs(this.rawEventDefs).concat(this.dynamicEventDefs)
-      this.currentDateEnv = dateEnv
-    }
-
-    onSuccess(this.eventDefs)
-  }
-
-
-  addEventDef(eventDef) {
-    this.dynamicEventDefs.push(eventDef)
-
-    if (this.eventDefs) {
-      this.eventDefs.push(eventDef)
-    }
-  }
-
-
-  /*
-  eventDefId already normalized to a string
-  */
-  removeEventDefsById(eventDefId) {
-    return removeMatching(this.eventDefs, function(eventDef) {
-      return eventDef.id === eventDefId
-    })
-  }
-
-
-  removeAllEventDefs() {
-    this.eventDefs = []
-  }
-
-
-  getPrimitive() {
-    return this.rawEventDefs
-  }
-
-
-  applyManualStandardProps(rawProps) {
-    let superSuccess = super.applyManualStandardProps(rawProps)
-
-    this.rawEventDefs = rawProps.events
-
-    return superSuccess
-  }
-
-}
-
-
-ArrayEventSource.defineStandardProps({
-  events: false // don't automatically transfer
-})

+ 0 - 173
src/models/event-source/EventSource.ts

@@ -1,173 +0,0 @@
-import {
-  default as ParsableModelMixin,
-  ParsableModelInterface
-} from '../../common/ParsableModelMixin'
-import Class from '../../common/Class'
-import Calendar from '../../Calendar'
-import EventDefParser from '../event/EventDefParser'
-import { DateMarker } from '../../datelib/marker'
-import { DateEnv } from '../../datelib/env'
-
-
-export default class EventSource extends Class {
-
-  static uuid: number = 0
-  static defineStandardProps = ParsableModelMixin.defineStandardProps
-  static copyVerbatimStandardProps = ParsableModelMixin.copyVerbatimStandardProps
-
-  applyProps: ParsableModelInterface['applyProps']
-  isStandardProp: ParsableModelInterface['isStandardProp']
-
-  calendar: Calendar
-
-  id: string // can stay null
-  uid: string
-  color: string
-  backgroundColor: string
-  borderColor: string
-  textColor: string
-  className: string[]
-  editable: boolean
-  startEditable: boolean
-  durationEditable: boolean
-  rendering: string | null
-  overlap: boolean
-  constraint: any
-  allDayDefault: boolean
-  eventDataTransform: any // optional function
-
-
-  // can we do away with calendar? at least for the abstract?
-  // useful for buildEventDef
-  constructor(calendar) {
-    super()
-    this.calendar = calendar
-    this.className = []
-    this.uid = String(EventSource.uuid++)
-  }
-
-
-  /*
-  rawInput can be any data type!
-  */
-  static parse(rawInput, calendar) {
-    let source = new this(calendar)
-
-    if (typeof rawInput === 'object' && rawInput) { // non-null object
-      if (source.applyProps(rawInput)) {
-        return source
-      }
-    }
-
-    return false
-  }
-
-
-  static normalizeId(id) { // TODO: converge with EventDef
-    if (id) {
-      return String(id)
-    }
-
-    return null
-  }
-
-
-  fetch(start: DateMarker, end: DateMarker, dateEnv: DateEnv, onSuccess, onFailure) {
-    // subclasses must implement. must call the `onSuccess` or `onFailure` func.
-  }
-
-
-  removeEventDefsById(eventDefId) {
-    // optional for subclasses to implement
-  }
-
-
-  removeAllEventDefs() {
-    // optional for subclasses to implement
-  }
-
-
-  /*
-  For compairing/matching
-  */
-  getPrimitive(otherSource) {
-    // subclasses must implement
-  }
-
-
-  parseEventDefs(rawEventDefs) {
-    let i
-    let eventDef
-    let eventDefs = []
-
-    for (i = 0; i < rawEventDefs.length; i++) {
-      eventDef = this.parseEventDef(rawEventDefs[i])
-
-      if (eventDef) {
-        eventDefs.push(eventDef)
-      }
-    }
-
-    return eventDefs
-  }
-
-
-  parseEventDef(rawInput) {
-    let calendarTransform = this.calendar.opt('eventDataTransform')
-    let sourceTransform = this.eventDataTransform
-
-    if (calendarTransform) {
-      rawInput = calendarTransform(rawInput, this.calendar)
-    }
-    if (sourceTransform) {
-      rawInput = sourceTransform(rawInput, this.calendar)
-    }
-
-    return EventDefParser.parse(rawInput, this)
-  }
-
-
-  applyManualStandardProps(rawProps) {
-
-    if (rawProps.id != null) {
-      this.id = EventSource.normalizeId(rawProps.id)
-    }
-
-    // TODO: converge with EventDef
-    if (Array.isArray(rawProps.className)) {
-      this.className = rawProps.className
-    } else if (typeof rawProps.className === 'string') {
-      this.className = rawProps.className.split(/\s+/)
-    }
-
-    return true
-  }
-
-}
-
-ParsableModelMixin.mixInto(EventSource)
-
-
-// Parsing
-// ---------------------------------------------------------------------------------------------------------------------
-
-
-EventSource.defineStandardProps({
-  // manually process...
-  id: false,
-  className: false,
-
-  // automatically transfer...
-  color: true,
-  backgroundColor: true,
-  borderColor: true,
-  textColor: true,
-  editable: true,
-  startEditable: true,
-  durationEditable: true,
-  rendering: true,
-  overlap: true,
-  constraint: true,
-  allDayDefault: true,
-  eventDataTransform: true
-})

+ 0 - 26
src/models/event-source/EventSourceParser.ts

@@ -1,26 +0,0 @@
-
-export default {
-
-  sourceClasses: [],
-
-
-  registerClass: function(EventSourceClass) {
-    this.sourceClasses.unshift(EventSourceClass) // give highest priority
-  },
-
-
-  parse: function(rawInput, calendar) {
-    let sourceClasses = this.sourceClasses
-    let i
-    let eventSource
-
-    for (i = 0; i < sourceClasses.length; i++) {
-      eventSource = sourceClasses[i].parse(rawInput, calendar)
-
-      if (eventSource) {
-        return eventSource
-      }
-    }
-  }
-
-}

+ 0 - 70
src/models/event-source/FuncEventSource.ts

@@ -1,70 +0,0 @@
-import { unpromisify } from '../../util/promise'
-import EventSource from './EventSource'
-import { DateMarker } from '../../datelib/marker'
-import { DateEnv } from '../../datelib/env'
-
-export default class FuncEventSource extends EventSource {
-
-  func: any
-
-
-  static parse(rawInput, calendar) {
-    let rawProps
-
-    // normalize raw input
-    if (typeof rawInput.events === 'function') { // extended form
-      rawProps = rawInput
-    } else if (typeof rawInput === 'function') { // short form
-      rawProps = { events: rawInput }
-    }
-
-    if (rawProps) {
-      return EventSource.parse.call(this, rawProps, calendar)
-    }
-
-    return false
-  }
-
-
-  fetch(start: DateMarker, end: DateMarker, dateEnv: DateEnv, onSuccess, onFailure) {
-    this.calendar.pushLoading()
-
-    unpromisify( // allow the func to return a promise
-      this.func.bind(
-        this.calendar,
-        {
-          start: dateEnv.toDate(start),
-          end: dateEnv.toDate(end),
-          timeZone: dateEnv.timeZone
-        }
-      ),
-      (rawEventDefs) => {
-        this.calendar.popLoading()
-        onSuccess(this.parseEventDefs(rawEventDefs))
-      },
-      () => {
-        this.calendar.popLoading()
-        onFailure()
-      }
-    )
-  }
-
-
-  getPrimitive() {
-    return this.func
-  }
-
-
-  applyManualStandardProps(rawProps) {
-    let superSuccess = super.applyManualStandardProps(rawProps)
-
-    this.func = rawProps.events
-
-    return superSuccess
-  }
-
-}
-
-FuncEventSource.defineStandardProps({
-  events: false // don't automatically transfer
-})

+ 0 - 144
src/models/event-source/JsonFeedEventSource.ts

@@ -1,144 +0,0 @@
-import * as request from 'superagent'
-import { assignTo } from '../../util/object'
-import { applyAll } from '../../util/misc'
-import EventSource from './EventSource'
-import { DateMarker } from '../../datelib/marker'
-import { DateEnv } from '../../datelib/env'
-
-
-export default class JsonFeedEventSource extends EventSource {
-
-  // these props must all be manually set before calling fetch
-  url: any
-  startParam: any
-  endParam: any
-  timezoneParam: any
-  ajaxSettings: any // does not include url
-
-
-  static parse(rawInput, calendar) {
-    let rawProps
-
-    // normalize raw input
-    if (typeof rawInput.url === 'string') { // extended form
-      rawProps = rawInput
-    } else if (typeof rawInput === 'string') { // short form
-      rawProps = { url: rawInput }
-    }
-
-    if (rawProps) {
-      return EventSource.parse.call(this, rawProps, calendar)
-    }
-
-    return false
-  }
-
-
-  fetch(start: DateMarker, end: DateMarker, dateEnv: DateEnv, onSuccess, onFailure) {
-    let ajaxSettings = this.ajaxSettings
-    let requestParams = this.buildRequestParams(start, end, dateEnv)
-    let theRequest
-
-    this.calendar.pushLoading()
-
-    if (!ajaxSettings.method || ajaxSettings.method.toUpperCase() === 'GET') {
-      theRequest = request.get(this.url).query(requestParams) // querystring params
-    } else {
-      theRequest = request(ajaxSettings.method, this.url).send(requestParams) // body data
-    }
-
-    theRequest.end((error, res) => {
-      let rawEventDefs
-
-      this.calendar.popLoading()
-
-      if (!error) {
-        if (res.body) { // parsed JSON
-          rawEventDefs = res.body
-        } else if (res.text) {
-          // if the server doesn't set Content-Type, won't be parsed as JSON. parse anyway.
-          rawEventDefs = JSON.parse(res.text)
-        }
-      }
-
-      if (rawEventDefs) {
-        let callbackRes = applyAll(ajaxSettings.success, null, [ rawEventDefs, res ])
-
-        if (Array.isArray(callbackRes)) {
-          rawEventDefs = callbackRes
-        }
-
-        onSuccess(this.parseEventDefs(rawEventDefs))
-      } else {
-        applyAll(ajaxSettings.error, null, [ error, res ])
-        onFailure()
-      }
-    })
-  }
-
-
-  buildRequestParams(start: DateMarker, end: DateMarker, dateEnv: DateEnv) {
-    let calendar = this.calendar
-    let ajaxSettings = this.ajaxSettings
-    let startParam
-    let endParam
-    let timezoneParam
-    let customRequestParams
-    let params = {}
-
-    startParam = this.startParam
-    if (startParam == null) {
-      startParam = calendar.opt('startParam')
-    }
-
-    endParam = this.endParam
-    if (endParam == null) {
-      endParam = calendar.opt('endParam')
-    }
-
-    timezoneParam = this.timezoneParam
-    if (timezoneParam == null) {
-      timezoneParam = calendar.opt('timezoneParam')
-    }
-
-    // retrieve any outbound GET/POST data from the options
-    if (typeof ajaxSettings.data === 'function') {
-      // supplied as a function that returns a key/value object
-      customRequestParams = ajaxSettings.data()
-    } else {
-      // probably supplied as a straight key/value object
-      customRequestParams = ajaxSettings.data || {}
-    }
-
-    assignTo(params, customRequestParams)
-
-    params[startParam] = dateEnv.formatIso(start)
-    params[endParam] = dateEnv.formatIso(end)
-
-    if (dateEnv.timeZone !== 'local') {
-      params[timezoneParam] = dateEnv.timeZone
-    }
-
-    return params
-  }
-
-
-  getPrimitive() {
-    return this.url
-  }
-
-
-  applyMiscProps(rawProps) {
-    this.ajaxSettings = rawProps
-  }
-
-}
-
-
-JsonFeedEventSource.defineStandardProps({
-  // automatically transfer (true)...
-  url: true,
-  startParam: true,
-  endParam: true,
-  timezoneParam: true
-})

+ 0 - 10
src/models/event-source/config.ts

@@ -1,10 +0,0 @@
-
-import EventSourceParser from './EventSourceParser'
-
-import ArrayEventSource from './ArrayEventSource'
-import FuncEventSource from './FuncEventSource'
-import JsonFeedEventSource from './JsonFeedEventSource'
-
-EventSourceParser.registerClass(ArrayEventSource)
-EventSourceParser.registerClass(FuncEventSource)
-EventSourceParser.registerClass(JsonFeedEventSource)

+ 0 - 102
src/models/event/EventDateProfile.ts

@@ -1,102 +0,0 @@
-import UnzonedRange from '../UnzonedRange'
-import Calendar from '../../Calendar'
-import { DateMarker, startOfDay } from '../../datelib/marker'
-
-/*
-Meant to be immutable
-*/
-export default class EventDateProfile {
-
-  unzonedRange: any
-  hasEnd: boolean
-  isAllDay: boolean
-  forcedStartTimeZoneOffset: number
-  forcedEndTimeZoneOffset: number
-
-
-  constructor(startMarker: DateMarker, endMarker: DateMarker, isAllDay: boolean, calendar: Calendar, forcedStartTimeZoneOffset?: number, forcedEndTimeZoneOffset?: number) {
-    this.unzonedRange = new UnzonedRange(
-      startMarker,
-      endMarker || calendar.getDefaultEventEnd(isAllDay, startMarker)
-    )
-    this.hasEnd = Boolean(endMarker)
-    this.isAllDay = isAllDay
-    this.forcedStartTimeZoneOffset = forcedStartTimeZoneOffset
-    this.forcedEndTimeZoneOffset = forcedEndTimeZoneOffset
-  }
-
-
-  /*
-  Needs an EventSource object
-  */
-  static parse(rawProps, source) {
-    let startInput = rawProps.start || rawProps.date
-    let endInput = rawProps.end
-
-    if (!startInput) {
-      return false
-    }
-
-    let calendar: Calendar = source.calendar
-    let startMeta = calendar.dateEnv.createMarkerMeta(startInput)
-    let startMarker = startMeta && startMeta.marker
-    let endMeta = endInput && calendar.dateEnv.createMarkerMeta(endInput)
-    let endMarker = endMeta && endMeta.marker
-    let forcedAllDay = rawProps.allDay
-    let forceEventDuration = calendar.opt('forceEventDuration')
-    let isAllDay
-
-    if (!startMarker) {
-      return false
-    }
-
-    if (endMarker && endMarker <= startMarker) {
-      endMarker = null
-      // TODO: warning?
-    }
-
-    if (forcedAllDay == null) {
-      forcedAllDay = source.allDayDefault
-
-      if (forcedAllDay == null) {
-        forcedAllDay = calendar.opt('allDayDefault')
-      }
-    }
-
-    if (forcedAllDay == null) {
-      isAllDay = startMeta.isTimeUnspecified && (!endMeta || endMeta.isTimeUnspecified)
-    } else {
-      isAllDay = forcedAllDay
-
-      if (forcedAllDay === true) {
-        startMarker = startOfDay(startMarker)
-
-        if (endMarker) {
-          endMarker = startOfDay(endMarker)
-        }
-      }
-    }
-
-    if (!endMarker && forceEventDuration) {
-      endMarker = calendar.getDefaultEventEnd(
-        startMeta.isTimeUnspecified,
-        startMarker
-      )
-    }
-
-    return new EventDateProfile(
-      startMarker,
-      endMarker,
-      isAllDay,
-      calendar,
-      startMeta.forcedTimeZoneOffset,
-      endMeta ? endMeta.forcedTimeZoneOffset : null
-    )
-  }
-
-
-  static isStandardProp(propName) {
-    return propName === 'start' || propName === 'date' || propName === 'end' || propName === 'allDay'
-  }
-
-}

+ 0 - 236
src/models/event/EventDef.ts

@@ -1,236 +0,0 @@
-import { assignTo } from '../../util/object'
-import {
-  default as ParsableModelMixin,
-  ParsableModelInterface
-} from '../../common/ParsableModelMixin'
-
-
-export default abstract class EventDef {
-
-  static uuid: number = 0
-  static defineStandardProps = ParsableModelMixin.defineStandardProps
-  static copyVerbatimStandardProps = ParsableModelMixin.copyVerbatimStandardProps
-
-  applyProps: ParsableModelInterface['applyProps']
-  isStandardProp: ParsableModelInterface['isStandardProp']
-
-  source: any // required
-
-  id: any // normalized supplied ID
-  rawId: any // unnormalized supplied ID
-  uid: any // internal ID. new ID for every definition
-
-  // NOTE: eventOrder sorting relies on these
-  title: any
-  url: any
-  rendering: any
-  constraint: any
-  overlap: any
-  editable: any
-  startEditable: any
-  durationEditable: any
-  color: any
-  backgroundColor: any
-  borderColor: any
-  textColor: any
-
-  className: any // an array. TODO: rename to className*s* (API breakage)
-  miscProps: any
-
-
-  constructor(source) {
-    this.source = source
-    this.className = []
-    this.miscProps = {}
-  }
-
-
-  static parse(rawInput, source) {
-    let def = new (this as any)(source)
-
-    if (def.applyProps(rawInput)) {
-      return def
-    }
-
-    return false
-  }
-
-
-  static normalizeId(id) { // TODO: converge with EventSource
-    return String(id)
-  }
-
-
-  static generateId() {
-    return '_fc' + (EventDef.uuid++)
-  }
-
-
-  abstract isAllDay() // subclasses must implement
-
-  abstract buildInstances(unzonedRange) // subclasses must implement
-
-
-  clone() {
-    let copy = new (this.constructor as any)(this.source)
-
-    copy.id = this.id
-    copy.rawId = this.rawId
-    copy.uid = this.uid // not really unique anymore :(
-
-    EventDef.copyVerbatimStandardProps(this, copy)
-
-    copy.className = this.className.slice() // copy
-    copy.miscProps = assignTo({}, this.miscProps)
-
-    return copy
-  }
-
-
-  hasInverseRendering() {
-    return this.getRendering() === 'inverse-background'
-  }
-
-
-  hasBgRendering() {
-    let rendering = this.getRendering()
-
-    return rendering === 'inverse-background' || rendering === 'background'
-  }
-
-
-  getRendering() {
-    if (this.rendering != null) {
-      return this.rendering
-    }
-
-    return this.source.rendering
-  }
-
-
-  getConstraint() {
-    if (this.constraint != null) {
-      return this.constraint
-    }
-
-    if (this.source.constraint != null) {
-      return this.source.constraint
-    }
-
-    return this.source.calendar.opt('eventConstraint') // what about View option?
-  }
-
-
-  getOverlap() {
-    if (this.overlap != null) {
-      return this.overlap
-    }
-
-    if (this.source.overlap != null) {
-      return this.source.overlap
-    }
-
-    return this.source.calendar.opt('eventOverlap') // what about View option?
-  }
-
-
-  isStartExplicitlyEditable() {
-    if (this.startEditable != null) {
-      return this.startEditable
-    }
-
-    return this.source.startEditable
-  }
-
-
-  isDurationExplicitlyEditable() {
-    if (this.durationEditable != null) {
-      return this.durationEditable
-    }
-
-    return this.source.durationEditable
-  }
-
-
-  isExplicitlyEditable() {
-    if (this.editable != null) {
-      return this.editable
-    }
-
-    return this.source.editable
-  }
-
-
-  toLegacy() {
-    let obj = assignTo({}, this.miscProps)
-
-    obj._id = this.uid
-    obj.source = this.source
-    obj.className = this.className.slice() // copy
-    obj.isAllDay = this.isAllDay()
-
-    if (this.rawId != null) {
-      obj.id = this.rawId
-    }
-
-    EventDef.copyVerbatimStandardProps(this, obj)
-
-    return obj
-  }
-
-
-  applyManualStandardProps(rawProps) {
-
-    if (rawProps.id != null) {
-      this.id = EventDef.normalizeId((this.rawId = rawProps.id))
-    } else {
-      this.id = EventDef.generateId()
-    }
-
-    if (rawProps._id != null) { // accept this prop, even tho somewhat internal
-      this.uid = String(rawProps._id)
-    } else {
-      this.uid = EventDef.generateId()
-    }
-
-    // TODO: converge with EventSource
-    if (Array.isArray(rawProps.className)) {
-      this.className = rawProps.className
-    }
-    if (typeof rawProps.className === 'string') {
-      this.className = rawProps.className.split(/\s+/)
-    }
-
-    return true
-  }
-
-
-  applyMiscProps(rawProps) {
-    assignTo(this.miscProps, rawProps)
-  }
-
-}
-
-ParsableModelMixin.mixInto(EventDef)
-
-EventDef.defineStandardProps({
-  // not automatically assigned (`false`)
-  _id: false,
-  id: false,
-  className: false,
-  source: false, // will ignored
-
-  // automatically assigned (`true`)
-  title: true,
-  url: true,
-  rendering: true,
-  constraint: true,
-  overlap: true,
-  editable: true,
-  startEditable: true,
-  durationEditable: true,
-  color: true,
-  backgroundColor: true,
-  borderColor: true,
-  textColor: true
-})

+ 0 - 156
src/models/event/EventDefDateMutation.ts

@@ -1,156 +0,0 @@
-import Calendar from '../../Calendar'
-import EventDateProfile from './EventDateProfile'
-import { startOfDay, diffDayAndTime } from '../../datelib/marker'
-import { Duration, createDuration, subtractDurations } from '../../datelib/duration'
-
-export default class EventDefDateMutation {
-
-  clearEnd: boolean = false
-  forceTimed: boolean = false
-  forceAllDay: boolean = false
-
-  // Durations. if 0-ms duration, will be null instead.
-  // Callers should not set this directly.
-  dateDelta: Duration
-  startDelta: Duration
-  endDelta: Duration
-
-
-  static createFromDiff(dateProfile0, dateProfile1, largeUnit, calendar: Calendar) {
-    const dateEnv = calendar.dateEnv
-    let clearEnd = dateProfile0.hasEnd && !dateProfile1.hasEnd
-    let forceTimed = dateProfile0.isAllDay && !dateProfile1.isAllDay
-    let forceAllDay = !dateProfile0.isAllDay && dateProfile1.isAllDay
-    let dateDelta
-    let endDiff
-    let endDelta
-    let mutation
-
-    // subtracts the dates in the appropriate way, returning a duration
-    function diffDates(date0, date1) {
-      if (largeUnit === 'year') {
-        return createDuration(dateEnv.diffWholeYears(date0, date1), 'year')
-      } else if (largeUnit === 'month') {
-        return createDuration(dateEnv.diffWholeMonths(date0, date1), 'month')
-      } else {
-        return diffDayAndTime(date0, date1) // returns a duration
-      }
-    }
-
-    dateDelta = diffDates(dateProfile0.unzonedRange.start, dateProfile1.unzonedRange.start)
-
-    if (dateProfile1.hasEnd) {
-      // use unzonedRanges because dateProfile0.end might be null
-      endDiff = diffDates(
-        dateProfile0.unzonedRange.end,
-        dateProfile1.unzonedRange.end
-      )
-      endDelta = subtractDurations(endDiff, dateDelta)
-    }
-
-    mutation = new EventDefDateMutation()
-    mutation.clearEnd = clearEnd
-    mutation.forceTimed = forceTimed
-    mutation.forceAllDay = forceAllDay
-    mutation.setDateDelta(dateDelta)
-    mutation.setEndDelta(endDelta)
-
-    return mutation
-  }
-
-
-  /*
-  returns an undo function.
-  */
-  buildNewDateProfile(eventDateProfile, calendar: Calendar) {
-    const dateEnv = calendar.dateEnv
-    let isAllDay = eventDateProfile.isAllDay
-    let startMarker = eventDateProfile.unzonedRange.start
-    let endMarker = null
-
-    if (this.forceAllDay) {
-      isAllDay = true
-    } else if (this.forceTimed) {
-      isAllDay = false
-    }
-
-    if (eventDateProfile.hasEnd && !this.clearEnd) {
-      endMarker = eventDateProfile.unzonedRange.end
-    } else if (this.endDelta && !endMarker) { // won't always be null?
-      endMarker = calendar.getDefaultEventEnd(eventDateProfile.isAllDay, startMarker)
-    }
-
-    if (this.dateDelta) {
-      startMarker = dateEnv.add(startMarker, this.dateDelta)
-
-      if (endMarker) {
-        endMarker = dateEnv.add(endMarker, this.dateDelta)
-      }
-    }
-
-    // do this before adding startDelta to start, so we can work off of start
-    if (this.endDelta) {
-      endMarker = dateEnv.add(endMarker, this.endDelta)
-    }
-
-    if (this.startDelta) {
-      startMarker = dateEnv.add(startMarker, this.startDelta)
-    }
-
-    if (this.forceAllDay) {
-      startMarker = startOfDay(startMarker)
-
-      if (endMarker) {
-        endMarker = startOfDay(endMarker)
-      }
-    }
-
-    // TODO: okay to access calendar option?
-    if (!endMarker && calendar.opt('forceEventDuration')) {
-      endMarker = calendar.getDefaultEventEnd(isAllDay, startMarker)
-    }
-
-    return new EventDateProfile(
-      startMarker,
-      endMarker,
-      isAllDay,
-      calendar,
-      eventDateProfile.forcedStartTimeZoneOffset,
-      eventDateProfile.forcedEndTimeZoneOffset
-    )
-  }
-
-
-  setDateDelta(dateDelta) {
-    if (dateDelta && dateDelta.valueOf()) {
-      this.dateDelta = dateDelta
-    } else {
-      this.dateDelta = null
-    }
-  }
-
-
-  setStartDelta(startDelta) {
-    if (startDelta && startDelta.valueOf()) {
-      this.startDelta = startDelta
-    } else {
-      this.startDelta = null
-    }
-  }
-
-
-  setEndDelta(endDelta) {
-    if (endDelta && endDelta.valueOf()) {
-      this.endDelta = endDelta
-    } else {
-      this.endDelta = null
-    }
-  }
-
-
-  isEmpty() {
-    return !this.clearEnd && !this.forceTimed && !this.forceAllDay &&
-      !this.dateDelta && !this.startDelta && !this.endDelta
-  }
-
-}

+ 0 - 147
src/models/event/EventDefMutation.ts

@@ -1,147 +0,0 @@
-import { isArraysEqual } from '../../util/array'
-import EventDateProfile from './EventDateProfile'
-import EventDef from './EventDef'
-import EventDefDateMutation from './EventDefDateMutation'
-import SingleEventDef from './SingleEventDef'
-
-
-export default class EventDefMutation {
-
-  // won't ever be empty. will be null instead.
-  // callers should use setDateMutation for setting.
-  dateMutation: any
-
-  // hacks to get updateEvent/createFromRawProps to work.
-  // not undo-able and not considered in isEmpty.
-  eventDefId: any // standard manual props
-  className: any // "
-  verbatimStandardProps: any
-  miscProps: any
-
-
-  static createFromRawProps(eventInstance, rawProps, largeUnit, calendar) {
-    let eventDef = eventInstance.def
-    let dateProps: any = {}
-    let standardProps: any = {}
-    let miscProps: any = {}
-    let verbatimStandardProps: any = {}
-    let eventDefId = null
-    let className = null
-    let propName
-    let dateProfile
-    let dateMutation
-    let defMutation
-
-    for (propName in rawProps) {
-      if (EventDateProfile.isStandardProp(propName)) {
-        dateProps[propName] = rawProps[propName]
-      } else if (eventDef.isStandardProp(propName)) {
-        standardProps[propName] = rawProps[propName]
-      } else if (eventDef.miscProps[propName] !== rawProps[propName]) { // only if changed
-        miscProps[propName] = rawProps[propName]
-      }
-    }
-
-    dateProfile = EventDateProfile.parse(dateProps, eventDef.source)
-
-    if (dateProfile) { // no failure?
-      dateMutation = EventDefDateMutation.createFromDiff(
-        eventInstance.dateProfile,
-        dateProfile,
-        largeUnit,
-        calendar
-      )
-    }
-
-    if (standardProps.id !== eventDef.id) {
-      eventDefId = standardProps.id // only apply if there's a change
-    }
-
-    if (!isArraysEqual(standardProps.className, eventDef.className)) {
-      className = standardProps.className // only apply if there's a change
-    }
-
-    EventDef.copyVerbatimStandardProps(
-      standardProps, // src
-      verbatimStandardProps // dest
-    )
-
-    defMutation = new EventDefMutation()
-    defMutation.eventDefId = eventDefId
-    defMutation.className = className
-    defMutation.verbatimStandardProps = verbatimStandardProps
-    defMutation.miscProps = miscProps
-
-    if (dateMutation) {
-      defMutation.dateMutation = dateMutation
-    }
-
-    return defMutation
-  }
-
-
-  /*
-  eventDef assumed to be a SingleEventDef.
-  returns an undo function.
-  */
-  mutateSingle(eventDef) {
-    let origDateProfile
-
-    if (this.dateMutation) {
-      origDateProfile = eventDef.dateProfile
-
-      eventDef.dateProfile = this.dateMutation.buildNewDateProfile(
-        origDateProfile,
-        eventDef.source.calendar
-      )
-    }
-
-    // can't undo
-    // TODO: more DRY with EventDef::applyManualStandardProps
-    if (this.eventDefId != null) {
-      eventDef.id = EventDef.normalizeId((eventDef.rawId = this.eventDefId))
-    }
-
-    // can't undo
-    // TODO: more DRY with EventDef::applyManualStandardProps
-    if (this.className) {
-      eventDef.className = this.className
-    }
-
-    // can't undo
-    if (this.verbatimStandardProps) {
-      SingleEventDef.copyVerbatimStandardProps(
-        this.verbatimStandardProps, // src
-        eventDef // dest
-      )
-    }
-
-    // can't undo
-    if (this.miscProps) {
-      eventDef.applyMiscProps(this.miscProps)
-    }
-
-    if (origDateProfile) {
-      return function() {
-        eventDef.dateProfile = origDateProfile
-      }
-    } else {
-      return function() { /* nothing to undo */ }
-    }
-  }
-
-
-  setDateMutation(dateMutation) {
-    if (dateMutation && !dateMutation.isEmpty()) {
-      this.dateMutation = dateMutation
-    } else {
-      this.dateMutation = null
-    }
-  }
-
-
-  isEmpty() {
-    return !this.dateMutation
-  }
-
-}

+ 0 - 25
src/models/event/EventDefParser.ts

@@ -1,25 +0,0 @@
-import SingleEventDef from './SingleEventDef'
-import RecurringEventDef from './RecurringEventDef'
-import { createDuration } from '../../datelib/duration'
-
-
-export default {
-
-  parse: function(eventInput, source) {
-    let startTime, endTime // for testing if given object is a duration
-
-    if (typeof eventInput.start !== 'number') { // because numbers should be parsed as dates
-      startTime = createDuration(eventInput.start)
-    }
-    if (typeof eventInput.end !== 'number') {
-      endTime = createDuration(eventInput.end)
-    }
-
-    if (startTime && endTime) { // inefficient to compute and then throw away
-      return RecurringEventDef.parse(eventInput, source)
-    } else {
-      return SingleEventDef.parse(eventInput, source)
-    }
-  }
-
-}

+ 0 - 27
src/models/event/EventInstance.ts

@@ -1,27 +0,0 @@
-
-export default class EventInstance {
-
-  def: any // EventDef
-  dateProfile: any // EventDateProfile
-
-
-  constructor(def, dateProfile) {
-    this.def = def
-    this.dateProfile = dateProfile
-  }
-
-
-  toLegacy(calendar) {
-    const dateEnv = calendar.dateEnv
-    let dateProfile = this.dateProfile
-    let obj = this.def.toLegacy()
-
-    obj.start = dateEnv.toDate(dateProfile.unzonedRange.start)
-    obj.end = dateProfile.hasEnd ?
-      dateEnv.toDate(dateProfile.unzonedRange.end) :
-      null
-
-    return obj
-  }
-
-}

+ 0 - 86
src/models/event/EventInstanceGroup.ts

@@ -1,86 +0,0 @@
-import UnzonedRange from '../UnzonedRange'
-import { eventInstanceToEventRange, eventInstanceToUnzonedRange } from './util'
-import EventRange from './EventRange'
-
-/*
-It's expected that there will be at least one EventInstance,
-OR that an explicitEventDef is assigned.
-*/
-export default class EventInstanceGroup {
-
-  eventInstances: any
-  explicitEventDef: any // optional
-
-
-  constructor(eventInstances?) {
-    this.eventInstances = eventInstances || []
-  }
-
-
-  getAllEventRanges(constraintRange) {
-    if (constraintRange) {
-      return this.sliceNormalRenderRanges(constraintRange)
-    } else {
-      return this.eventInstances.map(eventInstanceToEventRange)
-    }
-  }
-
-
-  sliceRenderRanges(constraintRange) {
-    if (this.isInverse()) {
-      return this.sliceInverseRenderRanges(constraintRange)
-    } else {
-      return this.sliceNormalRenderRanges(constraintRange)
-    }
-  }
-
-
-  sliceNormalRenderRanges(constraintRange) {
-    let eventInstances = this.eventInstances
-    let i
-    let eventInstance
-    let slicedRange
-    let slicedEventRanges = []
-
-    for (i = 0; i < eventInstances.length; i++) {
-      eventInstance = eventInstances[i]
-
-      slicedRange = eventInstance.dateProfile.unzonedRange.intersect(constraintRange)
-
-      if (slicedRange) {
-        slicedEventRanges.push(
-          new EventRange(
-            slicedRange,
-            eventInstance.def,
-            eventInstance
-          )
-        )
-      }
-    }
-
-    return slicedEventRanges
-  }
-
-
-  sliceInverseRenderRanges(constraintRange) {
-    let unzonedRanges = this.eventInstances.map(eventInstanceToUnzonedRange)
-    let ownerDef = this.getEventDef()
-
-    unzonedRanges = UnzonedRange.invertRanges(unzonedRanges, constraintRange)
-
-    return unzonedRanges.map(function(unzonedRange) {
-      return new EventRange(unzonedRange, ownerDef) // don't give an EventInstance
-    })
-  }
-
-
-  isInverse() {
-    return this.getEventDef().hasInverseRendering()
-  }
-
-
-  getEventDef() {
-    return this.explicitEventDef || this.eventInstances[0].def
-  }
-
-}

+ 0 - 21
src/models/event/EventRange.ts

@@ -1,21 +0,0 @@
-import UnzonedRange from '../../models/UnzonedRange'
-import EventDef from '../../models/event/EventDef'
-import EventInstance from '../../models/event/EventInstance'
-
-export default class EventRange {
-
-  unzonedRange: UnzonedRange
-  eventDef: EventDef
-  eventInstance: EventInstance // optional
-
-
-  constructor(unzonedRange, eventDef, eventInstance?) {
-    this.unzonedRange = unzonedRange
-    this.eventDef = eventDef
-
-    if (eventInstance) {
-      this.eventInstance = eventInstance
-    }
-  }
-
-}

+ 0 - 127
src/models/event/RecurringEventDef.ts

@@ -1,127 +0,0 @@
-import { assignTo } from '../../util/object'
-import EventDef from './EventDef'
-import EventInstance from './EventInstance'
-import EventDateProfile from './EventDateProfile'
-import { createDuration, Duration } from '../../datelib/duration'
-import { DateMarker, startOfDay } from '../../datelib/marker'
-
-const ONE_DAY = createDuration({ days: 1 })
-
-export default class RecurringEventDef extends EventDef {
-
-  startTime: Duration // duration
-  endTime: Duration // duration, or null
-  dowHash: any // object hash, or null
-
-
-  isAllDay() {
-    return !this.startTime && !this.endTime
-  }
-
-
-  buildInstances(unzonedRange) {
-    let calendar = this.source.calendar
-    const dateEnv = calendar.dateEnv
-    let dateMarker: DateMarker = startOfDay(unzonedRange.start)
-    let endMarker: DateMarker = unzonedRange.end
-    let instanceStart: DateMarker
-    let instanceEnd: DateMarker
-    let instances = []
-
-    while (dateMarker < endMarker) {
-
-      // if everyday, or this particular day-of-week
-      if (!this.dowHash || this.dowHash[dateMarker.getUTCDay()]) {
-
-        if (this.startTime) {
-          instanceStart = dateEnv.add(dateMarker, this.startTime)
-        } else {
-          instanceStart = dateMarker
-        }
-
-        if (this.endTime) {
-          instanceEnd = dateEnv.add(dateMarker, this.endTime)
-        } else {
-          instanceEnd = null
-        }
-
-        instances.push(
-          new EventInstance(
-            this, // definition
-            new EventDateProfile(instanceStart, instanceEnd, !(this.startTime || this.endTime), calendar)
-          )
-        )
-      }
-
-      dateMarker = dateEnv.add(dateMarker, ONE_DAY)
-    }
-
-    return instances
-  }
-
-
-  setDow(dowNumbers) {
-
-    if (!this.dowHash) {
-      this.dowHash = {}
-    }
-
-    for (let i = 0; i < dowNumbers.length; i++) {
-      this.dowHash[dowNumbers[i]] = true
-    }
-  }
-
-
-  clone() {
-    let def = super.clone()
-
-    if (def.startTime) {
-      def.startTime = createDuration(this.startTime)
-    }
-
-    if (def.endTime) {
-      def.endTime = createDuration(this.endTime)
-    }
-
-    if (this.dowHash) {
-      def.dowHash = assignTo({}, this.dowHash)
-    }
-
-    return def
-  }
-
-}
-
-
-/*
-HACK to work with TypeScript mixins
-NOTE: if super-method fails, should still attempt to apply
-*/
-RecurringEventDef.prototype.applyProps = function(rawProps) {
-  let superSuccess = EventDef.prototype.applyProps.call(this, rawProps)
-
-  if (rawProps.start) {
-    this.startTime = createDuration(rawProps.start)
-  }
-
-  if (rawProps.end) {
-    this.endTime = createDuration(rawProps.end)
-  }
-
-  if (rawProps.dow) {
-    this.setDow(rawProps.dow)
-  }
-
-  return superSuccess
-}
-
-
-// Parsing
-// ---------------------------------------------------------------------------------------------------------------------
-
-
-RecurringEventDef.defineStandardProps({ // false = manually process
-  start: false,
-  end: false,
-  dow: false
-})

+ 0 - 74
src/models/event/SingleEventDef.ts

@@ -1,74 +0,0 @@
-import EventDef from './EventDef'
-import EventInstance from './EventInstance'
-import EventDateProfile from './EventDateProfile'
-
-
-export default class SingleEventDef extends EventDef {
-
-  dateProfile: any
-
-
-  /*
-  Will receive start/end params, but will be ignored.
-  */
-  buildInstances() {
-    return [ this.buildInstance() ]
-  }
-
-
-  buildInstance() {
-    return new EventInstance(
-      this, // definition
-      this.dateProfile
-    )
-  }
-
-
-  isAllDay() {
-    return this.dateProfile.isAllDay
-  }
-
-
-  clone() {
-    let def = super.clone()
-
-    def.dateProfile = this.dateProfile
-
-    return def
-  }
-
-
-  /*
-  NOTE: if super-method fails, should still attempt to apply
-  */
-  applyManualStandardProps(rawProps) {
-    let superSuccess = super.applyManualStandardProps(rawProps)
-    let dateProfile = EventDateProfile.parse(rawProps, this.source) // returns null on failure
-
-    if (dateProfile) {
-      this.dateProfile = dateProfile
-
-      // make sure `date` shows up in the legacy event objects as-is
-      if (rawProps.date != null) {
-        this.miscProps.date = rawProps.date
-      }
-
-      return superSuccess
-    } else {
-      return false
-    }
-  }
-
-}
-
-
-// Parsing
-// ---------------------------------------------------------------------------------------------------------------------
-
-
-SingleEventDef.defineStandardProps({ // false = manually process
-  start: false,
-  date: false, // alias for 'start'
-  end: false,
-  allDay: false
-})