3.0.1 • Published 3 years ago

@cnbritain/merlin-www-js-utils v3.0.1

Weekly downloads
94
License
ISC
Repository
-
Last release
3 years ago

Modules

detect

detect.getUserAgent ⇒ Object

Creates an object with user agent information

Kind: static property of detect
Url: http://stackoverflow.com/questions/5916900/how-can-you-detect-the-version-of-a-browser

detect.hasHistory : Boolean

window.history support

Kind: static property of detect

detect.hasTouch : Boolean

Touch support

Kind: static property of detect

detect.isAndroid : Boolean

Android useragent sniff

Kind: static property of detect

detect.isIOS : Boolean

iOS useragent sniff

Kind: static property of detect

detect.isLinux : Boolean

Linux useragent sniff

Kind: static property of detect

detect.isMac : Boolean

Macintoch useragent sniff

Kind: static property of detect

detect.isWindows : Boolean

Windows useragent sniff

Kind: static property of detect

detect.supportBoxModel ⇒ Boolean

Box model support

Kind: static property of detect

detect.supportsHTML5Video ⇒ Boolean

HTML5 video support

Kind: static property of detect

functions

functions.addClass(el, cls)

Adds a class to an element

Kind: static method of functions

ParamType
elHTMLNode
clsString

functions.addEvent(el, type, fn)

Adds an event to an element

Kind: static method of functions

ParamType
elHTMLNode
typeString
fnfunction

functions.addEventOnce(el, type, fn)

Adds an event that will fire once and then remove itself

Kind: static method of functions

ParamType
elHTMLNode
typeString
fnfunction

functions.addHtml(node)

Adds html to a node

Kind: static method of functions

ParamType
nodeHTMLElement

functions.ajax(options) ⇒ Promise

Basic ajax function

Kind: static method of functions

ParamType
optionsObject

functions.assign(target, ...source) ⇒ Object

Assigns the values of the other sources to the target

Kind: static method of functions

ParamType
targetObject
...sourceObject

functions.clamp(min, max, value1) ⇒ Number/Function

Clamps a value to the min and max. Also set up to allow currying.

Kind: static method of functions

ParamType
minNumber
maxNumber
value1Number

functions.cloneArray(src) ⇒ Array

Clones an array

Kind: static method of functions

ParamType
srcArray

functions.cloneArrayDeep(src) ⇒ Array

Clones an array while recursively cloning the items inside

Kind: static method of functions

ParamType
srcArray

functions.cloneObject(src) ⇒ Object

Clones an object

Kind: static method of functions

ParamType
srcObject

functions.cloneObjectDeep(src) ⇒ Object

Clones an object whilst recursively cloning the descendants

Kind: static method of functions

ParamType
srcObject

functions.createEventTemplate(type, target, eventData) ⇒ Object

Creates an object for events

Kind: static method of functions

ParamTypeDescription
typeStringThe type of event
targetObjectThe thing that emitted the event
eventDataObjectSome data

functions.debounce(fn, wait, scope, immediate) ⇒ function

Debounce function, allows one function to be ran wait milliseconds after.

Kind: static method of functions

ParamTypeDescription
fnfunction
waitNumberNumber of milliseconds
scopeObject
immediateBoolean

functions.delegate(selector, fn, ctx) ⇒ function

Creates a function that will delegate events to a selector

Kind: static method of functions

ParamType
selectorString
fnfunction
ctx*

functions.exitFullscreen(el)

Exits fullscreen mode for the element

Kind: static method of functions

ParamType
elHTMLNode

functions.fireEvent(el, type, bubble, cancelable) ⇒ Boolean

Fires an event on an element

Kind: static method of functions
Returns: Boolean - Was the event cancelled?

ParamTypeDescription
elHTMLElement
typeStringThe type of event
bubbleBooleanShould the event bubble?
cancelableBooleanShould the event be cancelable?

functions.forEachShift(collection, fn)

Loop over a collection and shift the item from the collection

Kind: static method of functions

ParamType
collectionArray
fnfunction

functions.getElementOffset(el) ⇒ Object

Gets the elements offset. Based off of jquerys implementation

Kind: static method of functions

ParamType
elHTMLNode

functions.getEventTarget(e) ⇒ *

Gets the event target

Kind: static method of functions
Returns: * - The target of the event

ParamTypeDescription
eObjectThe event information

functions.getIframeFromWindow(window) ⇒ HTMLNode/Boolean

Gets the iframe element based on the window

Kind: static method of functions

ParamType
windowWindow

functions.getObjectValues(obj, keys) ⇒ Array.<*>

Gets the values from an object. If keys are specified, it will only get the values of those keys.

Kind: static method of functions

ParamTypeDescription
objObjectSource object
keysArray.<String>

functions.getParent(el, selector) ⇒ HTMLNode/Boolean

Gets the parent element matching the selector. If it doesn't match, returns nothing

Kind: static method of functions

ParamType
elHTMLNode
selectorString

functions.getPrevious(el, selector) ⇒ HTMLElement/Boolean

Gets the previous element matching the selector. If it doesn't match, returns false

Kind: static method of functions

ParamType
elHTMLElement
selectorString

functions.getParentUntil(el, selector) ⇒ Object

Gets the parent till the selector or the root.

Kind: static method of functions

ParamType
elHTMLNode
selectorString

functions.getPreviousElementUntil(el, selector) ⇒ Object

Gets the previous element till the selector or the root

Kind: static method of functions

ParamType
elHTMLNode
selectorString

functions.getScrollLeft(el) ⇒ Number

Gets the scroll left of the element

Kind: static method of functions

ParamType
elHTMLNode/Window

functions.getScrollTop(el) ⇒ Number

Gets the scroll top of the element

Kind: static method of functions

ParamType
elHTMLNode/Window

functions.getNamespaceKey(abbr) ⇒ String

Creates a key based on the brand abbreviation

Kind: static method of functions

ParamType
abbrString

functions.getWindowScrollLeft() ⇒ Number

Gets the scrollleft of the window

Kind: static method of functions

functions.getWindowScrollTop() ⇒ Number

Gets the scrolltop of the window

Kind: static method of functions

functions.hasClass(el, cls) ⇒ Boolean

Checks if the element has a class

Kind: static method of functions

ParamType
elHTMLNode
clsString

functions.hasOwnProperty(obj, key) ⇒ Boolean

hasOwnProperty that prevents contamination from the object being tested

Kind: static method of functions

ParamType
objObject
keyString

functions.inherit(src, props) ⇒ Object

Creates a new object based from src. Then copies over any properties.

Kind: static method of functions

ParamType
srcObject
propsObject | Undefined

functions.insertBefore(child, ref) ⇒ HTMLElement

Inserts the child element before the reference

Kind: static method of functions
Returns: HTMLElement - The child

ParamType
childHTMLElement
refHTMLElement

functions.isArray(src) ⇒ Boolean

Checks if the src is an array

Kind: static method of functions

ParamType
src*

functions.isArticleAdSlot(placement) ⇒ Boolean

Checks if the placement is in an article slot

Kind: static method of functions

ParamType
placementString

functions.isDefined(value) ⇒ Boolean

Checks if a value is defined

Kind: static method of functions

ParamType
value*

functions.isEmptyString(value) ⇒ Boolean

Checks if the value is an empty string

Kind: static method of functions

ParamType
value*

functions.isElement(value) ⇒ Boolean

Checks if the value is an element

Kind: static method of functions

ParamType
value*

functions.isHeaderAdSlot(placement) ⇒ Boolean

Checks if the placement is a header slot

Kind: static method of functions

ParamType
placementString

functions.isObject(src) ⇒ Boolean

Checks if the src is an object

Kind: static method of functions

ParamType
src*

functions.isSplashAdSlot(placement) ⇒ Boolean

Checks if the placement is a splash slot

Kind: static method of functions

ParamType
placementString

functions.isWindow(win) ⇒ Boolean

Checks if win is a window element

Kind: static method of functions

ParamType
win*

functions.loadScript(url, options) ⇒ Promise

Loads a script file into the page

Kind: static method of functions

ParamType
urlString
optionsObject

functions.loadSocialScripts() ⇒ Promise

Loads any social scripts. Includes twitter, facebook, vine, instagram and imgur

Kind: static method of functions

functions.not(value) ⇒ Boolean

Inverts the value

Kind: static method of functions

ParamType
value*

functions.onPageLoad(loadFn)

Runs loadFn once the page has loaded

Kind: static method of functions

ParamType
loadFnfunction

functions.onPageReady(readyFn)

Runs readyFn once the page is ready

Kind: static method of functions

ParamType
readyFnfunction

functions.padValue(value, width, chr) ⇒ String

Pads a number

Kind: static method of functions

ParamType
valueNumber
widthNumber
chrString

functions.randomUUID() ⇒ String

Generates a random id

Kind: static method of functions

functions.removeClass(el, cls)

Removes a class from an element

Kind: static method of functions

ParamType
elHTMLNode
clsString

functions.removeElement(el)

Removes the element from the tree

Kind: static method of functions

ParamType
elHTMLElement

functions.removeEvent(el, type, fn)

Removes an event from an element

Kind: static method of functions

ParamType
elHTMLNode
typeString
fnfunction

functions.throttle(fn, threshhold, scope) ⇒ function

Throttles an event being fired by the threshold

Kind: static method of functions

ParamTypeDescription
fnfunction
threshholdNumberMilliseconds to throttle by
scopeObject

functions.toBoolean(value) ⇒ Boolean

Converts a value to a boolean

Kind: static method of functions

ParamType
value*

functions.toggleClass(el, cls)

Toggles a class on an element

Kind: static method of functions

ParamType
elHTMLNode
clsString

functions.unescapeJinjaValue(value) ⇒ *

Unescapes a value from jinja

Kind: static method of functions

ParamType
value*
3.0.1

3 years ago

3.0.0

3 years ago

3.0.0-alpha.1

3 years ago

2.0.0

4 years ago

1.11.1

4 years ago

1.10.3-alpha.0

4 years ago

1.10.2

4 years ago

1.10.1

4 years ago

1.10.0

4 years ago

1.9.10

4 years ago

1.9.8

4 years ago

1.9.7

4 years ago

1.9.6

4 years ago

1.9.0

4 years ago

1.7.1-alpha.118

4 years ago

1.7.1-alpha.0

4 years ago

1.7.1-alpha.47

5 years ago

1.7.1-beta.49

5 years ago

1.7.0

6 years ago

1.6.4

6 years ago

1.6.3

6 years ago

1.6.2

6 years ago

1.6.1

6 years ago

1.6.0

6 years ago

1.5.2

6 years ago

1.5.0

6 years ago

1.4.2

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.11

6 years ago

1.3.8

6 years ago

1.3.7

6 years ago

1.3.5

6 years ago

1.3.4

6 years ago

1.3.3

6 years ago

1.3.2

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago