-
Notifications
You must be signed in to change notification settings - Fork 0
/
dashboard_view.coffee
82 lines (82 loc) · 2.23 KB
/
dashboard_view.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
class window.Veggie.DashboardView extends Veggie.View
id: "dashboard"
className: "common"
template: JST['dashboard_view']
collection: new Veggie.Dashboard()
add_song: ->
model = new Song(@collection.get("song"))
@song_view = new Veggie.SongView
model: model
$("#widgets",@$el).append(@song_view.render().el)
add_courses: ->
courses = new Veggie.Courses(@collection.get("courses"))
for c in courses.models
view = new Veggie.CourseView
model: c
$("#courses",@$el).append(view.render().el)
add_quote: ->
view = JST['item/quote'](q: @collection.get("quote"))
$("#quote").html view
add_person: ->
model = new Person(@collection.get("person"))
person_view = new Veggie.PersonView
model: model
$("#widgets",@$el).append(person_view.render().el)
active: ->
super()
if @current_course and @current_course.get("open")
@init_imagine()
close: ->
super()
@deinit_imagine()
deinit_imagine: ->
if $("#imagine").jmpress("initialized")
$("#imagine").jmpress "deinit"
$("#imagine").hide()
$("#icontrol").removeClass 'active'
@$el.css "height":"auto"
init_imagine: ->
unless $("#imagine").jmpress("initialized")
$("#imagine").jmpress
transitionDuration: 0
hash:
use: false
mouse:
clickSelects: false
keyboard:
keys:
9: null
32: null
$("#imagine").jmpress("route", "#iend", true)
$("#imagine").jmpress("route", "#ihome", true, true)
cid = @current_course.get("_id")
if step = $.jStorage.get "course_#{cid}"
$("#imagine").jmpress "goTo","#" + step
$("#imagine").show()
$("#icontrol").show().addClass 'active'
@$el.css "height":"100%"
keyup: (event) ->
switch event.keyCode
when 39
$(".next:visible").trigger("click")
addOneGuide: (guide) ->
view = new Veggie.GuideView
model: guide
$("#assets").append(view.render().el)
render: ->
template = @template(is_newer: @collection.has("guides"))
@$el.html(template)
this
extra: ->
if @collection.has("guides")
guides = @collection.get("guides")
Guide.fetch(guides)
for g,i in guides["member"]
@addOneGuide(Guide.generate(g,i+1))
$(document).on('keyup', @keyup)
@add_song()
@add_courses()
@add_quote()
@add_person()
window.chatroom = new Veggie.ChatView()
super()