 class PodsLoader
   delegate: null
   requests: []
+  running: 0
+  finished: 0
+  progress: ->
+    @finished / (@finished + @running)
   cancel: ->
     for request in @requests
       request.abort()
     @requests = []
+    @running = 0
+    @finished = 0
   loadPods: ->
     @cancel()
     for chunk in gon.pods_index

    @loader.loadPods()
    @progressBar.start()
  didLoad: (chunk_id, pods) ->
    @progressBar.update(chunk_id)
    @pods = @pods.concat(pods)
    if @delegate && @delegate.podsDidChange
      @delegate.podsDidChange()

# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
class @PodsProgressBar
  update: (factor) ->
    progress = factor * 100
    $('.progress-bar').css('width', progress + '%')
  start: ->
    $('.progress-container').hide().html($('.progress-tpl').html()).slideDown(1000)
