Elemint

The elemint function

$ (module.js, line 99)

A function that returns the following chainable methods.

  • after
  • ascend
  • before
  • child
  • class (kill, set, sub)
  • descend
  • event (emit, kill, set)
  • layer
  • match
  • mount
  • offset
  • parent
  • position
  • prop (get, kill, set)
  • sibling
  • size (get, set)
  • style (get, set)
  • unmount

$(elementOrSelector)
$$(elementOrSelector)
elemint(elementOrSelector)

The elemint object

$.after (method/after.js, line 1)

Return the immediately following sibling OR next matched sibling of each element in the set of matched elements.

$.after(target, optionalSelector);
$(target).after(optionalSelector);
Arguments:
Name Type Description
target Array | Element

The element(s) whose next sibling will be obtained.

selector String

Return the next sibling that matches the given selector.

Returns:

Element collection.

Type
Array | Element

$.animate (method/animate.js, line 1)

Manage DOM animations.

$.animate;
Arguments:
Name Type Description
target Array | Element

The target element(s).

Returns:

methods An object containing the 'set, kill' methods.

Type
Object

$.animate.kill (method/animate/animate.kill.js, line 1)

Kill a DOM animation.

$.animate.kill(tag);
Arguments:
Name Type Description
tag string

Animation identification.

$.animate.set (method/animate/animate.set.js, line 1)

Configure and start a DOM animation.

var config = {
    tag: 'myAnimation',
    callback: () => {...}
};

$.animate.set(config);
Arguments:
Name Type Description
config Object

Animation configuration.

$.ascend (method/ascend.js, line 1)

Find all the matched ancestors at each upper level relative to the subject. Will return n levels of anscestors until the limit is reached.

$.ascend(target, optionalSelectorOrLimit, limit);
$(target).ascend(optionalSelectorOrLimit, limit);
Arguments:
Name Type Description
target Element | Array

The element(s) whose ancestors will be returned.

selectorOrLimit String

The target ancestor or the number of ancestors to return.

limit Number

Limit how many ancestors will be returned.

Returns:

An array of ancestors that match the given selector.

Type
Array | Object

$.before (method/before.js, line 1)

Return the immediately preceding sibling OR preceding matched sibling of each element in the set of matched elements.

$.before(target, optionalSelector);
$(target).before(optionalSelector);
Arguments:
Name Type Description
target Array | Element

The element(s) whose preceding sibling will be obtained.

selector String

Return a preceding sibling that matches the given selector.

Returns:

Element collection.

Type
Array | Element

$.child (method/child.js, line 1)

Return the immediate children of the matched elements.

$.child(target, optionalSelector);
$(target).child(optionalSelector);
Arguments:
Name Type Description
target Array | Element

The parent element(s).

selector String

Find a specific subset of children.

Returns:

A collection of the selected element's children.

Type
Array

$.class (method/class.js, line 1)

Manipulate element classes

$.class(target);
$(target).class;
Arguments:
Name Type Description
target Array | Element

The target element(s).

Returns:

methods An object containing the 'set, kill, sub, test' methods.

Type
Object

$.class.kill (method/class/class.kill.js, line 1)

Disable a class on an element's className property.

$.class(target).kill(classA, classB, classN, ...);
$(target).class.kill(classA, classB, classN, ...);
Arguments:
Name Type Description
classes String

The classnames to be disabled.

$.class.set (method/class/class.set.js, line 1)

Enable a class on an element's className property.

$.class(target).set(classA, classB, classN, ...);
$(target).class.set(classA, classB, classN, ...);
Arguments:
Name Type Description
classes String

The classnames to be enabled.

$.class.sub (method/class/class.sub.js, line 1)

Substitute a class on an element's className property with another class.

$.class(target).sub('classA', 'classB');
$(target).class.sub('classA', 'classB');
Arguments:
Name Type Description
target String

The class that will be replaced.

replacement String

The class that will replace the target class.

$.descend (method/descend.js, line 1)

Find all the matched descendants at each level of depth relative to the subject. Will return n levels of descendants until the limit is reached.

$.descend(target, optionalSelectorOrDepth, depth);
$(target).descend(optionalSelectorOrDepth, depth);
Arguments:
Name Type Description
target Array | Element

The parent element(s).

selectorOrDepth String

The target descendant or the depth at which the descending will stop.

depth Number

The depth at which the descending will stop.

Returns:

An array of descendants that match the given selector.

Type
Array

$.event (method/event.js, line 1)

Manage element events

$.event(target);
$(target).event;
Arguments:
Name Type Description
target Array | Element

The target element(s).

Returns:

methods An object containing the 'set, kill, emit' methods.

Type
Object

$.event.emit (method/event/event.emit.js, line 1)

Send an event to an element

var config = {
    bubbles: true,
    cancelable: true
}

$.event(target).emit('eventName', config);
$(target).event.emit('eventName', config);

var e = $.event(target);
e.blur();
e.click();
e.dblclick();
e.focus();
e.keydown();
e.keypress();
e.keyup();
e.mousedown();
e.mouseenter();
e.mouseleave();
e.mousemove();
e.mouseout();
e.mouseover();
e.submit();
e.touchcancel();
e.touchend();
e.touchenter();
e.touchleave();
e.touchmove();
e.touchstart();
Arguments:
Name Type Description
eventName Object

The name of the event

config Object

The config for the event

$.event.kill (method/event/event.kill.js, line 1)

Stop an event listener

$.event(target).kill('tag');
$(target).event.kill('eventName', callback);
Arguments:
Name Type Description
tagOrEventName Array

A tag or event name for an existing event

callback Array

The original callback function to be used with an event name

$.event.set (method/event/event.set.js, line 1)

Setup an event listener on an element

var config = {
    on: '',
    tag: '',
    target: false,
    callback: () => {...},
    limit: false
}

$.event(target).set(config);
$.event(target).set(evt, callback);
$(target).event.set(config);
$(target).event.set(evt, callback);
Arguments:
Name Type Description
target Array | Element

The target element(s)

config Object

Event listener configuration

$.fragment (method/fragment.js, line 1)

Wrap HTML/nodes in a document fragment.

$.fragment([el1, el2, el3, ...]);
$.fragment("<div>...</div>");
Arguments:
Name Type Description
contents String | Element | Array

The html/elements that will be wrapped.

Returns:

The html/elements wrapper.

Type
Fragment

$.layer (method/layer.js, line 1)

Manage element layers.

$.layer(target);
$(target).layer;
Arguments:
Name Type Description
target Array | Element

The target element(s).

Returns:

methods An object containing the 'set, get' methods.

Type
Object

$.layer.get (method/layer/layer.get.js, line 1)

Return the z-index of an element.

$.layer(target).get();
$(target).layer.get()
Returns:

The z-index of the element.

Type
Number

$.layer.set (method/layer/layer.set.js, line 1)

Set the z-index of an element.

$.layer(target).set(newIndex);
$(target).layer.set(newIndex)
Arguments:
Name Type Description
z-index Number

The new z-index for the element(s).

$.match (method/match.js, line 1)

Return a set of elements that match the selector or pass the test.

$.match(target, selectorOrTest, test);
$(target).match(selectorOrTest, test);
Arguments:
Name Type Description
target Array | Element

The set of elements.

selectorOrTest String

A query selector or a testing function used to find a match.

test function | Undefined

A testing function used to find a match.

$.mount (method/mount.js, line 1)

  • Mounting is a process that inserts elements into the DOM.
  • Mount an element or fragment in a parent element.
  • Will default to mounting the selected element(s) in document.body if no other arguments are passed.
    • innerEnd: afterend of subject's last child.
    • innerBegin: beforebegin of subject's first child.
    • outerEnd: afterend of subject's last sibling.
    • outerBegin: beforebegin of subject's first sibling.
    • before: beforebegin of subject.
    • after: afterend of subject.
$.mount(
    target,
    locationOrPayload,
    payload
);

$(target).mount(
    locationOrPayload,
    payload
);
Arguments:
Name Type Description
target Element | Fragment

The point of reference for the mountpoint location.

locationOrPayload Array | Element | Fragment | String | Undefined

The mountpoint location relative to the target or the payload elements with the default mountpoint location set to innerEnd.

payload Array | Element | Fragment | String | Undefined

The payload elements that will be mounted.

$.offset (method/offset.js, line 1)

Manage element offsets.

$.offset(target);
$(target).offset;
Arguments:
Name Type Description
target Array | Element

The target element(s).

Returns:

methods An object containing the 'set, get' methods.

Type
Object

$.offset.get (method/offset/offset.get.js, line 1)

Return the offset of an element relative to the document.

$.offset(target).get();
$(target).offset.get();
Returns:

An object containing the element(s) offset as it's properties.

Type
Object

$.offset.set (method/offset/offset.set.js, line 1)

Set the offset of an element relative to the document.

$.offset(target).set({top: ..., left: ...});
$(target).offset.set({top: ..., left: ...});
Arguments:
Name Type Description
config Object

The new offset of the element(s).

$.parent (method/parent.js, line 1)

Return the parent of the matched elements.

$.parent(target);
$.parent(target, true);
$(target).parent();
$(target).parent(true);
Arguments:
Name Type Description
target Array | Element

The element whose parent will be selected.

offsetParent Boolean

Find the nearest ancestor that is positioned.

Returns:

The selected parent elements.

Type
Array

$.position (method/position.js, line 1)

Return the position of an element relative to it's offset parent.

$.position(target);
$(target).position();
Arguments:
Name Type Description
target Element

The element whose position will be returned.

Returns:

The position of the element returned within an object.

Type
Object

$.prop (method/prop.js, line 1)

Manage element properties (attributes)

$.prop(target);
$(target).prop;
Arguments:
Name Type Description
target Array | Element

The target element(s)

Returns:

methods An object containing the 'set, get, kill' methods

Type
Object

$.prop.get (method/prop/prop.get.js, line 1)

Get a value from an element property (attribute).

$.prop(target).get('property');
$.prop(target).get('propertyA', 'propertyB');
$(target).prop.get('property');
$(target).prop.get('propertyA', 'propertyB');
Arguments:
Name Type Description
prop String

A comma-separated list of properties whose value(s) will be fetched.

Returns:

prop An object with property key-values or a single value string.

Type
Object | String

$.prop.kill (method/prop/prop.kill.js, line 1)

Remove property (attribute) from an element.

$.prop(target).kill('property');
$(target).prop.kill('property');
Arguments:
Name Type Description
prop Array

The property whose value will be removed.

$.prop.set (method/prop/prop.set.js, line 1)

Set a value on an element property (attribute).

$.prop(target).set('propName', 'value');
$(target).prop.set('propName', 'value');

$.prop(target).set({'propName1: 'value1', 'propName2: 'value2'};
$(target).prop.set({'propName1: 'value1', 'propName2: 'value2'});
Arguments:
Name Type Description
ObjectOrKey Object | String

Attribute key-pair values or an attribute name.

value String

The value that will be set to the property.

$.query (method/query.js, line 1)

Look-up DOM elements and return them in an array.

// Elemint object with cached elements
$(target);

// Array of elements
$.query(selector);

// Shorthand for returning an array of elements
$.$(target);
Arguments:
Name Type Description
target Array | String | Nodelist | Element

The element(s) that will be selected.

context Document | Element

A parent whose children will be queried against the given selector. The default context is the current document.

Returns:

An element collection.

Type
Array

$.ready (method/ready.js, line 1)

Execute a function when the DOM is ready.

$.ready(() => {
    // body...
});
Arguments:
Name Type Description
callback function

A callback function.

$.render (method/render.js, line 1)

Accept markup and return a collection of elements in an array.

$.render(payload);
Arguments:
Name Type Description
payload String

The markup that will be converted to elements.

Returns:

The resulting array of elements.

Type
Array

$.sibling (method/sibling.js, line 1)

Return all matched elements that share the same immediate parent as the subject (subject excluded).

$.sibling(target, optionalSelector);
$(target).sibling(optionalSelector);
Arguments:
Name Type Description
target Array | Element

The element(s) whose siblings will be selected.

selector String

Query the siblings by selector.

Returns:

The subject(s) siblings.

Type
Array

$.size (method/size.js, line 1)

Get or set the dimensions of an element.

$.size(target);
$(target).size;
Arguments:
Name Type Description
target Array | Element

The target element(s).

Returns:

methods An object containing the 'set, get' methods.

Type
Object

$.size.get (method/size/size.get.js, line 1)

Get the height/width of an element.

$.size(target).get();
$.size(target).get('height');
$(target).size.get();
$(target).size.get('height');
Arguments:
Name Type Description
heightOrWidth String

Specify a single dimension to return.

Returns:

An object containing the element's dimensions.

Type
Object

$.size.set (method/size/size.set.js, line 1)

Set the height/width of an element.

$.size(target).set(config);
$(target).size.set(config);
Arguments:
Name Type Description
target Array | Element

The element(s) whose dimensions will be set.

$.style (method/style.js, line 1)

Manage document styles.

$.style(target);
$.style(target, document);
$(target).style;
$(target, document).style;
Arguments:
Name Type Description
elementOrProp Element | Array | String

An element(s) or CSS selector.

context Document | Element

The context which will be used - default is .

Returns:

methods An object containing the 'set, get' methods.

Type
Object

$.style.get (method/style/style.get.js, line 1)

Get style values from an element.

$.style(target).get(prop1, prop2, propN, ...);
$(target).style.get(prop1, prop2, propN, ...);
Arguments:
Name Type Description
style String

The style(s) whose value will be returned.

Returns:

CSS key-pair list or a CSS property value.

Type
Object | String

$.style.set (method/style/style.set.js, line 1)

Get style values from an element.

// Single rule injection into document stylesheets with string
$.style('div:before').set(prop, value);

// Multiple rule injection into document stylesheets with object
$.style('div:before').set({ prop: value, ... });

// Multiple rule injection into document stylesheets with string
$.style('div:before { prop: value, ... } div:after { prop: value, ... } ...').set();

// Multiple rule injection into document stylesheets with string via array
$.style(['div:before { prop: value, ... }', 'div:after { prop: value, ... }']).set();

// Inline rules
$.style(target, optionalContext).set(style, value);
$.style(target, optionalContext).set({ prop: value, ... });
$(target).style.set(style, value, optionalContext);
$(target).style.set({ prop: value, ... }, optionalContext);
Arguments:
Name Type Description
rulesOrProperty Object | String

CSS key-pair list or a CSS property name.

value String

The style that will be applied.

$.unmount (method/unmount.js, line 1)

Unmounting is a process that removes elements from the DOM. Unmount an element or it's relative.

  • innerEnd: afterend of subject's last child
  • innerBegin: beforebegin of subject's first child
  • outerEnd: afterend of subject's last sibling
  • outerBegin: beforebegin of subject's first sibling
  • before: beforebegin of subject
  • after: afterend of subject
// Self
$.unmount(target);
$(target).unmount();

// Relatives
$.unmount(target, relativeLocation);
$(target).unmount(relativeLocation);
$.unmount(target, childElement);
$(target).unmount(childElement);
Arguments:
Name Type Description
target Array | Element

The point of reference for the mountpoint location.

relative Element | String

The location of an element that will be removed relative to the target.