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-5.0.1 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-5.0.0 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-5.0.0.rc3 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-5.0.0.rc2 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-5.0.0.rc1 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-3.6.0 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-4.0.0 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-4.0.0.rc3 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-4.0.0.rc2 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-4.0.0.rc1 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-3.5.0 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-4.0.0.beta2 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-3.4.2 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-4.0.0.beta1 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-3.4.1 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-3.4.0 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-3.3.0 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-3.2.0 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-2.9.6 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee
hyrax-3.1.0 app/assets/javascripts/hyrax/monkey_patch_turbolinks.js.coffee