addCssClass()chooseCssClass()eltGetAncestorByTag()eltOuterHeight()eltOuterWidth()eltScrollTo()eltTransition()evtGetPointerX()evtGetPointerY()getElt()hasCssClass()hasElt()importStyleSheet()isDomNode()replaceCssClass()The DOM functions manipulate DOM elements. All DOM functions are properties of the global/window object and may be used without importing.
addCssClass() Global
addCssClass(arg1, ...classNames)
Adds CSS classes to an element, object, or string. The arguments in classNames are strings of class names separated by spaces.
If arg1 is a string, it is considered to be class names separated by spaces, and the class names in the classNames arguments are added to arg1 if they don't exist. The resulting string of class names is returned.
If arg1 is an object or DOM element, then the class names in the classNames arguments are added to the class names in arg1.className if they don't exist. If arg1.className does not exist, then arg1.className is set to the class names in the classNames arguments with any duplicates removed.
arg1className property should contain zero or more CSS class names separated by spaces, if present. classNamesclassNames arguments are strings containing zero or more CSS class names separated by spaces.If arg1 is a string, then a string is returned containing all the CSS classes specified in the arguments without duplicates. If arg1 is a DOM element or object, then undefined is returned.
chooseCssClass() Global
chooseCssClass(arg1, choice, ...choices)
Adds a single choice of CSS class name to the string, object, or DOM element specified by arg1. All the remaining choices are removed. The choice argument is an index into the choices arguments. This is useful when a CSS class string must have one of several different class names but not more than one.
arg1className property should contain zero or more CSS class names separated by spaces, if present. choicechoices arguments. A non-finite value (e.g. a Boolean) is coerced to 1 if truthy, otherwise 0. If the index is out of range, no class is chosen and all the choices classes are removed.choiceschoices arguments are strings containing zero or more CSS class names separated by spaces.If arg1 is a string, then a string is returned containing all the CSS classes with the chosen class names, with the others removed. If arg1 is a DOM element or object, then undefined is returned.
eltGetAncestorByTag() Global
eltGetAncestorByTag(elt, tag)
Return the enclosing element with the given tag. For example, eltGetAncestorByTag(elt, 'tr') returns the enclosing table row. The search stops at the <body> element. If no ancestor has the tag, an assert() failure is generated (logged and alerted) before null is returned.
elttagA DOM element, if the tag is found, or null otherwise.
eltOuterHeight() Global
eltOuterHeight(elt)
Returns the height of the element's bounding box in pixels (px units).
eltA number.
eltOuterWidth() Global
eltOuterWidth(elt)
Returns the width of the element's bounding box in pixels (px units).
eltA number.
eltScrollTo() Global
eltScrollTo(elt, top, duration)
Smoothly scrolls elt so that its scrollTop becomes top, using cosine easing so the motion starts and ends gently. When the document is hidden, where requestAnimationFrame() never fires, the animation is driven by a timer instead so the Promise still resolves.
elttopscrollTop value in pixels.durationA Promise that resolves when the scroll is complete.
eltTransition() Global
eltTransition(elt, startFn)
Asynchronously set up a transition on a DOM element.
startFn is a function that is called asynchronously when the current thread completes. This allows eltTransition() to be called before the element is fully painted with it's current style. At that point, the startFn can set up a transition or a new CSS class with a transition. The startFn is passed the DOM element as its single argument.
eltTransition() returns a Promise that resolves when the transition is complete.
eltstartFnstartFn(elt) where elt is the DOM element referenced by the eltTransition() elt argument. startFn() should set up the element with the new transition either by changing style or CSS class name.A Promise that resolves when the transition is complete.
evtGetPointerX() Global
evtGetPointerX(evt)
Returns the client X offset in pixels from the evt event object. On touch devices it returns the first touch point's X offset.
evtA number.
evtGetPointerY() Global
evtGetPointerY(evt)
Returns the client Y offset in pixels from the evt event object. On touch devices it returns the first touch point's Y offset.
evtA number.
getElt() Global
getElt(id)
Returns the DOM element whose ID string is id. getElt() generates an assertion failure if the ID is not found.
idA DOM element.
hasCssClass() Global
hasCssClass(arg1, className)
Return true if the DOM element, object, or string contains the string className.
If arg1 is a string, it is considered to be class names separated by spaces, and hasCssClass() returns true if the string includes className. It returns false if className is not present.
If arg1 is an object or DOM element, then hasCssClass() returns true if arg1.className includes className. It returns false if className is not present or arg1.className does not exist.
arg1className property should contain zero or more CSS class names separated by spaces, if present. classNameA Boolean
hasElt() Global
hasElt(id)
Returns true if the DOM element whose ID string is id exists.
idA Boolean.
importStyleSheet() Global
importStyleSheet(file)
A build-time placeholder. The function does nothing at run time; the build process finds the call and imports the CSS stylesheet.
fileundefined.
isDomNode() Global
isDomNode(arg)
Returns true if arg is a DOM element.
argA Boolean.
replaceCssClass() Global
replaceCssClass(arg1, oldClass)
replaceCssClass(arg1, oldClass, newClass)
Deletes the CSS classes in oldClass and adds the CSS classes in newClass to the element, object, or string specified by arg1. If newClass is not provided, then the oldClass classes are deleted.
If arg1 is a string, it is considered to be class names separated by spaces, and the class names in oldClass are deleted, and the class names in the newClass are added if they don't exist. The resulting string of class names is returned.
If arg1 is an object or DOM element, then the class names in oldClass are deleted from arg1.className, and the class names in the newClass are added to arg1.className, if they don't exist. If arg1.className does not exist, then arg1.className is set to the class names in the newClass argument with any duplicates removed.
arg1className property should contain zero or more CSS class names separated by spaces, if present. oldClassnewClass (opional)If arg1 is a string, then a string is returned containing the result of deleting and adding the specified classes to the original string without duplicates. If arg1 is a DOM element or object, then undefined is returned.