Sha256: e0552382e39d31871fdac566d3779b6d34abee2cb07f5464e907019dfdc38bfd

Contents?: true

Size: 1005 Bytes

Versions: 3

Compression:

Stored size: 1005 Bytes

Contents

Joint.bind 'Editor.Draft', class
  resetInterval: 4000
  loaded: =>
    @on 'Editor:updated', document, @update
    @on 'change', @element().querySelector('input[type=checkbox]'), @toggle

  toggle: (e) =>
    if e.target.checked
      @show()
    else
      @hide()

  show: =>
    el = @element().firstElementChild
    el.style.marginLeft = "-#{el.getBoundingClientRect().width}px"
    el.style.opacity = 0
    @element().querySelector('form.destroy').classList.remove('hide')
    @timerID = setTimeout @reset, @resetInterval

  hide: =>
    if @timerID?
      clearTimeout(@timerID)
      @timerID = null

    el = @element().firstElementChild
    el.style.marginLeft = ''
    el.style.opacity = 1
    @element().querySelector('form.destroy').classList.add('hide')


  reset: =>
    checkbox = @element().querySelector('input[type=checkbox]')
    if checkbox.checked
      checkbox.checked = false
      @hide()

  update: (e) =>
    unless @cached?
      @cached = e.target.textContent
      return


Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ecrire-0.22.1 lib/ecrire/app/assets/javascripts/admin/editor/navigation/draft.js.coffee
ecrire-0.21.0 lib/ecrire/app/assets/javascripts/admin/editor/navigation/draft.js.coffee
ecrire-0.20.0 lib/ecrire/app/assets/javascripts/admin/editor/navigation/draft.js.coffee