Move things from App.setup() to initializer

This commit is contained in:
Piotr Sarnacki 2015-01-30 17:07:28 +01:00
parent 031cc0124d
commit 0a048d1f00
5 changed files with 35 additions and 18 deletions

View File

@ -1,3 +1,5 @@
config = ENV.config
App = Ember.Application.extend(Ember.Evented,
LOG_TRANSITIONS: true
LOG_TRANSITIONS_INTERNAL: true
@ -6,18 +8,6 @@ App = Ember.Application.extend(Ember.Evented,
LOG_VIEW_LOOKUPS: true
#LOG_RESOLVER: true
setup: ->
if @config.pusher.key
@pusher = new Travis.Pusher(@config.pusher)
@tailing = new Travis.Tailing($(window), '#tail', '#log')
@toTop = new Travis.ToTop($(window), '.to-top', '#log-container')
@on 'user:signed_in', (user) ->
Travis.onUserUpdate(user)
@on 'user:synced', (user) ->
Travis.onUserUpdate(user)
lookup: ->
@__container__.lookup.apply @__container__, arguments
@ -84,9 +74,14 @@ App = Ember.Application.extend(Ember.Evented,
Em.run.later (-> element.remove()), 10
ready: ->
@slider = new Travis.Slider(@storage)
location.href = location.href.replace('#!/', '') if location.hash.slice(0, 2) == '#!'
@on 'user:signed_in', (user) ->
Travis.onUserUpdate(user)
@on 'user:synced', (user) ->
Travis.onUserUpdate(user)
currentDate: ->
new Date()

View File

@ -1,7 +1,9 @@
config = ENV.config
initialize = (container) ->
if Travis.config.ga_code
if config.ga_code
window._gaq = []
_gaq.push(['_setAccount', Travis.config.ga_code])
_gaq.push(['_setAccount', config.ga_code])
ga = document.createElement('script')
ga.type = 'text/javascript'

View File

@ -0,0 +1,21 @@
config = ENV.config
Slider = Travis.Slider
Pusher = Travis.Pusher
Tailing = Travis.Tailing
ToTop = Travis.ToTop
initialize = (container, application) ->
application.slider = new Slider(application.storage)
if config.pusher.key
application.pusher = new Pusher(config.pusher)
application.tailing = new Tailing($(window), '#tail', '#log')
application.toTop = new ToTop($(window), '.to-top', '#log-container')
Initializer =
name: 'services'
initialize: initialize
Ember.onLoad 'Ember.Application', (Application) ->
Application.initializer Initializer

View File

@ -166,3 +166,5 @@ if config.pro
]
]
]
Travis.Pusher = TravisPusher

View File

@ -180,7 +180,6 @@ require 'models/user'
require 'models/env-var'
require 'models/ssh-key'
require 'ext/ember/namespace'
require 'views/view'
require 'views/accounts'
require 'views/annotation'
@ -214,5 +213,3 @@ require 'views/application/loading'
require 'views/dashboard/loading'
require 'components/travis-switch'
Travis.setup()