Skip to main content

Window utilities

These utilities enable you to control interaction with the browser window and to ascertain the application's runtime environment, enhancing the adaptability and user experience of web applications.

Key features

  • Environment Checks: Functions to determine if the application is running inside an iframe or the Symphony desktop app, supporting conditional logic based on the execution context.
  • Pop-up Window Management: A utility for opening new browser windows with specific dimensions, useful for creating dialogues, authentication flows, or additional information displays.

Use cases

This module is ideal for:

  • Prototyping applications with lightweight data requirements.
  • Small-scale projects requiring a simple and quick database solution.
  • Scenarios where strong type safety and event-driven behavior are critical.

Examples

Checking for an iFrame environment

import { inIFrame } from '@genesislcap/foundation-utils';

if (inIFrame()) {
console.log('The application is running inside an iframe.');
}

Determining the Symphony Desktop app environment

import { inSymphonyDesktop } from '@genesislcap/foundation-utils';

if (inSymphonyDesktop()) {
console.log('Running within the Symphony desktop application.');
}

Opening a pop-up window

import { openPopup, POPUP_DEFAULT_WIDTH, POPUP_DEFAULT_HEIGHT } from '@genesislcap/foundation-utils';

const newWindow = openPopup(
'https://example.com',
'ExamplePopup',
POPUP_DEFAULT_WIDTH,
POPUP_DEFAULT_HEIGHT,
);

if (newWindow) {
console.log('Pop-up window opened successfully.');
}

Key points

  • Secure Contexts: Ensure that functionalities requiring secure contexts, like pop-up management, adhere to browser security policies and permissions.
  • User Experience Considerations: Use pop-up windows judiciously to avoid disrupting the user experience or running foul of browser pop-up blockers.
  • Environment-Sensitive Development: Use environment check utilities to tailor the application behaviour for specific contexts, ensuring a seamless user experience across different platforms.