@base-framework/base
Version:
This is a javascript framework.
273 lines (272 loc) • 7.46 kB
TypeScript
/**
* Dom
*
* This will contain methods for working with the dom.
*
* @module
* @name Dom
*/
export class Dom {
/**
* This will select an element by id.
*
* @param {string} id
* @returns {object|boolean} The element object or false.
*/
static getById(id: string): object | boolean;
/**
* This will select elements by name.
*
* @param {string} name
* @returns {object|boolean} The elements array or false.
*/
static getByName(name: string): object | boolean;
/**
* This will select by css selector.
*
* @param {string} selector
* @param {boolean} single Set to true if you only want one result.
* @returns {*}
*/
static getBySelector(selector: string, single: boolean): any;
/**
* This will get or set the innerHTML or an element.
*
* @param {object} obj
* @param {string} [html] If the html is not set, the html of the
* element will be returned.
*
* @returns {*}
*/
static html(obj: object, html?: string): any;
/**
* This will set the css property of an element.
*
* @param {object} obj
* @param {string} property
* @param {string} value
* @returns {object} an instance of base.
*/
static setCss(obj: object, property: string, value: string): object;
/**
* This will get the css property of an element.
*
* @param {object} obj
* @param {string} property
* @returns {*}
*/
static getCss(obj: object, property: string): any;
/**
* This will get or set the css propety or an element.
*
* @param {object} obj
* @param {string} property
* @param {string} [value]
* @returns {*}
*/
static css(obj: object, property: string, value?: string): any;
/**
* This will remove an attribute from an element.
*
* @param {object} obj
* @param {string} property
* @returns {object} an instance of base.
*/
static removeAttr(obj: object, property: string): object;
/**
* This will set an attribute of an element.
*
* @param {object} obj
* @param {string} property
* @param {string} value
* @returns {void}
*/
static setAttr(obj: object, property: string, value: string): void;
/**
* This will get an attribute of an element.
*
* @param {object} obj
* @param {string} property
* @returns {string}
*/
static getAttr(obj: object, property: string): string;
/**
* This will get or set an attribute from an element.
*
* @param {object} obj
* @param {string} property
* @param {string} [value]
* @returns {*}
*/
static attr(obj: object, property: string, value?: string): any;
/**
* This will prefix a string with "data-" if not set.
*
* @protected
* @param {string} prop
* @returns {string}
*/
protected static _checkDataPrefix(prop: string): string;
/**
* This will remove "data-" from a string.
*
* @protected
* @param {string} prop
* @returns {string}
*/
protected static removeDataPrefix(prop: string): string;
/**
* This will set data to an element.
*
* @param {object} obj
* @param {string} property
* @param {string} value
*/
static setData(obj: object, property: string, value: string): void;
/**
* This will get data from an element.
*
* @param {object} obj
* @param {string} property
* @returns {string}
*/
static getData(obj: object, property: string): string;
/**
* This will get or set data to an element.
*
* @param {object} obj
* @param {string} property
* @param {string} [value]
* @returns {*}
*/
static data(obj: object, property: string, value?: string): any;
/**
* This will find elements in an element.
*
* @param {object} obj
* @param {string} queryString
* @returns {array}
*/
static find(obj: object, queryString: string): any[];
/**
* This will display an element.
*
* @param {object} obj
* @returns {object} An instance of base.
*/
static show(obj: object): object;
/**
* This will hide an element.
*
* @param {object} obj
* @returns {object} An instance of base.
*/
static hide(obj: object): object;
/**
* This will toggle the display an element.
*
* @param {object} obj
* @returns {object} An instance of base.
*/
static toggle(obj: object): object;
/**
* This will get the size of an element.
*
* @param {object} obj
* @returns {object|boolean} A size object or false.
*/
static getSize(obj: object): object | boolean;
/**
* This will get the width of an element.
*
* @param {object} obj
* @returns {number|boolean} A width or false.
*/
static getWidth(obj: object): number | boolean;
/**
* This will get the height of an element.
*
* @param {object} obj
* @returns {number|boolean} A height or false.
*/
static getHeight(obj: object): number | boolean;
/**
* This will get the scroll position.
*
* @param {object} [obj] The element or document element if not set.
* @returns {object}
*/
static getScrollPosition(obj?: object): object;
/**
* This will get the scroll top position.
*
* @param {object} [obj] The element or document element if not set.
* @returns {number|null}
*/
static getScrollTop(obj?: object): number | null;
/**
* This will get the scroll left position.
*
* @param {object} [obj] The element or document element if not set.
* @returns {number|null}
*/
static getScrollLeft(obj?: object): number | null;
/**
* This will get the window size.
*
* @returns {object}
*/
static getWindowSize(): object;
/**
* This will get the document size.
*
* @returns {object}
*/
static getDocumentSize(): object;
/**
* This will get the document height.
*
* @returns {object}
*/
static getDocumentHeight(): object;
/**
* This will get the position of an element.
*
* @param {object} obj
* @param {number} [depth] The number of levels, default is 1, 0 is to the root.
* @returns {object}
*/
static position(obj: object, depth?: number): object;
/**
* This will add a class to an element.
*
* @param {object} obj
* @param {string} tmpClassName
* @returns {object}
*/
static addClass(obj: object, tmpClassName: string): object;
/**
* This will remove a class or classes from an element.
*
* @param {object} obj
* @param {string} [tmpClassName]
* @returns {object}
*/
static removeClass(obj: object, tmpClassName?: string): object;
/**
* This will check if an element has a class.
*
* @param {object} obj
* @param {string} tmpClassName
* @returns {boolean}
*/
static hasClass(obj: object, tmpClassName: string): boolean;
/**
* This will toggle a class on an element.
*
* @param {object} obj
* @param {string} tmpClassName
* @returns {object}
*/
static toggleClass(obj: object, tmpClassName: string): object;
}