Sha256: 31ea234ef548bed46e66e8f4876cb625654f3bccf2b6604a4e64c5dfa4a403e6

Contents?: true

Size: 462 Bytes

Versions: 17

Compression:

Stored size: 462 Bytes

Contents

ObserveJS.bind 'Post.Publish', class
  loaded: =>
    @on 'click', @toggle
    @on 'posts:toggle', @refresh

  toggle: (e) =>
    @element().setAttribute('published', !@isPublished())
    ObserveJS.XHR.send(@element())

  isPublished: =>
    @element().getAttribute('published') == 'true'

  refresh: (e) =>
    @element().setAttribute('published', e.State)

    if document.body.querySelector('main').classList.contains('titles')
      window.location.reload()

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
ecrire-0.31.2 lib/ecrire/app/assets/javascripts/admin/posts/toggle.coffee
ecrire-0.31.1 lib/ecrire/app/assets/javascripts/admin/posts/toggle.coffee
ecrire-0.31.0 lib/ecrire/app/assets/javascripts/admin/posts/toggle.coffee
ecrire-0.30.3 lib/ecrire/app/assets/javascripts/admin/posts/toggle.coffee
ecrire-0.30.2 lib/ecrire/app/assets/javascripts/admin/posts/toggle.coffee
ecrire-0.30.1 lib/ecrire/app/assets/javascripts/admin/posts/toggle.coffee
ecrire-0.30.0 lib/ecrire/app/assets/javascripts/admin/posts/toggle.coffee
ecrire-0.29.0 lib/ecrire/app/assets/javascripts/admin/posts/toggle.coffee
ecrire-0.28.3 lib/ecrire/app/assets/javascripts/admin/posts/toggle.js.coffee
ecrire-0.28.2 lib/ecrire/app/assets/javascripts/admin/posts/toggle.js.coffee
ecrire-0.28.1 lib/ecrire/app/assets/javascripts/admin/posts/toggle.js.coffee
ecrire-0.28.0 lib/ecrire/app/assets/javascripts/admin/posts/toggle.js.coffee
ecrire-0.27.0 lib/ecrire/app/assets/javascripts/admin/posts/toggle.js.coffee
ecrire-0.26.3 lib/ecrire/app/assets/javascripts/admin/posts/toggle.js.coffee
ecrire-0.26.2 lib/ecrire/app/assets/javascripts/admin/posts/toggle.js.coffee
ecrire-0.26.1 lib/ecrire/app/assets/javascripts/admin/posts/toggle.js.coffee
ecrire-0.26.0 lib/ecrire/app/assets/javascripts/admin/posts/toggle.js.coffee