foundation-ui

AdaptTo Interface

type
foundation-ui
condition
window object
returned type
FoundationUI
interface FoundationUI {
  /**
   * Shows an alert dialog.
   *
   * @param title The title of the dialog
   * @param message The message to be displayed
   * @param type The type of alert. Valid values are "default", "error", "notice", "success", "help", "info".
   */
  alert(title: string, message: string, type = "default"): void;

  /**
   * Notifies the user.
   *
   * @param title The title of the notification. By default the value is autogenerated based on type.
   * @param message The message to be displayed
   * @param type The type of notification. Valid values are "error", "notice", "success", "help", "info".
   */
  notify(title?: string, message: string, type = "info"): void;

  /**
   * Shows a wait ticker.
   *
   * @param title The title of the dialog
   * @param message The ticker message to be displayed
   */
  waitTicker(title: string, message: string): FoundationUIWait;

  /**
   * Prompts the user.
   *
   * @param title The title of the dialog
   * @param message The message to be displayed
   * @param type The type of alert. Valid values are "default", "error", "notice", "success", "help", "info".
   * @param actions The actions available to the user
   * @param callback The callback. The <code>FoundationUIPromptAction.id</code> is passed as the parameter.
   */
  prompt(title: string, message: string, type = "default", actions: FoundationUIPromptAction[], callback?: (id: string, action: FoundationUIPromptAction) => void): void;

  /**
   * Shows a wait mask. The mask is a singleton, thus it can only cover maximum one element at a time.
   *
   * @param el The element to cover
   */
  wait(el = document.body): void;

  /**
   * Clears the wait mask.
   */
  clearWait(): void;
}

interface FoundationUIWait {
  /**
   * Updates the message (ticker string).
   */
  updateMessage(message: string): void;

  /**
   * Clears the wait ticker.
   */
  clear(): void;
}

interface FoundationUIPromptAction {
  /**
   * The id of this action.
   */
  id: string;

  /**
   * The text of this action.
   */
  text: string;

  /**
   * <code>true</code> to make this action as the primary action.
   */
  primary?: boolean;

  /**
   * <code>true</code> to make this action to have warning styling.
   */
  warning?: boolean;

  /**
   * The handler of this action.
   */
  handler?: (action: FoundationUIPromptAction) => void;
}