simpa
Version:
Lightweight library for prototyping Single Page Applications.
270 lines (269 loc) • 9.39 kB
TypeScript
/**
* Global flag indicating if the touch functionality is enabled.
*/
export declare const gvTouch: boolean;
/**
* Global type for UUID identifiers.
*/
type identifier = string;
/**
* Generates unique identifier.
*
* @return Unique an identifier in form of UUID.
*/
export declare function $uuid(): string;
/**
* Returns an HTML element with specified identifier or <em>mull</em>
* when such element was not found in the document.
*
* This function is a shorter version of calling:
* <pre>
* document.getElementById(id) as HTMLElement
* </pre>
*
* @param id Identifier of the HTML element in document.
* @return HTML element with specified identifier or null when not found in DOM.
*/
export declare function $id(id: identifier): HTMLElement | null;
/**
* Returns an HTML element with specified identifier cast to HTMLDivElement.
*
* This function is a shorter version of calling:
* <pre>
* document.getElementById(id) as HTMLDivElement
* </pre>
*
* @param id Identifier of HTML DIV element in document.
* @return HTML DIV element with specified identifier or null.
*/
export declare function $htmlDiv(id: identifier): HTMLDivElement | null;
/**
* Returns HTML element with specified identifier and casts to HTMLPreElement.
* This function is an equivalent of calling:
* <pre>
* document.getElementById(id) as HTMLPreElement
* </pre>
*
* @param id Identifier of HTML PRE element in document.
* @return HTML PRE element with specified identifier or null.
*/
export declare function $htmlPre(id: identifier): HTMLPreElement | null;
/**
* Returns HTML element with specified identifier and casts to HTMLImageElement.
* This function is an equivalent of calling:
* <pre>
* document.getElementById(id) as HTMLImageElement
* </pre>
*
* @param id Identifier of HTML IMG element in document.
* @return HTML IMG element with specified identifier or null.
*/
export declare function $htmlImage(id: identifier): HTMLImageElement | null;
/**
* Creates HTML element from specified HTML tag name.
*
* @return Newly created HTML element.
*/
export declare function $createElement(tag: string): HTMLElement;
/**
* Creates HTML DIV element.
*
* @return Newly created HTML DIV element.
*/
export declare function $createDiv(): HTMLDivElement;
/**
* Registers a 'touch' event for the element with specified identifier.
* This function always registers an 'mouseup' event handler,
* and for touch screens additionally registers an 'touchend' event handler.
*
* @param id Identifier of the element for which the event handler will be registered.
* @param h Event handler to be registered for the element with specified identifier.
*/
export declare function $touch(id: identifier, h: () => void): void;
/**
* Registers a 'touch' event for the specified element.
* This function always registers an 'mouseup' event handler,
* and for touch screens additionally registers an 'touchend' event handler.
*
* @param e Element for which the event handler will be registered.
* @param h Event handler to be registered for the specified element.
*/
export declare function $Touch(e: HTMLElement | null, h: () => void): void;
/**
*
*/
export declare function $handleInput(id: identifier, h: () => void): void;
/**
*
*/
export declare function $HandleInput(e: HTMLElement | null, h: () => void): void;
/**
*
*/
export declare function $handleMouseDown(id: identifier, h: (me: MouseEvent) => void): void;
/**
*
*/
export declare function $HandleMouseDown(e: HTMLElement | null, h: (me: MouseEvent) => void): void;
/**
*
*/
export declare function $handleMouseUp(id: identifier, h: () => void): void;
/**
*
*/
export declare function $HandleMouseUp(e: HTMLElement | null, h: (me: MouseEvent) => void): void;
/**
*
*/
export declare function $handleMouseMove(id: identifier, h: (me: MouseEvent) => void): void;
/**
*
*/
export declare function $HandleMouseMove(e: HTMLElement | null, h: (me: MouseEvent) => void): void;
/**
*
*/
export declare function $handleMouseLeave(id: identifier, h: (me: MouseEvent) => void): void;
/**
*
*/
export declare function $HandleMouseLeave(e: HTMLElement | null, h: (me: MouseEvent) => void): void;
/**
*
*/
export declare function $handleKeyDown(id: identifier, h: (ke: KeyboardEvent) => void): void;
/**
*
*/
export declare function $HandleKeyDown(e: HTMLElement | null, h: (ke: KeyboardEvent) => void): void;
/**
*
*/
export declare function $handleKeyUp(id: identifier, h: (event: KeyboardEvent) => void): void;
/**
*
*/
export declare function $HandleKeyUp(e: HTMLElement | null, h: (ke: KeyboardEvent) => void): void;
/**
* Executes the handler when the ENTER key was pressed.
*/
export declare function $handleKeyEnter(id: identifier, h: () => void): void;
/**
* Executes the handler when the ENTER key was pressed.
*/
export declare function $HandleKeyEnter(e: HTMLElement | null, h: () => void): void;
/**
* Executes the handler when the SPACE key was pressed.
*/
export declare function $handleKeySpace(id: identifier, h: () => void): void;
/**
* Executes the handler when the SPACE key was pressed.
*/
export declare function $HandleKeySpace(e: HTMLElement | null, h: () => void): void;
/**
* Registers the same handler for 'touch' event, ENTER key and SPACE key.
* This utility function simplifies registering handler for buttons,
* for which the touchend, mouseup, keyup events should be handled the same way.
*
* @param id Identifier of the element for which the event handler will be registered.
* @param h Event handler to be registered for the element with specified identifier.
*/
export declare function $touchEnterSpace(id: identifier, h: () => void): void;
/**
* Deletes all child nodes of specifier element.
*
* @param id Identifier of the element for which all child nodes will be deleted.
*/
export declare function $deleteChildren(id: identifier): void;
/**
* Deletes all child nodes of specifier element.
*
* @param e Element for which all child nodes will be deleted.
*/
export declare function $DeleteChildren(e: HTMLElement | null): void;
/**
*
* @param element
* @param value
*/
export declare function $SET_TEXT(element: Text, value: string): void;
/**
* Sets the focus on the element with specified identifier.
*
* @param id Identifier of the element that will gain a focus.
*/
export declare function $setFocus(id: identifier): void;
/**
* Sets the focus on the specified element.
*
* @param e HTML element that will gain a focus.
*/
export declare function $SetFocus(e: HTMLElement | null): void;
export declare function $APPEND_CHILD_TEXT(element: HTMLElement): Text;
export declare function $REPLACE(s: string, t: string, r: string): string;
export declare function $REPLACE_MD(s: string, t: string, r: string): string;
export declare function $displayBlock(id: identifier): void;
export declare function $DisplayBlock(e: HTMLElement | null): void;
export declare function $displayNone(id: identifier): void;
export declare function $DisplayNone(e: HTMLElement | null): void;
export declare function $displayFlex(id: identifier): void;
export declare function $DisplayFlex(e: HTMLElement | null): void;
export declare function $makeVisible(id: identifier, visible: boolean): void;
export declare function $visible(id: identifier): void;
export declare function $Visible(e: HTMLElement | null): void;
export declare function $hidden(id: identifier): void;
export declare function $Hidden(e: HTMLElement | null): void;
/**
*
*/
export declare function $innerHTML(id: identifier, html: string): void;
/**
*
*/
export declare function $InnerHTML(e: HTMLElement | null, html: string): void;
/**
* Sets the inner text of the element with specified identifier.
*
* @param id Identifier of the element for which the inner text will be set.
* @param text Text to be set as inner value of the element.
*/
export declare function $innerText(id: identifier, text: string): void;
/**
* Sets the inner text of the specified element.
*
* @param e HTML element for which the inner text will be set.
* @param text Text to be set as inner value of the element.
*/
export declare function $InnerText(e: HTMLElement | null, text: string): void;
/**
* Adds a class name to the list of classes of the element with specified identifier.
*
* @param id Identifier of the element.
* @param className Name of the class to be added.
*/
export declare function $addClassName(id: identifier, className: string): void;
/**
* Adds a class name to the list of classes of the specified element.
*
* @param e Element to which the class name will be added.
* @param className Name of the class to be added.
*/
export declare function $AddClassName(e: HTMLElement | null, className: string): void;
export declare function $removeClassName(id: identifier, className: string): void;
export declare function $RemoveClassName(e: HTMLElement | null, className: string): void;
/**
* Converts the input string with Markdown formatting into HTML.
*
* @param s Markdown string.
* @return HTML string.
*/
export declare function $md(s: string): string;
/**
* Parses an integer value from string.
*
* @param s String to be parsed as integer value.
* @param def Default value when the number can not be parsed properly.
*/
export declare function $parseInt(s: string | null | undefined, def: number): number;
export {};