2016-02-13 20:39:14 +00:00
|
|
|
define [
|
|
|
|
'jquery',
|
|
|
|
'underscore'
|
|
|
|
'backbone'
|
|
|
|
], ($, _, Backbone) ->
|
|
|
|
|
|
|
|
monday = (d) ->
|
|
|
|
d = new Date d
|
|
|
|
day = d.getDay()
|
|
|
|
diff = d.getDate() - day + (if day == 0 then -6 else 1)
|
|
|
|
new Date d.setDate diff
|
|
|
|
|
2016-02-13 21:37:45 +00:00
|
|
|
class OfficeHours extends Backbone.Model
|
2016-02-13 20:39:14 +00:00
|
|
|
start: null,
|
|
|
|
|
|
|
|
url: ->
|
2016-02-13 21:37:45 +00:00
|
|
|
if @start instanceof Date then "/oh/hours/#{encodeURIComponent @start}" else "/oh/hours/"
|
2016-02-13 20:39:14 +00:00
|
|
|
|
2016-02-13 21:37:45 +00:00
|
|
|
initialize: (model, option) ->
|
2016-02-13 20:39:14 +00:00
|
|
|
@start = monday(new Date)
|
|
|
|
|
|
|
|
# This is going to go with the Google idea of a view and overlays:
|
|
|
|
# given a parent object, and precise definitions of the base
|
|
|
|
# Calendar, OfficeHours and Appointments views, draw
|
|
|
|
|
|
|
|
class Appointments extends Backbone.View
|
|
|
|
|
2016-02-13 21:37:45 +00:00
|
|
|
class OfficeHoursView extends Backbone.View
|
2016-02-13 20:39:14 +00:00
|
|
|
|
|
|
|
class DayView extends Backbone.View
|
|
|
|
|
|
|
|
|
|
|
|
class CalendarView extends Backbone.View
|
2016-02-13 21:37:45 +00:00
|
|
|
className: 'calendar'
|
2016-02-13 20:39:14 +00:00
|
|
|
|
2016-02-13 21:37:45 +00:00
|
|
|
events:
|
2016-02-13 20:39:14 +00:00
|
|
|
'click .forward': "nextWeek"
|
|
|
|
'click .backward': "lastWeek"
|
|
|
|
|
|
|
|
initialize: (options) ->
|
|
|
|
|
|
|
|
->
|
2016-02-13 21:37:45 +00:00
|
|
|
officehours = new OfficeHours()
|
|
|
|
$.when(officehours.fetch()).then(console.log(officehours))
|