Sha256: 08e47640602fe988577519ef27f3ac06c0172d4db32c8209f6b9de656538e463

Contents?: true

Size: 1.34 KB

Versions: 9

Compression:

Stored size: 1.34 KB

Contents

ObserveJS.bind 'Posts.Filter.Tags', class
  loaded: =>
    @on 'tags:index', @show
    @on 'click', @action
    @element().appendChild(@retrieve('svg.placeholder'))

  show: (e) =>
    document.body.appendChild(e.HTML)
    @on 'click', e.HTML, @select

  select: (e) =>
    el = e.target
    while el && !(el instanceof HTMLLIElement)
      el = el.parentElement

    return unless el?

    span = @retrieve('span.tag')
    span.textContent = el.textContent
    @retrieve('svg.placeholder').remove()
    @element().appendChild(span)
    @element().appendChild(@retrieve('svg.clear'))
    @element().setAttribute('tid', el.getAttribute('oid'))
    @element().classList.add 'tagged'
    document.querySelector("[as='Overlay']").instance.remove()
    document.querySelector("[as='Posts.Filter']").instance.search()
    document.querySelector("[as='Posts.Filter'] input.search").focus()

  action: =>
    if @element().classList.contains('tagged')
      @retrieve('svg.clear').remove()
      @retrieve('span.tag').remove()
      @element().appendChild(@retrieve('svg.placeholder'))
      @element().classList.remove('tagged')
      @element().removeAttribute('tid')
    else
      xhr = new ObserveJS.XHR(@element())
      xhr.send()
    document.querySelector("[as='Posts.Filter']").instance.search()
    document.querySelector("[as='Posts.Filter'] input.search").focus()

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ecrire-0.28.3 lib/ecrire/app/assets/javascripts/admin/posts/filters/tags.js.coffee
ecrire-0.28.2 lib/ecrire/app/assets/javascripts/admin/posts/filters/tags.js.coffee
ecrire-0.28.1 lib/ecrire/app/assets/javascripts/admin/posts/filters/tags.js.coffee
ecrire-0.28.0 lib/ecrire/app/assets/javascripts/admin/posts/filters/tags.js.coffee
ecrire-0.27.0 lib/ecrire/app/assets/javascripts/admin/posts/filters/tags.js.coffee
ecrire-0.26.3 lib/ecrire/app/assets/javascripts/admin/posts/filters/tags.js.coffee
ecrire-0.26.2 lib/ecrire/app/assets/javascripts/admin/posts/filters/tags.js.coffee
ecrire-0.26.1 lib/ecrire/app/assets/javascripts/admin/posts/filters/tags.js.coffee
ecrire-0.26.0 lib/ecrire/app/assets/javascripts/admin/posts/filters/tags.js.coffee