Sha256: d06bb883a066d6e08e36f359ba06b8054f5fda5a5d1b481e846ee1fe6596d6d1

Contents?: true

Size: 1.07 KB

Versions: 73

Compression:

Stored size: 1.07 KB

Contents

(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 postMessage
      normalizedLink = document.createElement('a');
      normalizedLink.href = targetInfo.url;

      data = JSON.stringify({
        message: 'Shopify.API.remoteRedirect',
        data: {location: normalizedLink.href}
      });
      window.parent.postMessage(data, targetInfo.myshopifyUrl);
    }
  }

  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

73 entries across 73 versions & 1 rubygems

Version Path
shopify_app-18.0.3 app/assets/javascripts/shopify_app/redirect.js
shopify_app-18.0.2 app/assets/javascripts/shopify_app/redirect.js
shopify_app-18.0.1 app/assets/javascripts/shopify_app/redirect.js
shopify_app-18.0.0 app/assets/javascripts/shopify_app/redirect.js
shopify_app-17.2.1 app/assets/javascripts/shopify_app/redirect.js
shopify_app-17.2.0 app/assets/javascripts/shopify_app/redirect.js
shopify_app-17.1.1 app/assets/javascripts/shopify_app/redirect.js
shopify_app-17.1.0 app/assets/javascripts/shopify_app/redirect.js
shopify_app-17.0.5 app/assets/javascripts/shopify_app/redirect.js
shopify_app-17.0.4 app/assets/javascripts/shopify_app/redirect.js
shopify_app-17.0.3 app/assets/javascripts/shopify_app/redirect.js
shopify_app-17.0.2 app/assets/javascripts/shopify_app/redirect.js
shopify_app-17.0.1 app/assets/javascripts/shopify_app/redirect.js
shopify_app-17.0.0 app/assets/javascripts/shopify_app/redirect.js
shopify_app-16.1.0 app/assets/javascripts/shopify_app/redirect.js
shopify_app-16.0.0 app/assets/javascripts/shopify_app/redirect.js
shopify_app-15.0.1 app/assets/javascripts/shopify_app/redirect.js
shopify_app-15.0.0 app/assets/javascripts/shopify_app/redirect.js
shopify_app-14.4.4 app/assets/javascripts/shopify_app/redirect.js
shopify_app-14.4.3 app/assets/javascripts/shopify_app/redirect.js