This repository has been archived by the owner on Jul 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
/
app.coffee
81 lines (60 loc) · 2.06 KB
/
app.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
class @App
@Models: {}
@Collections: {}
@Controllers: {}
@Views: {}
@Routers: {}
ajax: $.ajax
# FIXME: move to config
endpoints:
api: 'https://api.github.com/'
web: 'https://github.com/'
constructor: ->
_.extend @, Backbone.Events
$.ajaxSetup
headers:
'Accept': 'application/vnd.github.v3.html+json'
# An event aggrigator
vent: _.extend {}, Backbone.Events
# DOM is ready, initialize the App
ready: =>
$(document.body).addClass('standalone') if window.navigator.standalone
@authenticate() unless window.jasmine?
# Kick off authentication
authenticate: ->
new App.Models.Authentication @start
# User is authenticated, start the main app.
start: =>
$('#app').show()
@filters = new App.Collections.Filters([
{id: 'everything', name: 'Everything', data: {}, octicon: 'inbox'},
{id: 'participating', name: 'Participating', data: {participating: true}, reasons: ['mention', 'author', 'comment', 'state_change', 'assign'], octicon: 'comment-discussion'}
{id: 'mentioned', name: 'Mentioned', data: {participating: true}, reasons: ['team_mention'], octicon: 'jersey'},
])
@repositories = new App.Collections.Repositories()
new App.Routers.Filters
filters: @filters
vent: @vent
new App.Controllers.Filters
filters: @filters
repositories: @repositories
vent: @vent
new App.Routers.Notifications(@vent)
new App.Controllers.Notification(@vent)
new App.Views.Shortcuts(vent: @vent, repositories: @repositories)
new App.Routers.Misc
Backbone.history.start() unless Backbone.History.started
Backbone.history.navigate 'everything', trigger: true
# Notifictions do not get marked as read when in development mode.
isDevelopment: ->
localStorage['dev']?
toggleDevelopment: ->
if localStorage['dev']
localStorage.removeItem('dev')
console.log 'Development mode disabled'
else
localStorage['dev'] = true
console.log 'Development mode enabled'
window.app = new App()
# Initialize the app
$ app.ready