Options
All
  • Public
  • Public/Protected
  • All
Menu

@vangware/window-open-promise

Index

Type aliases

WindowOpenPromiseFeatures

WindowOpenPromiseFeatures: Omit<WindowOpenPromiseOptions, "replace" | "target" | "url">

WindowOpenPromise features.

WindowOpenPromiseOptions

WindowOpenPromiseOptions: { height?: number; left?: number; menuBar?: boolean; noOpener?: boolean; resizable?: boolean; scrollbars?: boolean; target?: string; titleBar?: boolean; toolBar?: boolean; top?: number; url?: string; width?: number }

WindowOpenPromise options.

Type declaration

  • Optional Readonly height?: number

    WindowOpenPromise height (minimum 100).

  • Optional Readonly left?: number

    WindowOpenPromise left position.

  • Optional Readonly menuBar?: boolean

    WindowOpenPromise renders the menu bar.

  • Optional Readonly noOpener?: boolean

    WindowOpenPromise can't access it's opener.

  • Optional Readonly resizable?: boolean

    WindowOpenPromise is resizable.

  • Optional Readonly scrollbars?: boolean

    WindowOpenPromise has scrollbars.

  • Optional Readonly target?: string

    WindowOpenPromise target.

  • Optional Readonly titleBar?: boolean

    WindowOpenPromise renders the title bar.

  • Optional Readonly toolBar?: boolean

    WindowOpenPromise renders the tool bar.

  • Optional Readonly top?: number

    WindowOpenPromise top position.

  • Optional Readonly url?: string

    WindowOpenPromise url.

  • Optional Readonly width?: number

    WindowOpenPromise width (minimum 100).

Functions

Const featureParser

  • Parses features object into features string.

    example
    featureParser({
    top: 10,
    left: 10,
    resizable: true
    }); // "top=10,left=10,resizable=1"

    Parameters

    Returns string

    Parsed string.

Const windowOpenPromise

  • windowOpenPromise(window: Readonly<Pick<Window, "open">>): (__namedParameters?: WindowOpenPromiseOptions) => Promise<Window>
  • Promised Window.open.

    example
    const windowOpen = windowOpenPromise(window);
    windowOpen({
    url: "https://example.com",
    top: 10,
    left: 10
    })
    .then(newWindow => {
    newWindow.console.log("This will log in the new window.");
    newWindow.addEventListener("beforeunload", _event => {
    console.log("This will log when the new window is closed.");
    });
    })
    .catch(_error => {
    console.error("This will log if the new window can't be opened.");
    });

    Parameters

    • window: Readonly<Pick<Window, "open">>

      Window object (or maybe a mock :D).

    Returns (__namedParameters?: WindowOpenPromiseOptions) => Promise<Window>

    Curried function with window in context.