Sha256: 30309c7db3a4b41aee6f8700c09aa5018607d75a6e7bbc251879ca40cef91603

Contents?: true

Size: 1.18 KB

Versions: 42

Compression:

Stored size: 1.18 KB

Contents

class PostEditLocking
  constructor: ->
    @status_uri = window.post_edit_status_uri
    @interval = window.post_status_interval
    @editor_id = window.post_editor_id
    @user_id = window.user_id

    @was_editor = (@editor_id == @user_id)

    # if the current user is NOT the locker of the post,
    # we want him to poll at a less frequent interval
    # to give the locker space in the case that
    # they have a momentary network hiccup and can't lock
    # on first attempt
    if !@was_editor
      @interval += window.post_status_grace

    setInterval @push_status, @interval

  push_status: =>
    # attempt lock...
    $.post @status_uri, (response) =>
      if !@was_editor && response.edit_lock_succeeded
        if confirm "#{response.editor_byline} has finished editing this post. Click OK to refresh this page and view the updated post content."
          window.location.reload()

        @was_editor = true

      # ensure lock message is always shown when another user locks the post
      if response.editor_is_self != true
        $(".editing-user-name").html(response.editor_byline)
        $("#post-locked-message").removeClass("hidden")


window.PostEditLocking = PostEditLocking

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
virgo-0.3.17 app/assets/javascripts/virgo/admin/posts/edit_locking.coffee
virgo-0.3.16 app/assets/javascripts/virgo/admin/posts/edit_locking.coffee
virgo-0.3.15 app/assets/javascripts/virgo/admin/posts/edit_locking.coffee
virgo-0.3.14 app/assets/javascripts/virgo/admin/posts/edit_locking.coffee
virgo-0.3.13 app/assets/javascripts/virgo/admin/posts/edit_locking.coffee
virgo-0.3.12 app/assets/javascripts/virgo/admin/posts/edit_locking.coffee
virgo-0.3.11 app/assets/javascripts/virgo/admin/posts/edit_locking.coffee
virgo-0.3.10 app/assets/javascripts/virgo/admin/posts/edit_locking.coffee
virgo-0.3.9 app/assets/javascripts/virgo/admin/posts/edit_locking.coffee
virgo-0.3.8 app/assets/javascripts/virgo/admin/posts/edit_locking.coffee
virgo-0.3.7 app/assets/javascripts/virgo/admin/posts/edit_locking.coffee
virgo-0.3.6 app/assets/javascripts/virgo/admin/posts/edit_locking.coffee
virgo-0.3.4 app/assets/javascripts/virgo/admin/posts/edit_locking.coffee
virgo-0.3.3 app/assets/javascripts/virgo/admin/posts/edit_locking.coffee
virgo-0.3.2 app/assets/javascripts/virgo/admin/posts/edit_locking.coffee
virgo-0.3.1 app/assets/javascripts/virgo/admin/posts/edit_locking.coffee
virgo-0.3 app/assets/javascripts/virgo/admin/posts/edit_locking.coffee
virgo-0.2.9 app/assets/javascripts/virgo/admin/posts/edit_locking.coffee
virgo-0.2.8 app/assets/javascripts/virgo/admin/posts/edit_locking.coffee
virgo-0.2.7 app/assets/javascripts/virgo/admin/posts/edit_locking.coffee