Sha256: 3b776a4d96cfaeff543aefdec5457114b046d80e589ffc796fd9cf365a75c44f

Contents?: true

Size: 1.27 KB

Versions: 58

Compression:

Stored size: 1.27 KB

Contents

# Monkey patch Turbolinks to render 401
# See https://github.com/turbolinks/turbolinks/issues/179
#     https://github.com/samvera/hyrax/issues/617
if Turbolinks?
  Turbolinks.HttpRequest.prototype.requestLoaded = ->
    @endRequest =>
      if 200 <= @xhr.status < 300 or @xhr.status == 401
        @delegate.requestCompletedWithResponse(@xhr.responseText, @xhr.getResponseHeader("Turbolinks-Location"))
      else
        @failed = true
        @delegate.requestFailedWithStatusCode(@xhr.status, @xhr.responseText)

  # Fixes a back/forward navigation problem with UV and turbolinks
  # See https://github.com/samvera/hyrax/issues/2964
  # This is based on https://github.com/turbolinks/turbolinks/issues/219#issuecomment-275838923
  $(window).on 'popstate', (event) =>
    @turbolinks_location = Turbolinks.Location.wrap(window.location)
    return if Turbolinks.controller.location.requestURL == @turbolinks_location.requestURL
    return if event.state?.turbolinks
    if @window_turbolinks = window.history.state?.turbolinks
      Turbolinks.controller.historyPoppedToLocationWithRestorationIdentifier(@turbolinks_location, @window_turbolinks.restorationIdentifier)
    else
      Turbolinks.controller.historyPoppedToLocationWithRestorationIdentifier(@turbolinks_location, Turbolinks.uuid())

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
hyrax-2.9.5 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-3.0.2 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-3.0.1 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-3.0.0 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-3.0.0.pre.rc4 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-2.9.4 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-3.0.0.pre.rc3 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-2.9.3 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-2.9.2 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-2.9.1 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-2.9.0 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-3.0.0.pre.rc2 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-2.8.0 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-2.7.2 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-2.7.1 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-2.7.0 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-2.6.0 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-3.0.0.pre.rc1 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-3.0.0.pre.beta3 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-2.5.1 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee