Sha256: e4c06e4487683eadd2fdb3e74b2ddf231c9fd2a79931310743ce8204ce552b7e

Contents?: true

Size: 894 Bytes

Versions: 1

Compression:

Stored size: 894 Bytes

Contents

//= require ./app_bridge_redirect.js

(function() {
  function redirect() {
    var redirectTargetElement = document.getElementById("redirection-target");

    if (!redirectTargetElement) {
      return;
    }

    var targetInfo = JSON.parse(redirectTargetElement.dataset.target)

    if (window.top == window.self) {
      // If the current window is the 'parent', change the URL by setting location.href
      window.top.location.href = targetInfo.url;
    } else {
      // If the current window is the 'child', change the parent's URL with App Bridge Redirect
      window.appBridgeRedirect(targetInfo.url);
    }
  }

  document.addEventListener("DOMContentLoaded", redirect);

  // In the turbolinks context, neither DOMContentLoaded nor turbolinks:load
  // consistently fires. This ensures that we at least attempt to fire in the
  // turbolinks situation as well.
  redirect();
})();

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shopify_app-14.1.0 app/assets/javascripts/shopify_app/redirect.js