/** * Types declaration for SsiModal * * SsiModal: * @url https://github.com/ssbeefeater/ssi-modal * @author ssbeefeater * * This d.ts file: * @author dragon-fish * * @license MIT */ declare class SsiModal { constructor(options: Partial) readonly backdropId: string readonly modalId: string readonly numberId: string public options: SsiModalOptions readonly pluginName: string close: () => void /** * Initialize the modal and backdrop and expose them to the DOM */ init: () => this /** * Changes the previe state (fullScreen) of the modal. */ changePreviewState: () => this /** * Generates a button according to the options. * @returns The button element. */ generateButton: ( buttonOptions: Partial ) => JQuery /** * Returns the backdrop element of the modal. * Or outer element if the modal is stack. */ get$backdrop: () => JQuery /** * Returns the buttons element of the modal. * @param type - 'left' or 'right'. If not specified, returns all buttons' container. */ get$buttons: (type?: 'left' | 'right') => JQuery /** * Returns the content element of the modal. */ get$content: () => JQuery /** * Returns the title icons of the modal. */ get$icons: () => JQuery /** * Returns the modal element of the modal. * @description returns the outer element of the modal (ie if we use stack modals will return the window object else will return the modalOuter) */ get$modal: () => JQuery /** * Returns the title element of the modal. */ get$title: () => JQuery /** * Returns the window element of the modal. */ get$window: () => JQuery /** * Returns the wrapper element of the modal. */ get$wrapper: () => JQuery /** * Initialize the buttons element if it is necessary, and add the buttons to the element. * @returns Buttons container element. */ setButtons: ( buttons: Partial[], area?: AnyJQueryElement, $modalWindow?: JQuery ) => JQuery /** * Initialize the content element if it is necessary and registers the content. * @param content The content of the element. * @param method The jquery method that will use to register the content to the modal. * @returns The content element of the modal. */ setContent: ( content: string | HTMLElement | JQuery, method?: 'html' | 'append' | 'prepend' = 'html' ) => JQuery setIcons: (icons: any) => void setModalHeight: ( offset: number, option?: 'height' | 'min-height' | 'max-height' ) => number setOptions: (options: Partial) => this setPluginName: (name: string) => this setTitle: (title: string | HTMLElement | JQuery) => void show: () => this // Static methods /** * Checks if the element is a ssi modal object. */ static checkElement: (element: AnyJQueryElement) => SsiModal | false /** * Creates a ssi modal object and shows it immediately. * @example ```js * ssi_modal.show({content:'Hello World'}) * ``` */ static show: (options: Partial) => SsiModal /** * Creates a ssi modal object but does not show it. * @example ```js * ssi_modal.createObject({content:'Hello World'}).init().show() * ``` */ static createObject: (options: Partial) => SsiModal /** * Closes the very top modal. If you pass a target parameter will close the modal you specified. */ static close: (modalId?: string) => SsiModal static closeAll: () => SsiModal /** * Remove all the modals from the dom immediately. No callbacks will execute. */ static removeAll: () => void static confirm: ( options: Partial, method: (event: MouseEvent, modal: SsiModal) => void ) => SsiModal // == Plugins == // dialog static dialog: ( options: Partial, method: (event: MouseEvent, modal: SsiModal) => void ) => SsiModal // confirm static confirm: ( options: Partial, method: (event: MouseEvent, modal: SsiModal) => void ) => SsiModal // notify static notify: ( type: 'success' | 'error' | 'warning' | 'info' | 'dialog' | 'confirm', options: Partial & Partial<{ icon: string okBtn: Pick cancelBtn: Pick overrideOther: boolean }>, callback: (result: boolean) => void ) => SsiModal } export interface SsiModalOptions { animation: SsiModalAnimation animationSpeed: number backdrop: boolean | ('shared' | 'byKindShared') backdropAnimation: SsiModalAnimation backdropClassName: string beforeClose: (modal: SsiModal) => void | false beforeShow: (modal: SsiModal) => void | false bodyElement: boolean bodyScroll: boolean buttons: Partial[] center: boolean className: string closeAfter: { time: number displayTime: number resetOnHover: boolean } closeIcon: boolean content: string | HTMLElement | JQuery fitScreen: boolean fixedHeight: boolean | number iconButtons: boolean iframe: unknown keepContent: boolean modalAnimation: SsiModalAnimation navigation: boolean onClickClose: boolean onClose: (modal: SsiModal) => void onShow: (modal: SsiModal) => void outSideClose: boolean position: | 'right top' | 'right bottom' | 'left top' | 'left bottom' | 'center top' | 'center bottom' preview: unknown sizeClass: SsiModalSizeClass stack: boolean title: AnyJQueryElement } export interface SsiModalButton { label: AnyJQueryElement type: 'button' | 'link' className: string enableAfter: number | false id: string method: (this: HTMLButtonElement, event: MouseEvent, modal: SsiModal) => void side: 'left' | 'right' keyPress: string closeAfter: number | false } export type SsiModalSizeClass = | 'dialog' | 'small' | 'smaillToMedium' | 'medium' | 'mediumToLarge' | 'large' | 'full' | 'auto' export type SsiModalAnimation = | string | { show: string | false hide: string | false } | false type AnyJQueryElement = string | HTMLElement | JQuery // Declare the global variable declare global { export const ssi_modal: typeof SsiModal export interface Window { ssi_modal: typeof SsiModal } }