Sha256: dfa9d5629bdd2dc853e4bad1da379a15ef2ffda0df9cd261a1b22c778ae937b3

Contents?: true

Size: 938 Bytes

Versions: 9

Compression:

Stored size: 938 Bytes

Contents

class CalendarApplication
  calendarElements =
    'ul.dates': CalendarDatesController
    'ul.event_details': CalendarEventsController

  @initialize = (options = {}) ->
    for element, controller of calendarElements
      for el in $(element)
        new controller($(el))

    if options.history
      @initializeHistory(options.basePath)

  @initializeHistory = (basePath) ->
    CalendarDate.all().map(
      (date) ->
        date.element.bind('click', (event) ->
          window?.history?.pushState(
            { dateObjectId: date.id },
            null,
            "#{basePath}/#{date.toPath()}"
          )
        )
    )

    window?.onpopstate = (event) ->
      if event.state?.dateObjectId?
        date = CalendarDate.find(event.state.dateObjectId)
        date.trigger('activate')
        CalendarDate.deactivateAllDates()
        date.updateAttributes(active: true)

window.CalendarApplication = CalendarApplication

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
event_cal-2.0.2 vendor/assets/javascripts/calendarApplication.js.coffee
event_cal-2.0.1 vendor/assets/javascripts/calendarApplication.js.coffee
event_cal-2.0.0 vendor/assets/javascripts/calendarApplication.js.coffee
event_cal-1.3.0 vendor/assets/javascripts/calendarApplication.js.coffee
event_cal-1.2.5 vendor/assets/javascripts/calendarApplication.js.coffee
event_cal-1.2.4 vendor/assets/javascripts/calendarApplication.js.coffee
event_cal-1.2.3 vendor/assets/javascripts/calendarApplication.js.coffee
event_cal-1.2.2 vendor/assets/javascripts/calendarApplication.js.coffee
event_cal-1.2.1 vendor/assets/javascripts/calendarApplication.js.coffee