lib/ecrire/app/assets/javascripts/admin/posts/header.coffee in ecrire-0.30.3 vs lib/ecrire/app/assets/javascripts/admin/posts/header.coffee in ecrire-0.31.0
- old
+ new
@@ -5,16 +5,16 @@
@on 'change', @element().querySelector('input[type=file]'), @submit
@on 'dragover', @over
@on 'dragleave', @cancel
@on 'drop', @drop
- @on 'ObserveJS:XHR:Failed', @failed
+ @when 'ObserveJS:XHR:Failed', @failed
@on 'images:create', @refresh
@on 'images:destroy', @refresh
- @on 'scroll', window, @resize
+ @when 'scroll', @resize
@maxHeight = parseFloat(window.getComputedStyle(this.element())['height'])
@resize()
@@ -53,35 +53,36 @@
e.y <= rect.top
progress: (e) =>
return unless e.lengthComputable
percentComplete = e.loaded / e.total * 100.0;
- progressBar = @retrieve('div.status.uploading').querySelector('.progressbar')
+ progressBar = @element().querySelector('div.status.uploading .progressbar')
progressBar.firstElementChild.style.width = "#{percentComplete}%";
failed: (e) =>
errors = JSON.parse(e.response.target.responseText)
- @hide(@retrieve('div.status.uploading'))
- @show(@retrieve('div.error.status'))
- ul = @retrieve('div.error.status').querySelector('ul')
- @on 'click', @retrieve('div.error.status').querySelector('button'), @clear
+ @hide(@template('div.status.uploading'))
+ @show(@template('div.error.status'))
+ ul = @template('div.error.status').querySelector('ul')
+ @on 'click', @template('div.error.status').querySelector('button'), @clear
for error in errors
ul.insertAdjacentHTML('beforeend', "<li>#{error}</li>")
open: (e) =>
@element().querySelector('input[type=file]').click()
remove: (e) =>
xhr = new ObserveJS.XHR(e.currentTarget)
xhr.request.upload.onprogress = @progress
xhr.send()
+ @show(@template('div.status.uploading'))
over: (e) =>
e.preventDefault()
if !@element().classList.contains('image')
@element().classList.add 'image'
- @show(@retrieve('div.dropping.status'))
+ @show(@template('div.dropping.status'))
cancel: (e) =>
e.preventDefault()
rect = @element().getBoundingClientRect()
if @outside(e, rect)
@@ -100,22 +101,22 @@
upload: (file) =>
if !@element().classList.contains('image')
@element().classList.add 'image'
- @show(@retrieve('div.status.uploading'))
- @retrieve('div.status.uploading').querySelector('.progressbar > span').style.width = '0%';
+ @show(@template('div.status.uploading'))
+ @template('div.status.uploading').querySelector('.progressbar > span').style.width = '0%';
xhr = new ObserveJS.XHR(@element())
xhr.data.set 'image[file]', file
xhr.request.upload.onprogress = @progress
xhr.send()
loading: =>
- @element().firstElementChild.appendChild(@retrieve('div.status.uploading'))
+ @element().firstElementChild.appendChild(@template('div.status.uploading'))
clear: (e) =>
@element().classList.remove 'image'
- for li in @retrieve('div.error.status').querySelectorAll('li')
+ for li in @template('div.error.status').querySelectorAll('li')
li.remove()
for status of @statuses
@statuses[status].classList.add 'hidden'