BW Core Javascript (version: 4.2)

To start, there are some custom standard functions applied to some HTML elements.

 

Every website loads in a bwcore.js file. It includes a number of commonly used functions and provides a stable basis for all websites. We have included FastClick to speed up response times for touches as clicks on mobile devices and isMobile.

window.bwcVars

This object contains many useful variables about the web page, elements, window and mouse.

 

window.bwcFunctions

This object contains many useful variables about the web page, elements, window and mouse.

bwcFunctions.stripTags()

Strip HTML tags, but allow some

Example

 
var strippedString = bwcFunctions.stripTags(input,allowed);
 
Variable/Key
Type
Default
Description
input
string
""
a string to strip HTML tags from
allowed
string
""
a string with any tags you want to keep. e.g. "<a><b>"

bwcFunctions.array_replace_recursive()

A deep overwriting of arrays to replicate PHP's array_replace_recursive function in Javascript (http://brett-zamir.me)

Example

 
var newArray = bwcFunctions.array_replace_recursive(inputArray,anotherArray);
 
Variable/Key
Type
Default
Description
inputArray
array
[]
the first array to process. You can add as many other arrays as you want as additional parameters

bwcFunctions.getCookieByName()

Get a cookie's value by it's name

Example

 
var cookieValue = bwcFunctions.getCookieByName("cookieName");
 

bwcFunctions.getNow()

Gets Performance.now() if - returns floating point milliseconds since that particular page started to load. If unavailable it falls back to a predefined Date().getTime() variable saved at the script's load point subtracting the current Date().getTime() variable.

Example

 
var nowMS = bwcFunctions.getNow();
 

window.ellipsis()

Trims text to it's container and appends a tail. It is automatically run on any elements with the class ellipsis

Example Auto HTML

 
<div>
	<span class="ellipsis">
		A string  which may be too wide for the container
	</span>
</div>
 

Example Javascript

 
ellipsis(redoEllipsis,className,restoreCharacters);
 

window.replaceHtml()

The fastest way to replace HTML inside an element.

Example

 
replaceHtml(domElement,newHTML);
 

window.layoutNotices

This object handles displaying banner notification and errors at the top of your web page when configured in your layout class.

window.fixedElementFunctions (deprecated)

This object was used to keep fixed elements within a client's window when scrolling. This has been deprecated due to lacking mobile support responsiveness.