How to use the cross-domain-utils/src.getTop function in cross-domain-utils

To help you get started, we’ve selected a few cross-domain-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github paypal / paypal-checkout-components / src / interface / hacks.js View on Github external
/* @flow */

import { getLogger } from 'paypal-braintree-web-client/src';
import { getParent, getTop } from 'cross-domain-utils/src';
import { patchMethod } from 'belter/src';

import { Checkout } from '../checkout';

const parent = getParent(window);
const top = getTop(window);

if (top && parent) {
    let canRenderTop = (top === parent);

    if (!canRenderTop) {
        Checkout.canRenderTo(top).then(result => {
            canRenderTop = result;
        });

        patchMethod(Checkout, 'renderTo', ({ args: [ win, props, el ], original, context }) => {

            if (!canRenderTop) {
                win = getParent(window);
            }

            return original.call(context, win, props, el);
github paypal / paypal-checkout-components / src / hacks.js View on Github external
checkout.openContainer().then(() => {
            checkout.event.triggerOnce(CONSTANTS.EVENTS.CLOSE);
            checkout.showContainer();
        });

        // $FlowFixMe
        Button.xprops.payment().then(token => {
            window.top.location = extendUrl(config.checkoutUrl, { token });
        }).catch(err => {
            checkout.error(err);
        });
    };
}

const parent = getParent(window);
const top = getTop(window);

if (top && parent) {
    let canRenderTop = (top === parent);

    if (!canRenderTop) {
        Checkout.canRenderTo(top).then(result => {
            canRenderTop = result;
        });

        patchMethod(Checkout, 'renderTo', ({ args: [ win, props, el ], original, context }) => {

            if (!canRenderTop) {
                win = getParent(window);
            }

            return original.call(context, win, props, el);
github krakenjs / zoid / dist / module / component / child / index.js View on Github external
ChildComponent.prototype.getWindowByRef = function getWindowByRef(ref) {
        var type = ref.type;

        var result = void 0;

        if (type === WINDOW_REFERENCES.OPENER) {
            result = getOpener(window);
        } else if (type === WINDOW_REFERENCES.TOP) {
            result = getTop(window);
        } else if (type === WINDOW_REFERENCES.PARENT) {
            // $FlowFixMe
            var distance = ref.distance;


            if (distance) {
                result = getNthParentFromTop(window, distance);
            } else {
                result = getParent(window);
            }
        }

        if (type === WINDOW_REFERENCES.GLOBAL) {
            // $FlowFixMe
            var uid = ref.uid;
github paypal / paypal-smart-payment-buttons / src / payment-flows / checkout.js View on Github external
function setupCheckout({ components } : { components : Components }) : ZalgoPromise {
    const { Checkout } = components;

    checkoutOpen = false;

    const [ parent, top ] = [ getParent(window), getTop(window) ];

    const tasks = {};

    if (top && parent && parent !== top) {
        tasks.canRenderTo = Checkout.canRenderTo(top).then(result => {
            canRenderTop = result;
        });
    }

    return ZalgoPromise.hash(tasks).then(noop);
}
github paypal / paypal-smart-payment-buttons / src / payment-flows / checkout.js View on Github external
function getRenderWindow() : Object {
    const top = getTop(window);
    if (canRenderTop && top) {
        return top;
    } else if (getParent()) {
        return getParent();
    } else {
        return window;
    }
}
github paypal / paypal-smart-payment-buttons / src / flows / checkout.js View on Github external
function getRenderWindow() : Object {
    const top = getTop(window);
    if (canRenderTop && top) {
        return top;
    } else {
        return window.xprops.getParent();
    }
}
github paypal / paypal-smart-payment-buttons / src / flows / checkout.js View on Github external
export function setupCheckout() : ZalgoPromise {
    checkoutOpen = false;

    const [ parent, top ] = [ getParent(window), getTop(window) ];

    const tasks = {};

    if (top && parent && parent !== top) {
        tasks.canRenderTo = window.paypal.Checkout.canRenderTo(top).then(result => {
            canRenderTop = result;
        });
    }

    return ZalgoPromise.hash(tasks).then(noop);
}