travis-web/assets/scripts/app/controllers/repo.coffee
Damien Mathieu c9e0f07a5a highlight multiple lines
We can now highlight multiple lines, adding #L1-L2 to the hash.
We can select the ending line with shift + click.

Closes travis-ci/travis-ci#1829
2014-01-07 21:46:19 +01:00

85 lines
2.0 KiB
CoffeeScript

Travis.RepoController = Travis.Controller.extend
needs: ['repos', 'currentUser', 'build']
currentUserBinding: 'controllers.currentUser'
build: Ember.computed.alias('controllers.build.build')
slug: (-> @get('repo.slug') ).property('repo.slug')
isLoading: (-> @get('repo.isLoading') ).property('repo.isLoading')
init: ->
@_super.apply this, arguments
Visibility.every Travis.INTERVALS.updateTimes, @updateTimes.bind(this)
updateTimes: ->
Ember.run this, ->
if builds = @get('builds')
builds.forEach (b) -> b.updateTimes()
if build = @get('build')
build.updateTimes()
if build && jobs = build.get('jobs')
jobs.forEach (j) -> j.updateTimes()
activate: (action) ->
@stopObservingLastBuild()
this["view#{$.camelize(action)}"]()
viewIndex: ->
@observeLastBuild()
@connectTab('current')
viewCurrent: ->
@observeLastBuild()
@connectTab('current')
viewBuilds: ->
@connectTab('builds')
viewPullRequests: ->
@connectTab('pull_requests')
viewBranches: ->
@connectTab('branches')
viewBuild: ->
@connectTab('build')
viewJob: ->
@connectTab('job')
lastBuildDidChange: ->
Ember.run.scheduleOnce('data', this, @_lastBuildDidChange);
_lastBuildDidChange: ->
build = @get('repo.lastBuild')
@set('build', build)
stopObservingLastBuild: ->
@removeObserver('repo.lastBuild', this, 'lastBuildDidChange')
observeLastBuild: ->
@lastBuildDidChange()
@addObserver('repo.lastBuild', this, 'lastBuildDidChange')
connectTab: (tab) ->
# TODO: such implementation seems weird now, because we render
# in the renderTemplate function in routes
name = if tab == 'current' then 'build' else tab
@set('tab', tab)
urlGithub: (->
Travis.Urls.githubRepo(@get('repo.slug'))
).property('repo.slug')
setLineNumbers: (start, end) ->
lines = []
index = start
while index <= (end || start)
lines.push(index)
index++
@set('lineNumbers', lines)