Global

Methods

# $(argument) → {jLight}

jLights default export
Parameters:
Name Type Description
argument jLight | string | function | HTMLElement | HTMLCollection | NodeList | document | window The argument to initialize jLight on
Source:
Tutorials:
Returns:
jLight collection
Type
jLight

Type Definitions

# ajaxCompleteCallback(?response, ?status, ?request) → {void}

Parameters:
Name Type Attributes Description
response * <optional>
The requests response
status number <optional>
The requests HTTP status code
request XMLHttpRequest <optional>
The orginal XMLHttpRequest object
Source:
Returns:
void
Type
void

# animateCallback(?properties, ?duration, ?callback, ?easing) → {jLight}

Parameters:
Name Type Attributes Description
properties Object.<string, string> <optional>
The css properties and values to animate
duration number <optional>
The duration for the animation in ms (default: 300)
callback function <optional>
The function to run after the animation is complete (default: noop)
easing string <optional>
Which type of css easing to use for the animation (default: 'ease')
Source:
Returns:
jLight collection
Type
jLight

# animateOutCallback(?duration, ?callback, ?easing) → {jLight}

Parameters:
Name Type Attributes Description
duration number <optional>
The duration for the animation in ms (default: 300)
callback function <optional>
The function to run after the animation is complete (default: noop)
easing string <optional>
Which type of css easing to use for the animation (default: 'ease')
Source:
Returns:
jLight collection
Type
jLight

# arrayBooleanCallback(callback) → {boolean}

Parameters:
Name Type Description
callback iteratorBooleanCallback The elements to supply to the function
Source:
Returns:
If the conditon is met
Type
boolean

# arrayLengthCallback(…elements) → {number}

Parameters:
Name Type Attributes Description
elements jLight | string | HTMLElement | HTMLCollection | NodeList <repeatable>
The elements to apply to the function.
Source:
Returns:
The collections new length
Type
number

# attrCallback(?attribute, ?value) → {jLight|Object.<string, string>|boolean}

Parameters:
Name Type Attributes Description
attribute string | Object.<string, *> <optional>
The attribute or attributes to set or get
value * <optional>
The value to set the attribute to
Source:
Returns:
jLight collection, the attributes value, an object of each attribute on the collections elements or if the attribute whether present on at least one of the collections elements
Type
jLight | Object.<string, string> | boolean

# cloneCallback(?deep) → {jLight}

Parameters:
Name Type Attributes Description
deep boolean <optional>
Whether to apply deep cloning of the affected nodes (default: true)
Source:
Returns:
jLight collection
Type
jLight

# compareCallback($element1, $element2) → {number}

Parameters:
Name Type Description
$element1 jLight The element to compare
$element2 jLight The element to compare to
Source:
Returns:
The value to determine which place the element to compare will take
Type
number

# contentCallback(?content) → {jLight|string}

Parameters:
Name Type Attributes Description
content string <optional>
The content to supply to the function
Source:
Returns:
jLight collection or the text content
Type
jLight | string

# cssCallback(property, ?value) → {jLight|string|CSSStyleDeclaration}

Parameters:
Name Type Attributes Description
property string | Object.<string, string> The property name or the properties to set
value string <optional>
The value to set the supplied property to
Source:
Returns:
jLight collection, property value or elements CSSStyleDeclaration
Type
jLight | string | CSSStyleDeclaration

# cssClassCallback(cssClasses) → {jLight}

Parameters:
Name Type Description
cssClasses string Space sepearated classes to supply to the function
Source:
Returns:
jLight collection
Type
jLight

# dataCallback(?keyOrData, ?value) → {jLight|*}

Parameters:
Name Type Attributes Description
keyOrData string | Object.<string, *> <optional>
The key of the data value to get or set or an object of data values to set.
value string | Array.<string> <optional>
The value to set the data at the supplied key to.
Source:
Returns:
jLight collection
Type
jLight | *

# defaultCallback() → {jLight}

Source:
Returns:
jLight collection
Type
jLight

# delayCallback(?delay) → {Promise}

Parameters:
Name Type Attributes Description
delay number <optional>
The duration to delay the code execution for
Source:
Returns:
The corresponding promise
Type
Promise

# delegateCallback(eventNames, callback) → {jLight}

Parameters:
Name Type Description
eventNames string Space separated list of event names
callback function The function to apply
Source:
Returns:
jLight collection
Type
jLight

# dimensionCallback() → {number}

Source:
Returns:
The dimension value
Type
number

# elementsBooleanCallback(elements) → {boolean}

Parameters:
Name Type Description
elements jLight | string | HTMLElement | HTMLCollection | NodeList The elements to supply to the function
Source:
Returns:
If the conditon is met
Type
boolean

# elementsCallback(elements) → {jLight}

Parameters:
Name Type Description
elements jLight | string | HTMLElement | HTMLCollection | NodeList The elements to apply the function to
Source:
Returns:
jLight collection
Type
jLight

# elementsNumberCallback(elements) → {number}

Parameters:
Name Type Description
elements jLight | string | HTMLElement | HTMLCollection | NodeList The elements to supply to the function
Source:
Returns:
The resulting number
Type
number

# eventCallback(?event)

Parameters:
Name Type Attributes Description
event Event <optional>
The dispatched event with jLight elements for the events currentTarget and target attached (event.$currentTarget and event.$target)
Source:

# fadeCallback(?duration, ?callback, ?type, ?easing) → {jLight}

Parameters:
Name Type Attributes Description
duration number <optional>
The duration for the animation in ms (default: 300)
callback function <optional>
The function to run after the animation is complete (default: noop)
type string <optional>
The css display type to apply to the collections elements (default: 'block')
easing string <optional>
Which type of css easing to use for the animation (default: 'ease')
Source:
Returns:
jLight collection
Type
jLight

# filterCallback(callbackOrSelector) → {jLight}

Parameters:
Name Type Description
callbackOrSelector string | iteratorCallback The selector to filter the collection by or a custom function to decide which elements to filter out
Source:
Returns:
jLight collection
Type
jLight

# getOrSetValueCallback(?value) → {jLight|number}

Parameters:
Name Type Attributes Description
value number <optional>
The value to supply to the function
Source:
Returns:
jLight collection or the value
Type
jLight | number

# hasClassCallback(cssClasses) → {boolean}

Parameters:
Name Type Description
cssClasses string Space sepearated classes to supply to the function
Source:
Returns:
Whether at least one of the collections elements has all of the provided classes
Type
boolean

# indexElementCallback(index) → {HTMLElement|undefined}

Parameters:
Name Type Description
index number The index to supply to the function
Source:
Returns:
The element or null
Type
HTMLElement | undefined

# indexjLightCallback(index) → {jLight}

Parameters:
Name Type Description
index number The index to supply to the function
Source:
Returns:
jLight collection
Type
jLight

# inViewCallback(?offsetOrCallback, ?callbackOrOptions) → {jLight|boolean}

Parameters:
Name Type Attributes Description
offsetOrCallback function | Object <optional>
The offset used for determining if the element is in view or the function to run each time that is the case
callbackOrOptions function | Object <optional>
The function to run each time the element is in view or a custom options object to define the functions behavior (defaults: { scrollTimer: 100, isInView: noop, onEnter: noop, onExit: noop })
Source:
Returns:
jLight collection or whether the collections first element is in view
Type
jLight | boolean

# isCallback(propertyOrElements) → {boolean}

Parameters:
Name Type Description
propertyOrElements jLight | string | HTMLElement | HTMLCollection | NodeList The property or set to compare the collections elements to
Source:
Returns:
If the property is set on one of the collections elements or at least on of the elements is contained in the supplied elements
Type
boolean

# iteratorBooleanCallback(?$element, ?index) → {boolean}

Parameters:
Name Type Attributes Description
$element jLight <optional>
The current jLight element
index number <optional>
The current index
Source:
Returns:
Whether the condition is met
Type
boolean

# iteratorCallback(?$element, ?index) → {void}

Parameters:
Name Type Attributes Description
$element jLight <optional>
The current jLight element
index number <optional>
The current index
Source:
Returns:
void
Type
void

# jLight

Type:
  • Object

Properties

Name Type Description
elements Array.<HTMLElement> The collections elements.
length number The collections element count.
tagName string The collections first elements tag name.
addClass cssClassCallback Adds css classes to the collections elements.
removeClass cssClassCallback Removes css classes to the collections elements.
toggleClass toggleCssClassCallback Toggles css classes of the collections elements.
hasClass hasClassCallback Whether at least one of the collections elements has all of the provided classes.
css cssCallback Applies style rules to the collections elements, gets the current style rules or gets the current value for a specific style property.
show visibilityCallback Shows the collections elements.
hide defaultCallback Hides the collections elements.
toggle toggleVisibilityCallback Toggles the collections elements visibility.
on onCallback Adds event handlers to elements.
once onCallback Adds event handlers to elements fo one time execution.
off offCallback Removes event handlers from elements.
delegate delegateCallback [DEPRECATED] Delegates event handlers to elements.
undelegate delegateCallback [DEPRECATED] Undelegates event handlers from elements.
trigger triggerCallback Triggers events on the collections elements.
prop propCallback Sets a property of the collections elements or gets its value.
attr attrCallback Sets an attribute or attributes to the collections elements or gets its value or values.
removeAttr removeAttrCallback Removes the supplied attributes from the collections elements.
text contentCallback Gets or sets the text content of the collections elements.
html contentCallback Gets or sets the HTML content of the collections elements.
val valCallback Gets or sets the collections elements values.
data dataCallback Gets or sets the jLight data of the collections elements.
empty defaultCallback Empties the collections elements HTML content.
clone cloneCallback Clones the collection.
add elementsCallback Adds elements to the collection.
remove removeCallback Removes elements from the collection.
prepend elementsCallback Prepends elements to the collections elements.
append elementsCallback Appends elements to the collections elements.
prependTo elementsCallback Prepends the collections elements to elements.
appendTo elementsCallback Appends the collections elements to elements.
insertBefore elementsCallback Inserts the collections elements before elements.
insertAfter elementsCallback Inserts the collections elements after elements.
before elementsCallback Inserts elements before the collections elements.
after elementsCallback Inserts elements after the collections elements.
wrap elementsCallback Wraps the collections elements in elements.
get indexElementCallback Gets the element at the supplied index from the collection.
eq indexjLightCallback Gets the jLight element at the supplied index from the collection.
first defaultCallback Gets the first jLight element from the collection.
last defaultCallback Gets the last jLight element from the collection.
parent defaultCallback Gets a jLight collection from the collections parent elements.
parents defaultCallback Gets a jLight collection from all the collections parent elements.
children defaultCallback Gets a jLight collection from the collections children elements.
siblings defaultCallback Gets a jLight collection from the collections sibling elements.
prev selectorCallback Gets a jLight collection from the collections previous sibling elements.
next selectorCallback Gets a jLight collection from the collections next sibling elements.
closest selectorCallback Gets a jLight collection from all the collections parent elements matching the selector.
not elementsCallback Gets a jLight collection from the collections elements which are not part of elements.
has elementsCallback Gets a jLight collection from the collections elements which contain elements.
filter filterCallback Gets a filtered jLight collection based on the input.
forEach outerIteratorCallback Runs a function on each of the collections elements.
each outerIteratorCallback [DEPRECATED] Runs a function on each of the collections elements.
slice sliceCallback Slices the collection.
splice spliceCallback Splices the collection.
push arrayLengthCallback Pushes elements to the collection.
pop defaultCallback Pops the last element from the collection.
reverse defaultCallback Reverses a collection.
shift defaultCallback Shifts a collection.
unshift arrayLengthCallback Unshifts a collection.
sort sortCallback Sorts a collection.
reduce reduceCallback Reduces a collection.
map mapCallback Maps a collection.
concat multipleElementsCallback Concats a collection with other collections.
includes elementsBooleanCallback Whether the collections elements include at least one of elements.
some arrayBooleanCallback Whether at least one of the collections elements meets the conditon.
every arrayBooleanCallback Whether every one of the collections elements meets the conditon.
indexOf elementsNumberCallback Gets the given elements index inside the collection.
lastIndexOf elementsNumberCallback Gets the given elements last index inside the collection.
find selectorCallback Gets a jLight collection from the collections children elements matching the selector.
width getOrSetValueCallback Gets or sets the width of the collections elements.
height getOrSetValueCallback Gets or sets the height of the collections elements.
innerWidth dimensionCallback Gets the inner width of the collections elements.
innerHeight dimensionCallback Gets the inner height of the collections elements.
outerWidth outerDimensionCallback Gets the outer width of the collections elements.
outerHeight outerDimensionCallback Gets the outer height of the collections elements.
scrollWidth dimensionCallback Gets the scroll width of the collections elements.
scrollHeight dimensionCallback Gets the scroll height of the collections elements.
scrollTop getOrSetValueCallback Gets or sets the scrollTop of the collections elements.
scrollLeft getOrSetValueCallback Gets or sets the scrollLeft of the collections elements.
offset offsetCallback Gets or sets the collections elements offset.
animate animateCallback Animates the given properties to the given values on the collections elements.
scrollTo scrollToCallback Scrolls the collections elements to elements.
stop defaultCallback Stops all running animations on the collections elements.
fadeIn fadeCallback Fades the collections elements in.
fadeOut animateOutCallback Fades the collections elements out.
fadeToggle fadeCallback Toggles the display state of the collections elements by fading.
slideDown slideCallback Slides the collections elements down.
slideUp animateOutCallback Slides the collections elements up.
slideToggle slideToggleCallback Toggles the display state of the collections elements by sliding.
is isCallback Whether a property of an element of the collection is true or if an element of the collection is part of another set.
contains elementsBooleanCallback Whether the collections elements contain at least one of elements.
inView inViewCallback Checks if the collections first element is in view or runs a function if that is the case.
delay delayCallback Delays code execution.
when whenCallback Calls the supplied function with the supplied arguments if the given condition is met.
serialize stringCallback Serializes the collections elements values to a URL encoded string.
serializeJson stringObjectCallback Serializes the collections elements values to a JSON object.
Source:

# mapCallback(callback) → {jLight}

Parameters:
Name Type Description
callback mapInnerCallback The function used for mapping
Source:
Returns:
jLight collection
Type
jLight

# mapInnerCallback(?$element, ?index) → {jLight|string|HTMLElement|HTMLCollection|NodeList}

Parameters:
Name Type Attributes Description
$element jLight <optional>
The current element
index number <optional>
The current elements index
Source:
Returns:
The elements to map
Type
jLight | string | HTMLElement | HTMLCollection | NodeList

# multipleElementsCallback(…elements) → {jLight}

Parameters:
Name Type Attributes Description
elements jLight | string | HTMLElement | HTMLCollection | NodeList | Array.<(jLight|string|HTMLElement|HTMLCollection|NodeList)> <repeatable>
The elements to apply to the function.
Source:
Returns:
jLight collection
Type
jLight

# offCallback(eventNames, ?callback) → {jLight}

Parameters:
Name Type Attributes Description
eventNames string Space separated list of event names
callback function <optional>
The function to remove from being executed when the event occurs
Source:
Returns:
jLight collection
Type
jLight

# offsetCallback(?value, ?relativeToViewport) → {jLight|Object}

Parameters:
Name Type Attributes Description
value boolean | Object <optional>
The value to set the elements offset to or if the returned offset should be relative to the viewport
relativeToViewport boolean <optional>
Whether the offset should be set relative to the viewport (default: false)
Source:
Returns:
jLight collection or elements offset
Type
jLight | Object

# onCallback(eventNames, callbackOrSelector, ?delegatedCallbackOrOptions, ?options) → {jLight}

Parameters:
Name Type Attributes Description
eventNames string Space separated list of event names
callbackOrSelector eventCallback The function to execute when the event occurs or a selector to delegate events to children of the current collections elements
delegatedCallbackOrOptions eventCallback | Object <optional>
The callback to run when the event is delegated or the options to apply to the listener
options Object <optional>
The options to apply to the listener
Source:
Returns:
jLight collection
Type
jLight

# onStepCallback(percent) → {void}

Parameters:
Name Type Description
percent number The eased percentage of the current time over the duration
Source:
Returns:
void
Type
void

# outerDimensionCallback(?includeMargins) → {number}

Parameters:
Name Type Attributes Description
includeMargins boolean <optional>
Whether to include the elements margins (default: false)
Source:
Returns:
The dimension value
Type
number

# outerIteratorCallback(callback) → {jLight}

Parameters:
Name Type Description
callback iteratorCallback The function to apply to each element
Source:
Returns:
jLight collection
Type
jLight

# propCallback(property, ?state) → {jLight|boolean}

Parameters:
Name Type Attributes Description
property string The property to set or get
state boolean <optional>
The state to set the property to
Source:
Returns:
jLight collection or if the property is set on at least one of the collections elements
Type
jLight | boolean

# reduceCallback(callback, ?initialValue) → {*}

Parameters:
Name Type Attributes Description
callback reduceInnerCallback The function used for reduction
initialValue * <optional>
The initial value used for reduction
Source:
Returns:
The reduction result
Type
*

# reduceInnerCallback(accumulator, $element, ?index) → {*}

Parameters:
Name Type Attributes Description
accumulator * The accumulated value
$element jLight The current element
index number <optional>
The current elements index
Source:
Returns:
The current reduction result
Type
*

# removeAttrCallback(attribute) → {jLight}

Parameters:
Name Type Description
attribute string | Array.<string> The attribute or attributes to remove
Source:
Returns:
jLight collection
Type
jLight

# removeCallback(?elements, ?removeFromDom) → {jLight|null}

Parameters:
Name Type Attributes Description
elements jLight | string | HTMLElement | HTMLCollection | NodeList <optional>
The elements to remove
removeFromDom boolean <optional>
Whether the elements should also be removed from the DOM (default: true)
Source:
Returns:
jLight collection or null
Type
jLight | null

# scrollToCallback(elements, ?duration, ?offset, ?callback) → {jLight}

Parameters:
Name Type Attributes Description
elements jLight | string | HTMLElement | HTMLCollection | NodeList The elements to scroll the collections elements to
duration number <optional>
The duration of the scroll animation in ms (default: 300)
offset Object | Object <optional>
The offset for the target position
callback function <optional>
The function to run after the scrolling is complete
Source:
Returns:
jLight collection
Type
jLight

# selectorCallback(?selector) → {jLight}

Parameters:
Name Type Attributes Description
selector string <optional>
The selector to use for matching elements
Source:
Returns:
jLight collection
Type
jLight

# sliceCallback(?start, ?end) → {jLight}

Parameters:
Name Type Attributes Description
start number <optional>
The index to start the slicing
end number <optional>
The index to end the slicing
Source:
Returns:
jLight collection
Type
jLight

# slideCallback(?duration, ?callback, ?height, ?type, ?easing) → {jLight}

Parameters:
Name Type Attributes Description
duration number <optional>
The duration for the animation in ms (default: 300)
callback function <optional>
The function to run after the animation is complete (default: noop)
height string <optional>
The css height value to end the sliding animation (default: 'auto')
type string <optional>
The css display type to apply to the collections elements (default: 'block')
easing string <optional>
Which type of css easing to use for the animation (default: 'ease')
Source:
Returns:
jLight collection
Type
jLight

# slideToggleCallback(?duration, ?callback, ?height, ?type, ?easing, ?force) → {jLight}

Parameters:
Name Type Attributes Description
duration number <optional>
The duration for the animation in ms (default: 300)
callback function <optional>
The function to run after the animation is complete (default: noop)
height string <optional>
The css height value to end the sliding animation (default: 'auto')
type string <optional>
The css display type to apply to the collections elements (default: 'block')
easing string <optional>
Which type of css easing to use for the animation (default: 'ease')
force boolean <optional>
Force whether to slide down or up
Source:
Returns:
jLight collection
Type
jLight

# sortCallback(compareFunction) → {jLight}

Parameters:
Name Type Description
compareFunction compareCallback The function used for sorting
Source:
Returns:
jLight collection
Type
jLight

# spliceCallback(start, ?deleteCount) → {jLight}

Parameters:
Name Type Attributes Description
start number The index to start the splicing
deleteCount number <optional>
The count of elements to delete
Source:
Returns:
jLight collection
Type
jLight

# stringCallback() → {string}

Source:
Returns:
The resulting string
Type
string

# stringObjectCallback() → {Object.<string, string>}

Source:
Returns:
The resulting JSON object
Type
Object.<string, string>

# toggleCssClassCallback(cssClasses, ?force) → {jLight}

Parameters:
Name Type Attributes Description
cssClasses string Space sepearated classes to supply to the function
force boolean <optional>
Force whether to add or remove classes
Source:
Returns:
jLight collection
Type
jLight

# toggleVisibilityCallback(?type, ?force) → {jLight}

Parameters:
Name Type Attributes Description
type string <optional>
The css display type to apply to the function (default: 'block')
force boolean <optional>
Force whether to show or hide elements
Source:
Returns:
jLight collection
Type
jLight

# triggerCallback(eventNames, ?jLightEventData) → {jLight}

Parameters:
Name Type Attributes Description
eventNames string Space separated list of event names
jLightEventData * <optional>
Custom data passed to the event
Source:
Returns:
jLight collection
Type
jLight

# valCallback(?valueOrFunction) → {jLight|boolean|string}

Parameters:
Name Type Attributes Description
valueOrFunction boolean | null | string | Array.<boolean> | function | iteratorCallback <optional>
The value to set the collections elements value to. If a function is supplied its return value will be set as the value. If the jLight element is an HTMLSelectElement with the multiple attribute each option will be passed separately to the function. In that case an array of booleans can be used to set the selected options.
Source:
Returns:
jLight collection or the value
Type
jLight | boolean | string

# visibilityCallback(?type) → {jLight}

Parameters:
Name Type Attributes Description
type string <optional>
The css display type to apply to the function (default: 'block')
Source:
Returns:
jLight collection
Type
jLight

# whenCallback(condition, callback, ?…args) → {jLight}

Parameters:
Name Type Attributes Description
condition boolean | function The condition to check for. If a function is supplied its return value will be used for checking
callback string | function The function to run when the condition is met. If a string is provided it should be a valid jLight function name
args * <optional>
<repeatable>
The arguments to supply to the given jLight function
Source:
Returns:
jLight collection
Type
jLight

# xhrCallback(?request) → {XMLHttpRequest}

Parameters:
Name Type Attributes Description
request XMLHttpRequest <optional>
The orginal XMLHttpRequest object
Source:
Returns:
XMLHttpRequest
Type
XMLHttpRequest