@cnbritain/common-js v1.0.0
Modules
detect
- detect
- .getUserAgent ⇒ Object
- .hasHistory : Boolean
- .hasTouch : Boolean
- .isAndroid : Boolean
- .isIOS : Boolean
- .isLinux : Boolean
- .isMac : Boolean
- .isWindows : Boolean
- .supportBoxModel ⇒ Boolean
- .supportsHTML5Video ⇒ Boolean
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)
- .addEvent(el, type, fn)
- .addEventOnce(el, type, fn)
- .addHtml(node)
- .ajax(options) ⇒ Promise
- .clamp(min, max, value1) ⇒ Number/Function
- .debounce(fn, wait, scope, immediate) ⇒ function
- .delegate(selector, fn, ctx) ⇒ function
- .exitFullscreen(el)
- .forEachShift(collection, fn)
- .getElementOffset(el) ⇒ Object
- .getEventTarget(e) ⇒ *
- .getIframeFromWindow(window) ⇒ HTMLNode/Boolean
- .getParent(el, selector) ⇒ HTMLNode/Boolean
- .getPrevious(el, selector) ⇒ HTMLElement/Boolean
- .getParentUntil(el, selector) ⇒ Object
- .getPreviousElementUntil(el, selector) ⇒ Object
- .getScrollLeft(el) ⇒ Number
- .getScrollTop(el) ⇒ Number
- .getWindowScrollLeft() ⇒ Number
- .getWindowScrollTop() ⇒ Number
- .hasClass(el, cls) ⇒ Boolean
- .hasOwnProperty(obj, key) ⇒ Boolean
- .isArticleAdSlot(placement) ⇒ Boolean
- .isDefined(value) ⇒ Boolean
- .isEmptyString(value) ⇒ Boolean
- .isHeaderAdSlot(placement) ⇒ Boolean
- .isSplashAdSlot(placement) ⇒ Boolean
- .isWindow(win) ⇒ Boolean
- .loadScript(url, options) ⇒ Promise
- .loadSocialScripts() ⇒ Promise
- .not(value) ⇒ Boolean
- .onPageLoad(loadFn)
- .onPageReady(readyFn)
- .padValue(value, width, chr) ⇒ String
- .randomUUID() ⇒ String
- .removeClass(el, cls)
- .removeElement(el)
- .removeEvent(el, type, fn)
- .throttle(fn, threshhold, scope) ⇒ function
- .toBoolean(value) ⇒ Boolean
- .toggleClass(el, cls)
- .unescapeJinjaValue(value) ⇒ *
functions.addClass(el, cls)
Adds a class to an element
Kind: static method of functions
| Param | Type |
|---|---|
| el | HTMLNode |
| cls | String |
functions.addEvent(el, type, fn)
Adds an event to an element
Kind: static method of functions
| Param | Type |
|---|---|
| el | HTMLNode |
| type | String |
| fn | function |
functions.addEventOnce(el, type, fn)
Adds an event that will fire once and then remove itself
Kind: static method of functions
| Param | Type |
|---|---|
| el | HTMLNode |
| type | String |
| fn | function |
functions.addHtml(node)
Adds html to a node
Kind: static method of functions
| Param | Type |
|---|---|
| node | HTMLElement |
functions.ajax(options) ⇒ Promise
Basic ajax function
Kind: static method of functions
| Param | Type |
|---|---|
| options | Object |
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
| Param | Type |
|---|---|
| min | Number |
| max | Number |
| value1 | Number |
functions.debounce(fn, wait, scope, immediate) ⇒ function
Debounce function, allows one function to be ran wait milliseconds after.
Kind: static method of functions
| Param | Type | Description |
|---|---|---|
| fn | function | |
| wait | Number | Number of milliseconds |
| scope | Object | |
| immediate | Boolean |
functions.delegate(selector, fn, ctx) ⇒ function
Creates a function that will delegate events to a selector
Kind: static method of functions
| Param | Type |
|---|---|
| selector | String |
| fn | function |
| ctx | * |
functions.exitFullscreen(el)
Exits fullscreen mode for the element
Kind: static method of functions
| Param | Type |
|---|---|
| el | HTMLNode |
functions.forEachShift(collection, fn)
Loop over a collection and shift the item from the collection
Kind: static method of functions
| Param | Type |
|---|---|
| collection | Array |
| fn | function |
functions.getElementOffset(el) ⇒ Object
Gets the elements offset. Based off of jquerys implementation
Kind: static method of functions
| Param | Type |
|---|---|
| el | HTMLNode |
functions.getEventTarget(e) ⇒ *
Gets the event target
Kind: static method of functions
Returns: * - The target of the event
| Param | Type | Description |
|---|---|---|
| e | Object | The event information |
functions.getIframeFromWindow(window) ⇒ HTMLNode/Boolean
Gets the iframe element based on the window
Kind: static method of functions
| Param | Type |
|---|---|
| window | Window |
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
| Param | Type |
|---|---|
| el | HTMLNode |
| selector | String |
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
| Param | Type |
|---|---|
| el | HTMLElement |
| selector | String |
functions.getParentUntil(el, selector) ⇒ Object
Gets the parent till the selector or the root.
Kind: static method of functions
| Param | Type |
|---|---|
| el | HTMLNode |
| selector | String |
functions.getPreviousElementUntil(el, selector) ⇒ Object
Gets the previous element till the selector or the root
Kind: static method of functions
| Param | Type |
|---|---|
| el | HTMLNode |
| selector | String |
functions.getScrollLeft(el) ⇒ Number
Gets the scroll left of the element
Kind: static method of functions
| Param | Type |
|---|---|
| el | HTMLNode/Window |
functions.getScrollTop(el) ⇒ Number
Gets the scroll top of the element
Kind: static method of functions
| Param | Type |
|---|---|
| el | HTMLNode/Window |
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
| Param | Type |
|---|---|
| el | HTMLNode |
| cls | String |
functions.hasOwnProperty(obj, key) ⇒ Boolean
hasOwnProperty that prevents contamination from the object being tested
Kind: static method of functions
| Param | Type |
|---|---|
| obj | Object |
| key | String |
functions.isArticleAdSlot(placement) ⇒ Boolean
Checks if the placement is in an article slot
Kind: static method of functions
| Param | Type |
|---|---|
| placement | String |
functions.isDefined(value) ⇒ Boolean
Checks if a value is defined
Kind: static method of functions
| Param | Type |
|---|---|
| value | * |
functions.isEmptyString(value) ⇒ Boolean
Checks if the value is an empty string
Kind: static method of functions
| Param | Type |
|---|---|
| value | * |
functions.isHeaderAdSlot(placement) ⇒ Boolean
Checks if the placement is a header slot
Kind: static method of functions
| Param | Type |
|---|---|
| placement | String |
functions.isSplashAdSlot(placement) ⇒ Boolean
Checks if the placement is a splash slot
Kind: static method of functions
| Param | Type |
|---|---|
| placement | String |
functions.isWindow(win) ⇒ Boolean
Checks if win is a window element
Kind: static method of functions
| Param | Type |
|---|---|
| win | * |
functions.loadScript(url, options) ⇒ Promise
Loads a script file into the page
Kind: static method of functions
| Param | Type |
|---|---|
| url | String |
| options | Object |
functions.loadSocialScripts() ⇒ Promise
Loads any social scripts. Includes twitter, facebook, vine and instagram
Kind: static method of functions
functions.not(value) ⇒ Boolean
Inverts the value
Kind: static method of functions
| Param | Type |
|---|---|
| value | * |
functions.onPageLoad(loadFn)
Runs loadFn once the page has loaded
Kind: static method of functions
| Param | Type |
|---|---|
| loadFn | function |
functions.onPageReady(readyFn)
Runs readyFn once the page is ready
Kind: static method of functions
| Param | Type |
|---|---|
| readyFn | function |
functions.padValue(value, width, chr) ⇒ String
Pads a number
Kind: static method of functions
| Param | Type |
|---|---|
| value | Number |
| width | Number |
| chr | String |
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
| Param | Type |
|---|---|
| el | HTMLNode |
| cls | String |
functions.removeElement(el)
Removes the element from the tree
Kind: static method of functions
| Param | Type |
|---|---|
| el | HTMLElement |
functions.removeEvent(el, type, fn)
Removes an event from an element
Kind: static method of functions
| Param | Type |
|---|---|
| el | HTMLNode |
| type | String |
| fn | function |
functions.throttle(fn, threshhold, scope) ⇒ function
Throttles an event being fired by the threshold
Kind: static method of functions
| Param | Type | Description |
|---|---|---|
| fn | function | |
| threshhold | Number | Milliseconds to throttle by |
| scope | Object |
functions.toBoolean(value) ⇒ Boolean
Converts a value to a boolean
Kind: static method of functions
| Param | Type |
|---|---|
| value | * |
functions.toggleClass(el, cls)
Toggles a class on an element
Kind: static method of functions
| Param | Type |
|---|---|
| el | HTMLNode |
| cls | String |
functions.unescapeJinjaValue(value) ⇒ *
Unescapes a value from jinja
Kind: static method of functions
| Param | Type |
|---|---|
| value | * |
10 years ago