/** * Represents a very simple DOM API for Veams-JS (incl. ajax support) * * @module VeamsQuery * @version v3.0.5 * * Polyfills: npm install promise-polyfill --save-exact * * @author Andy Gutsche */ import { AjaxOpts, Offset } from "./veams-query.m"; export declare class VeamsQueryObject { [key: number]: any; length: number; type: string; /** * VeamsQuery DOM wrapper object * * @param {String | VeamsQueryObject | HTMLElement} selector - selector (string, VeamsQueryObject, HTMLElement) * @param {VeamsQueryObject | HTMLElement} [context = null] - context (VeamsQueryObject, HTMLElement) */ constructor(selector: any, context?: any); /** * Get the descendants of each element in the current set of matched elements, filtered by a selector, * VeamsQueryObject, or element * * @param {string|VeamsQueryObject|HTMLElement} selector - Selector (string, VeamsQueryObject, HTMLElement) * @return {VeamsQueryObject} - VeamsQueryObject */ find(selector: string | VeamsQueryObject | HTMLElement): VeamsQueryObject; /** * For each element in the set, get the first element that matches the selector by testing * the element itself and traversing up through its ancestors in the DOM tree * * @param {string} selector - Selector * @return {VeamsQueryObject} - VeamsQueryObject */ closest(selector: string): VeamsQueryObject; /** * Create a new VeamsQueryObject with elements added to the set of matched elements. * * @param {string | HTMLElement | VeamsQueryObject} selector - Selector, HTMLElement or VeamsQueryObject * @return {VeamsQueryObject} - VeamsQueryObject */ add(selector: string | HTMLElement | VeamsQueryObject): VeamsQueryObject; /** * Check if element has given class * * @param {string} className - Name of class to check * @return {boolean} - Element has class (true/false) */ hasClass(className: string): boolean; /** * Check the current matched set of elements against a selector, element, or VeamsQueryObject and return true if * at least one of these elements matches the given arguments * * @param {string} selector - A string containing a selector expression to match elements against * @return {boolean} - At least one element matches selector (true/false) */ is(selector: string): boolean; /** * Add the specified class(es) to each element in the set of matched elements. * * @param {string} classNames - Name(s) of class(es) to add * @return {VeamsQueryObject} - VeamsQueryObject */ addClass(classNames: string): VeamsQueryObject; /** * Remove a single class, multiple classes, or all classes from each element in the set of matched elements * * @param {string} [classNames] - Name(s) of class(es) to remove * @return {VeamsQueryObject} - VeamsQueryObject */ removeClass(classNames?: string): VeamsQueryObject; /** * Get the HTML contents of the first element in the set of matched elements * Set the HTML contents of each element in the set of matched elements * * @param {string|VeamsQueryObject|HTMLElement} [element] - HTML string | VeamsQueryObject | element * @return {string|VeamsQueryObject} - HTML contents | VeamsQueryObject */ html(element?: string | VeamsQueryObject | HTMLElement): string | VeamsQueryObject; /** * Insert content, specified by the parameter, to the end of each element in the set of matched elements * * @param {string|VeamsQueryObject|HTMLElement} element - HTML string | VeamsQueryObject | element * @return {VeamsQueryObject} - VeamsQueryObject */ append(element: string | VeamsQueryObject | HTMLElement): VeamsQueryObject; /** * Insert content, specified by the parameter, to the beginning of each element in the set of matched elements * * @param {string|VeamsQueryObject|HTMLElement} element - HTML string | VeamsQueryObject | element * @return {VeamsQueryObject} - VeamsQueryObject */ prepend(element: string | VeamsQueryObject | HTMLElement): VeamsQueryObject; /** * Insert content, specified by the parameter, before each element in the set of matched elements * * @param {string|VeamsQueryObject|HTMLElement} element - HTML string | VeamsQueryObject | element * @return {VeamsQueryObject} - VeamsQueryObject */ before(element: string | VeamsQueryObject | HTMLElement): VeamsQueryObject; /** * Insert content, specified by the parameter, after each element in the set of matched elements * * @param {string|VeamsQueryObject|HTMLElement} element - HTML string | VeamsQueryObject | element * @return {VeamsQueryObject} - VeamsQueryObject */ after(element: string | VeamsQueryObject | HTMLElement): VeamsQueryObject; /** * Remove the set of matched elements from the DOM * * @return {VeamsQueryObject} - VeamsQueryObject */ remove(): VeamsQueryObject; /** * Remove all child nodes of the set of matched elements from the DOM * * @return {VeamsQueryObject} - VeamsQueryObject */ empty(): VeamsQueryObject; /** * Reduce the set of matched elements to the one at the specified index * * @param {number} index - Index of element in node list * @return {VeamsQueryObject} - VeamsQueryObject containing node at given index of original node list */ eq(index: number): VeamsQueryObject; /** * Get the value of an attribute for the first element in the set of matched elements * Set value of an attribute for the set of matched elements * * @param {string} attrName - Attribute name * @param {string|number|boolean} [attrVal] - Attribute value * @return {string|number|boolean|VeamsQueryObject} - Attribute value | VeamsQueryObject */ attr(attrName: string, attrVal?: string | number | boolean): string | number | boolean | VeamsQueryObject; /** * Remove an attribute from each element in the set of matched elements * * @param {string} attrName - attribute name * @return {VeamsQueryObject} - VeamsQueryObject */ removeAttr(attrName: string): VeamsQueryObject; /** * Get the combined text contents of each element in the set of matched elements. * Set the content of each element in the set of matched elements to the specified text * * @param {string} [text] - text * @return {string|VeamsQueryObject} - Text | VeamsQueryObject */ text(text?: string): string | VeamsQueryObject; /** * Get the computed style properties for the first element in the set of matched elements. * Set the content of each element in the set of matched elements to the specified text * * @param {string|Object} cssProp - CSS property or property/value object * @param {string|number} [cssVal] - CSS value * @return {string|Object} - CSS value | VeamsQueryObject */ css(cssProp: string | object, cssVal?: string | number): string | VeamsQueryObject; /** * Get the current computed height for the first element in the set of matched elements, including padding, * border and optionally margin * * @param {boolean} [includeMargin=false] - Include the element's margin in the calculation (true/false) * @return {number} - Height */ outerHeight(includeMargin?: boolean): number; /** * Get the current computed width for the first element in the set of matched elements, including padding, * border and optionally margin * * @param {boolean} [includeMargin=false] - Include the element's margin in the calculation (true/false) * @return {number} - Width */ outerWidth(includeMargin?: boolean): number; /** * Get the current coordinates of the first element in the set of matched elements, * relative to the document * * @return {Offset} - offset (offset.top, offset.left) */ offset(): Offset; /** * Create a deep copy of the first element in the set of matched elements (without data and events) * * @param {Boolean} [withChildren=false] - Clone with children (true/false) * @return {VeamsQueryObject} - Clone of DOM node */ clone(withChildren?: boolean): VeamsQueryObject; /** * Return an integer indicating the position of the first element in the set of matched elements relative * to its sibling elements * * @return {number} - Index of element among its siblings */ index(): number; /** * Get the value of a property for the first element in the set of matched elements * Set value of a property for the set of matched elements * * @param {string} propName - Property name * @param {string|number|boolean} [propVal] - Property value * @return {string|number|boolean|VeamsQueryObject} - Property value | VeamsQueryObject */ prop(propName: string, propVal?: string | number | boolean): string | number | boolean | VeamsQueryObject; /** * Get the current value of the first element in the set of matched elements. * Set the value of each element in the set of matched elements * * @param {string | number} [val] - Value * @return {string|number|Array|VeamsQueryObject} - value | VeamsQueryObject */ val(val?: string | number): string | number | string[] | VeamsQueryObject; /** * Encode a set of form elements as a string for submission. * * @return {string} - Serialized form data */ serialize(): string; /** * Iterate over a VeamsQueryObject, executing a function for each matched element. * * @param {Function} fn - Callback function * @return {VeamsQueryObject} - VeamsQueryObject */ each(fn: (index: number, element: HTMLElement) => void): VeamsQueryObject; /** * Attach an event handler function for one or more events to the selected elements * * @param {string} eventNames - Name(s) of event(s) to be registered for matched set of elements * @param {string} [selector] - Selector string to filter descendants of selected elements triggering the event * @param {Function} handler - Event handler function * @param {boolean} [useCapture] - Dispatch event to registered listeners before dispatching it to event target * @return {VeamsQueryObject} - VeamsQueryObject */ on(eventNames: string, selector?: string, handler?: Function, useCapture?: boolean): VeamsQueryObject; /** * Detach an event handler for one or more events from the selected elements * * @param {string} eventNames - Name(s) of event(s) to be unregistered for matched set of elements * @param {string} [selector] - Selector string to filter descendants of selected elements triggering the event * @param {Function} [handler] - Event handler * @return {VeamsQueryObject} - VeamsQueryObject */ off(eventNames: string, selector?: string, handler?: Function): VeamsQueryObject; /** * Execute all handlers and behaviors attached to the matched elements for the given event type * * @param {string} eventNames - name(s) of event(s) which will be trigger on the set of matched elements * @param {CustomEventInit} [customEventInit] - custom event init object * @return {VeamsQueryObject} - VeamsQueryObject */ trigger(eventNames: string, customEventInit?: object): VeamsQueryObject; } /** * VeamsQuery Interface */ export interface IVeamsQuery { (selector?: string | VeamsQueryObject | HTMLElement, context?: any): any; ajax(opts: AjaxOpts): Promise; parseHTML(htmlString: string): Node; version: string; } /** * VeamsQuery selector function * * @param {string | VeamsQueryObject | HTMLElement} selector - selector (string, VeamsQueryObject, HTMLElement) * @param {VeamsQueryObject | HTMLElement} [context = null] - context (VeamsQueryObject, HTMLElement) * @return {VeamsQueryObject} */ declare const VeamsQuery: IVeamsQuery; export default VeamsQuery;