dom.d.ts 5.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. export declare function addCssClass(element: HTMLElement, className: string): HTMLElement;
  2. export declare function removeCssClass(element: HTMLElement, className: string): void;
  3. export declare function addOrRemoveCssClass(element: HTMLElement, className: string, addOrRemove: boolean): void;
  4. /**
  5. * This method adds a class to an element and remove that class from all siblings.
  6. * Useful for toggling state.
  7. * @param {HTMLElement} element The element to receive the class
  8. * @param {string} elementClass The class to be assigned to the element
  9. * @param {boolean} otherElementClass The class to be assigned to siblings of the element, but not the element itself
  10. */
  11. export declare function radioCssClass(element: HTMLElement, elementClass: string | null, otherElementClass?: string | null): void;
  12. export declare function containsClass(element: HTMLElement, className: string): boolean;
  13. export declare function setDisplayed(element: HTMLElement, displayed: boolean): void;
  14. export declare function setVisible(element: HTMLElement, visible: boolean): void;
  15. export declare function setDisabled(element: HTMLElement, disabled: boolean): void;
  16. export declare function isElementChildOfClass(element: HTMLElement, cls: string, maxNest?: number): boolean;
  17. export declare function getElementSize(el: HTMLElement): {
  18. height: number;
  19. width: number;
  20. paddingTop: number;
  21. paddingRight: number;
  22. paddingBottom: number;
  23. paddingLeft: number;
  24. marginTop: number;
  25. marginRight: number;
  26. marginBottom: number;
  27. marginLeft: number;
  28. boxSizing: string;
  29. };
  30. export declare function getInnerHeight(el: HTMLElement): number;
  31. export declare function getInnerWidth(el: HTMLElement): number;
  32. export declare function getAbsoluteHeight(el: HTMLElement): number;
  33. export declare function getAbsoluteWidth(el: HTMLElement): number;
  34. export declare function getScrollLeft(element: HTMLElement, rtl: boolean): number;
  35. export declare function setScrollLeft(element: HTMLElement, value: number, rtl: boolean): void;
  36. export declare function clearElement(el: HTMLElement): void;
  37. /** @deprecated */
  38. export declare function removeElement(parent: HTMLElement, cssSelector: string): void;
  39. export declare function removeFromParent(node: Element | null): void;
  40. export declare function isVisible(element: HTMLElement): boolean;
  41. /**
  42. * Loads the template and returns it as an element. makes up for no simple way in
  43. * the dom api to load html directly, eg we cannot do this: document.createElement(template)
  44. * @param {string} template
  45. * @returns {HTMLElement}
  46. */
  47. export declare function loadTemplate(template: string): HTMLElement;
  48. export declare function appendHtml(eContainer: HTMLElement, htmlTemplate: string): void;
  49. /** @deprecated */
  50. export declare function getElementAttribute(element: any, attributeName: string): string | null;
  51. export declare function offsetHeight(element: HTMLElement): number;
  52. export declare function offsetWidth(element: HTMLElement): number;
  53. export declare function ensureDomOrder(eContainer: HTMLElement, eChild: HTMLElement, eChildBefore: HTMLElement): void;
  54. export declare function setDomChildOrder(eContainer: HTMLElement, orderedChildren: HTMLElement[]): void;
  55. export declare function insertTemplateWithDomOrder(eContainer: HTMLElement, htmlTemplate: string, eChildBefore: HTMLElement): HTMLElement;
  56. /** @deprecated */
  57. export declare function prependDC(parent: HTMLElement, documentFragment: DocumentFragment): void;
  58. export declare function addStylesToElement(eElement: any, styles: any): void;
  59. export declare function isHorizontalScrollShowing(element: HTMLElement): boolean;
  60. export declare function isVerticalScrollShowing(element: HTMLElement): boolean;
  61. export declare function setElementWidth(element: HTMLElement, width: string | number): void;
  62. export declare function setFixedWidth(element: HTMLElement, width: string | number): void;
  63. export declare function setElementHeight(element: HTMLElement, height: string | number): void;
  64. export declare function setFixedHeight(element: HTMLElement, height: string | number): void;
  65. export declare function formatSize(size: number | string): string;
  66. /**
  67. * Returns true if it is a DOM node
  68. * taken from: http://stackoverflow.com/questions/384286/javascript-isdom-how-do-you-check-if-a-javascript-object-is-a-dom-object
  69. * @param {any} o
  70. * @return {boolean}
  71. */
  72. export declare function isNode(o: any): boolean;
  73. /**
  74. * Returns true if it is a DOM element
  75. * taken from: http://stackoverflow.com/questions/384286/javascript-isdom-how-do-you-check-if-a-javascript-object-is-a-dom-object
  76. * @param {any} o
  77. * @returns {boolean}
  78. */
  79. export declare function isElement(o: any): boolean;
  80. export declare function isNodeOrElement(o: any): boolean;
  81. /**
  82. * Makes a copy of a node list into a list
  83. * @param {NodeList} nodeList
  84. * @returns {Node[]}
  85. */
  86. export declare function copyNodeList(nodeList: NodeList): Node[];
  87. export declare function iterateNamedNodeMap(map: NamedNodeMap, callback: (key: string, value: string) => void): void;
  88. /** @deprecated */
  89. export declare function setCheckboxState(eCheckbox: HTMLInputElement, state: any): void;