window.Alchemy = {} if typeof(window.Alchemy) is 'undefined'
Alchemy.FileProgress = (file) ->
# Build Wrapper
@$fileProgressWrapper = $('
')
# Build Container
@$fileProgressElement = $('')
# Append Cancel Button
@$fileProgressCancel = $('')
@$fileProgressElement.append @$fileProgressCancel
# Append Filename
@$fileProgressElement.append "" + file.name + "
"
# Append Progressbar Status Text
@$fileProgressStatus = $('
')
@$fileProgressElement.append @$fileProgressStatus
# Build Progressbar Container
$progressBarContainer = $('')
# Build Progressbar
@$progressBar = $('')
# Knit all together
$progressBarContainer.append @$progressBar
@$fileProgressElement.append $progressBarContainer
@$fileProgressWrapper.append @$fileProgressElement
$('.upload-progress-container').append @$fileProgressWrapper
this
Alchemy.FileProgress::reset = ->
@$fileProgressStatus.html ' '
@$progressBar.removeClass().addClass 'progress-bar-in-progress'
@$progressBar.css width: '0%'
Alchemy.FileProgress::setProgress = (percentage) ->
@$progressBar.removeClass().addClass 'progress-bar-in-progress'
@$progressBar.css width: percentage + '%'
Alchemy.FileProgress::setComplete = ->
@$progressBar.removeClass().addClass 'progress-bar-complete'
@$progressBar.css width: '100%'
@$fileProgressCancel.hide()
@$fileProgressWrapper.delay(1500).fadeOut ->
$(this).remove()
Alchemy.FileProgress::setError = ->
@$progressBar.removeClass().addClass 'progress-bar-error'
@$progressBar.css width: '100%'
Alchemy.FileProgress::setCancelled = ->
@$progressBar.removeClass().addClass 'progress-bar-canceled'
@$progressBar.css width: '100%'
@$fileProgressCancel.hide()
@$fileProgressWrapper.delay(1500).fadeOut ->
$(this).remove()
if $('.upload-progress-container').is(':empty')
$('.overall-upload').removeClass('visible')
return
Alchemy.FileProgress::setStatus = (status) ->
@$fileProgressStatus.text Alchemy.t(status)