Sha256: 8b5507c6c9a5f2714e925f0ef19266ce498b817310ba6e1a7db73c747e4f0d51

Contents?: true

Size: 940 Bytes

Versions: 8

Compression:

Stored size: 940 Bytes

Contents

ObserveJS.bind 'Post.Tags.Form', class
  loaded: =>
    @on 'input', @search
    @on 'submit', @send
    @on 'tags:index', @refresh
    @on 'tags:create', @append

    @element().querySelector('#TagName').focus()

  send: (e) =>
    e.preventDefault()
    e.stopPropagation()
    ObserveJS.XHR.send(@element())

  search: (e) =>
    xhr = new ObserveJS.XHR(@element())
    xhr.method = 'GET'
    xhr.data.set 'q', e.target.value
    xhr.send()

  append: (e) =>
    oid = e.HTML.getAttribute('oid')
    list = @element().nextElementSibling
    el = list.querySelector("[oid='#{oid}']")

    if el?
      el.parentElement.replaceChild(e.HTML, el)
      return

    el = list.querySelector('li.empty')
    if el?
      el.remove()
      list.appendChild(e.HTML)
      return
    
  refresh: (e) =>
    sibling = @element().nextElementSibling
    list = e.HTML.querySelector('ul.tags')
    @element().parentElement.replaceChild(list, sibling)

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ecrire-0.31.2 lib/ecrire/app/assets/javascripts/admin/posts/tags/form.coffee
ecrire-0.31.1 lib/ecrire/app/assets/javascripts/admin/posts/tags/form.coffee
ecrire-0.31.0 lib/ecrire/app/assets/javascripts/admin/posts/tags/form.coffee
ecrire-0.30.3 lib/ecrire/app/assets/javascripts/admin/posts/tags/form.coffee
ecrire-0.30.2 lib/ecrire/app/assets/javascripts/admin/posts/tags/form.coffee
ecrire-0.30.1 lib/ecrire/app/assets/javascripts/admin/posts/tags/form.coffee
ecrire-0.30.0 lib/ecrire/app/assets/javascripts/admin/posts/tags/form.coffee
ecrire-0.29.0 lib/ecrire/app/assets/javascripts/admin/posts/tags/form.coffee