object
smize : Provides the `smize` library - Simple Module InitialiZEr
Quickly build controller classes, with a collection of composable/extendable classes and common utilities.
Examples can be found in `dist/index.html`
Kind: global namespace
- smize :
object
- .composables :
object
- .AJAX
- new AJAX(scope)
- .afterAll(xhr, status, response) ⇒
boolean
- .afterEach(xhr, status, response) ⇒
boolean
- .call(config, stopOnError) ⇒
void
- .Base
- new Base(config, defaults)
- .configure(config) ⇒
boolean
- .subscribe(eventNames) ⇒
boolean
- .handleSubscriptions(eventName) ⇒
boolean
- .Debug
- new Debug(scope, config)
- .error() ⇒
boolean
- .formatMessage(methodName, message) ⇒
string
- .info() ⇒
boolean
- .matchesFilters(message) ⇒
boolean
- .warn() ⇒
boolean
- .write(writeArguments) ⇒
boolean
- .AJAX
- .data :
object
- .getCookies(cookieString) ⇒
object
- .getLocalItem(itemName, defaultValue) ⇒
object
- .getMetaKeys() ⇒
object
- .getQueryKeys(queryString) ⇒
object
- .getSessionItem(itemName, defaultValue) ⇒
object
- .removeLocalItem(itemName) ⇒
boolean
- .removeSessionItem(itemName) ⇒
boolean
- .setLocalItem(itemName, value) ⇒
boolean
- .setSessionItem(itemName, value) ⇒
boolean
- .transferKeys(source, target, concatArrays, dedupeArrays) ⇒
boolean
- .getCookies(cookieString) ⇒
- .events :
object
- .debounce(originalFunction, executionDelay, callImmediately) ⇒
function
- .publish(subscriptionName) ⇒
boolean
- .subscribe(subscriptionName, subscriber) ⇒
boolean
- .debounce(originalFunction, executionDelay, callImmediately) ⇒
- .html :
object
- .addClass(elements, classNames) ⇒
boolean
- .getClasses(elements) ⇒
array
- .hasClass(elements, classNames) ⇒
boolean
- .isValidElement(element) ⇒
boolean
- .nodeListToArray(elements) ⇒
array
- .removeClass(elements, classNames) ⇒
boolean
- .addClass(elements, classNames) ⇒
- .il8n :
object
- .addDictionaryKey(dictionaryKey) ⇒
boolean
- .addDictionaryKeys(dictionaryKeys) ⇒
boolean
- .formatDate(date, language) ⇒
string
- .formatDateString(dateString, language) ⇒
string
- .formatNumber(numberValue, language, options) ⇒
string
- .getKeyValue(dictionaryKeyName, language) ⇒
string
- .setKeyValue(dictionaryKeyName, language, value) ⇒
boolean
- .addDictionaryKey(dictionaryKey) ⇒
- .responsive :
object
- .currentBreakpoint
- .addBreakpoint(breakpointName, breakpointSettings) ⇒
boolean
- .addSubscriber(breakpointNames, subscriberFunction) ⇒
boolean
- .bindEventHandlers() ⇒
boolean
- .getBreakpoint(breakpointName) ⇒
object
- .getCurrentBreakpoints(viewport) ⇒
Array
- .getSubscriberCount(breakpointName) ⇒
number
- .removeBreakpoint(breakpointName) ⇒
boolean
- .ui :
object
- .bindModule(element) ⇒
boolean
- .bindScope(scope, deferSelector) ⇒
boolean
- .registerModule(moduleName, ClassReference, defaultConfiguration) ⇒
boolean
- .bindModule(element) ⇒
- .utils :
object
- .arrayFromArrayLike(arrayLike) ⇒
array
- .objectFromString(string) ⇒
object
- .replaceTokens(originalString, tokenSources, removeRemainder) ⇒
string
- .resolveBits(bits, expectedType, root) ⇒
object
- .stringFromObject(obj) ⇒
string
- .arrayFromArrayLike(arrayLike) ⇒
- .valid :
object
- .isDocumentValid() ⇒
boolean
- .isFalsy(value) ⇒
boolean
- .isOfType(value, checkType) ⇒
boolean
- .isTruthy(value) ⇒
boolean
- .isValidArray(value) ⇒
boolean
- .isValidCountryCode(countryCode) ⇒
boolean
- .isValidObject(value) ⇒
boolean
- .isValidString(value) ⇒
boolean
- .isWindowValid() ⇒
boolean
- .validBoolean(value, defaultValue) ⇒
boolean
- .validNumber(value, defaultValue) ⇒
number
- .validObject(value, defaultValue) ⇒
object
- .validString(value, defaultValue) ⇒
string
- .isDocumentValid() ⇒
- .ns(bitParts, root) ⇒
object
- .composables :
object
smize.composables : A collection of composable classes that provide reusable functionality.
Kind: static namespace of smize
- .composables :
object
- .AJAX
- new AJAX(scope)
- .afterAll(xhr, status, response) ⇒
boolean
- .afterEach(xhr, status, response) ⇒
boolean
- .call(config, stopOnError) ⇒
void
- .Base
- new Base(config, defaults)
- .configure(config) ⇒
boolean
- .subscribe(eventNames) ⇒
boolean
- .handleSubscriptions(eventName) ⇒
boolean
- .Debug
- new Debug(scope, config)
- .error() ⇒
boolean
- .formatMessage(methodName, message) ⇒
string
- .info() ⇒
boolean
- .matchesFilters(message) ⇒
boolean
- .warn() ⇒
boolean
- .write(writeArguments) ⇒
boolean
- .AJAX
composables.AJAX
A composable class that provides AJAX functionality
Kind: static class of composables
Properties
Name | Type | Description |
---|---|---|
classPath | string |
The path to the class in the global namespace |
lastResponse | object |
The last response from an AJAX call |
lastStatus | string |
The last status from an AJAX call |
lastXHR | object |
The last XHR object |
scope | object |
The class instance that initialized this composable |
- .AJAX
- new AJAX(scope)
- .afterAll(xhr, status, response) ⇒
boolean
- .afterEach(xhr, status, response) ⇒
boolean
- .call(config, stopOnError) ⇒
void
new AJAX(scope)
Creates a new, scoped instance of the AJAX class
Param | Type | Description |
---|---|---|
scope | object |
The class instance that created this instance |
boolean
AJAX.afterAll(xhr, status, response) ⇒ Tasks performed after all AJAX calls in a series of calls
Kind: static method of AJAX
Returns: boolean
- The method executed successfully
Param | Type | Description |
---|---|---|
xhr | object |
The XMLHttpRequest for the AJAX call |
status | string |
The status of the XMLHttpRequest |
response | object |
The response object from the XMLHttpRequest |
boolean
AJAX.afterEach(xhr, status, response) ⇒ Tasks performed after each AJAX call in a series of calls
Kind: static method of AJAX
Returns: boolean
- The method executed successfully
Param | Type | Description |
---|---|---|
xhr | object |
The XMLHttpRequest for the AJAX call |
status | string |
The status of the XMLHttpRequest |
response | object |
The response object from the XMLHttpRequest |
void
AJAX.call(config, stopOnError) ⇒ Places an AJAX call
Kind: static method of AJAX
Param | Type | Description |
---|---|---|
config | object |
The configuration properties for the AJAX call, or an array of configs:
|
stopOnError | boolean |
Should the chain end when there is an error? |
composables.Base
A base class that can be extended to provide common functionality
Kind: static class of composables
Properties
Name | Type | Description |
---|---|---|
config | object |
The initial configuration received from the constructor |
el | object |
The element this class instance was bound to |
initialized | boolean |
Has the instance initialized? |
loaded | boolean |
Has the instance loaded all content? |
setup | boolean |
Has the instance completed its setup tasks? |
subscriptions | array |
A collection of events to subscribe to |
- .Base
- new Base(config, defaults)
- .configure(config) ⇒
boolean
- .subscribe(eventNames) ⇒
boolean
- .handleSubscriptions(eventName) ⇒
boolean
new Base(config, defaults)
Creates a new instance of the Base class
Param | Type | Description |
---|---|---|
config | object |
Shared configuration for a group of class instances |
defaults | object |
The default configuration for an extending class |
boolean
Base.configure(config) ⇒ Configures a class instance from a configuration object
Kind: static method of Base
Returns: boolean
- Was the configuration successful?
Param | Type | Description |
---|---|---|
config | object |
The object to configure from |
boolean
Base.subscribe(eventNames) ⇒ Subscribes to one or more events using smize.events.subscribe
Kind: static method of Base
Returns: boolean
- Were events successfully subscribed to?
Param | Type | Description |
---|---|---|
eventNames | object |
An array of event names, or a single event name string |
boolean
Base.handleSubscriptions(eventName) ⇒ A handler method that delegates resolved subscriptions to the appropriate method
Kind: static abstract method of Base
Returns: boolean
- Was the subscription event handled?
Param | Type | Description |
---|---|---|
eventName | string |
The name of the event to handle |
composables.Debug
A composable class that provides Debug functionality
Kind: static class of composables
Properties
Name | Type | Description |
---|---|---|
classPath | string |
The path to the class in the global namespace |
debugEnabled | boolean |
Is debug enabled? Defaults to global state |
debugFilters | array |
A collection of debug filters, defaults to global state |
debugLevel | string |
The allowed debug level, defaults to global state |
scope | object |
The class instance that initialized this composable |
- .Debug
- new Debug(scope, config)
- .error() ⇒
boolean
- .formatMessage(methodName, message) ⇒
string
- .info() ⇒
boolean
- .matchesFilters(message) ⇒
boolean
- .warn() ⇒
boolean
- .write(writeArguments) ⇒
boolean
new Debug(scope, config)
Creates a new, scoped instance of the Debug class
Param | Type | Description |
---|---|---|
scope | object |
The class instance that created this instance |
config | object |
Optional configuration overrides |
boolean
Debug.error() ⇒ Writes an error log, accepting the same params as console.error
Kind: static method of Debug
Returns: boolean
- Was the message logged?
string
Debug.formatMessage(methodName, message) ⇒ Formats a message string
Kind: static method of Debug
Returns: string
- The formatted message or an empty string
Param | Type | Description |
---|---|---|
methodName | string |
The name of the caller method |
message | string |
The message to format |
boolean
Debug.info() ⇒ Writes an info log, accepting the same params as console.info
Kind: static method of Debug
Returns: boolean
- Was the message logged?
boolean
Debug.matchesFilters(message) ⇒ Ensures a message matches any filters specified
Kind: static method of Debug
Returns: boolean
- Did the message pass our filters?
Param | Type | Description |
---|---|---|
message | string |
The message argument passed to the logger |
boolean
Debug.warn() ⇒ Writes an warn log, accepting the same params as console.warn
Kind: static method of Debug
Returns: boolean
- Was the message logged?
boolean
Debug.write(writeArguments) ⇒ Writes a log to the console if it is able to
Kind: static method of Debug
Returns: boolean
- Was the message logged?
Param | Type | Description |
---|---|---|
writeArguments | array |
A collection of arguments for debugging |
object
smize.data : Provides data-related utilities
Kind: static namespace of smize
- .data :
object
- .getCookies(cookieString) ⇒
object
- .getLocalItem(itemName, defaultValue) ⇒
object
- .getMetaKeys() ⇒
object
- .getQueryKeys(queryString) ⇒
object
- .getSessionItem(itemName, defaultValue) ⇒
object
- .removeLocalItem(itemName) ⇒
boolean
- .removeSessionItem(itemName) ⇒
boolean
- .setLocalItem(itemName, value) ⇒
boolean
- .setSessionItem(itemName, value) ⇒
boolean
- .transferKeys(source, target, concatArrays, dedupeArrays) ⇒
boolean
- .getCookies(cookieString) ⇒
object
data.getCookies(cookieString) ⇒ Retrieves cookies as key
: value
pairs
Kind: static method of data
Returns: object
- A collection of keys
Param | Type | Description |
---|---|---|
cookieString | string |
The cookies to parse, defaults to document.cookie |
object
data.getLocalItem(itemName, defaultValue) ⇒ Retrieves an item from localStorage
- type inferred from the default value
Kind: static method of data
Returns: object
- The stored value, defaults to string
Param | Type | Description |
---|---|---|
itemName | string |
The name of the localStorage item |
defaultValue | object |
An optional default value if none is retrieved |
object
data.getMetaKeys() ⇒ Retrieves element values as key
: value
pairs
Kind: static method of data
Returns: object
- A collection of keys
object
data.getQueryKeys(queryString) ⇒ Retrieves query string parameters as key
: value
pairs
Kind: static method of data
Returns: object
- A collection of keys
Param | Type | Description |
---|---|---|
queryString | string |
The optional query string to retrieve keys from, defaults to document.location.search |
object
data.getSessionItem(itemName, defaultValue) ⇒ Retrieves an item from sessionStorage
- type inferred from the default value
Kind: static method of data
Returns: object
- The stored value, defaults to a string
Param | Type | Description |
---|---|---|
itemName | string |
The name of the sessionStorage item |
defaultValue | object |
An optional default value if none is retrieved |
boolean
data.removeLocalItem(itemName) ⇒ Removes an item from localStorage
if it exists
Kind: static method of data
Returns: boolean
- Was the removal successful?
Param | Type | Description |
---|---|---|
itemName | string |
The name of the localStorage item |
boolean
data.removeSessionItem(itemName) ⇒ Removes an item from sessionStorage if it exists
Kind: static method of data
Returns: boolean
- Was the removal successful?
Param | Type | Description |
---|---|---|
itemName | string |
The name of the sessionStorage item |
boolean
data.setLocalItem(itemName, value) ⇒ Creates or updates a localStorage
item
Kind: static method of data
Returns: boolean
- Was the update successful?
Param | Type | Description |
---|---|---|
itemName | string |
The name of the localStorage item |
value | object |
The new value for the item |
boolean
data.setSessionItem(itemName, value) ⇒ Creates or updates a sessionStorage
item
Kind: static method of data
Returns: boolean
- Was the update successful?
Param | Type | Description |
---|---|---|
itemName | string |
The name of the sessionStorage item |
value | object |
The new value for the item |
boolean
data.transferKeys(source, target, concatArrays, dedupeArrays) ⇒ Transfers key
: value
pairs between two objects
Kind: static method of data
Returns: boolean
- Was the transfer successful?
Todo
- Explore object copying APIs to clean this logic up
Param | Type | Description |
---|---|---|
source | object |
The source collection to read values from |
target | object |
The target collection add values to |
concatArrays | boolean |
Should arrays be merged? |
dedupeArrays | boolean |
Should array members be unique? |
object
smize.events : Provides utilities for publishing and subscribing to events
Kind: static namespace of smize
- .events :
object
- .debounce(originalFunction, executionDelay, callImmediately) ⇒
function
- .publish(subscriptionName) ⇒
boolean
- .subscribe(subscriptionName, subscriber) ⇒
boolean
- .debounce(originalFunction, executionDelay, callImmediately) ⇒
function
events.debounce(originalFunction, executionDelay, callImmediately) ⇒ Debounces event calls to improve performance
Kind: static method of events
Returns: function
- The debounced function or the original value
Param | Type | Description |
---|---|---|
originalFunction | function |
The function call to be debounced |
executionDelay | number |
The number of milliseconds to delay by |
callImmediately | boolean |
Should the function be called immediately? |
boolean
events.publish(subscriptionName) ⇒ Publishes information to all subscribers of a given subscription
Kind: static method of events
Returns: boolean
- Was the subscription published?
Param | Type | Description |
---|---|---|
subscriptionName | string |
The name of the subscription |
boolean
events.subscribe(subscriptionName, subscriber) ⇒ Publishes information to all subscribers of a given subscription
Kind: static method of events
Returns: boolean
- Did we successfully subscribe?
Param | Type | Description |
---|---|---|
subscriptionName | string |
The name of the subscription |
subscriber | function |
The subscriber function |
object
smize.html : Provides generic utilities for managing HTML nodes
Kind: static namespace of smize
- .html :
object
- .addClass(elements, classNames) ⇒
boolean
- .getClasses(elements) ⇒
array
- .hasClass(elements, classNames) ⇒
boolean
- .isValidElement(element) ⇒
boolean
- .nodeListToArray(elements) ⇒
array
- .removeClass(elements, classNames) ⇒
boolean
- .addClass(elements, classNames) ⇒
boolean
html.addClass(elements, classNames) ⇒ Adds one or more CSS classes to one or more elements
Kind: static method of html
Returns: boolean
- Was the operation successful?
Param | Type | Description |
---|---|---|
elements | object |
An HTML element or an Array-like of HTML elements |
classNames | object |
A CSS class name or an Array of CSS class names |
array
html.getClasses(elements) ⇒ Returns an Array of all classes on one or more elements
Kind: static method of html
Returns: array
- The classes found on the element(s)
Param | Type | Description |
---|---|---|
elements | object |
An HTML element or an Array-like of HTML elements |
boolean
html.hasClass(elements, classNames) ⇒ Checks that all elements have all CSS classes
Kind: static method of html
Returns: boolean
- Do all elements have all classes?
Param | Type | Description |
---|---|---|
elements | object |
An HTML element or an Array-like of HTML elements |
classNames | object |
A CSS class name or an Array of CSS class names |
boolean
html.isValidElement(element) ⇒ Verifies that one object is a valid HTML element
Kind: static method of html
Returns: boolean
- Is this a valid element?
Param | Type | Description |
---|---|---|
element | object |
A single element to verify |
array
html.nodeListToArray(elements) ⇒ Creates an Array from an element or a NodeList
Kind: static method of html
Returns: array
- An Array of one or more HTML elements
Param | Type | Description |
---|---|---|
elements | object |
An HTML element or an Array-like of HTML elements |
boolean
html.removeClass(elements, classNames) ⇒ Removes one or more CSS classes from one or more elements
Kind: static method of html
Returns: boolean
- Was the operation successful?
Param | Type | Description |
---|---|---|
elements | object |
An HTML element or an array-like of HTML elements |
classNames | object |
A CSS class name or an Array of CSS class names |
object
smize.il8n : Provides utilities for localization and internationalization
Kind: static namespace of smize
- .il8n :
object
- .addDictionaryKey(dictionaryKey) ⇒
boolean
- .addDictionaryKeys(dictionaryKeys) ⇒
boolean
- .formatDate(date, language) ⇒
string
- .formatDateString(dateString, language) ⇒
string
- .formatNumber(numberValue, language, options) ⇒
string
- .getKeyValue(dictionaryKeyName, language) ⇒
string
- .setKeyValue(dictionaryKeyName, language, value) ⇒
boolean
- .addDictionaryKey(dictionaryKey) ⇒
boolean
il8n.addDictionaryKey(dictionaryKey) ⇒ Adds a single dictionary key to the DICTIONARY; key format (provide as many language/country values as needed):
{
"name": "A unique name for the dictionary key",
"en": "A default English value; use ISO 639-1 values for the language code",
"en-US": "The US English value; use IETF language tags"
}
Kind: static method of il8n
Returns: boolean
- Was the key successfully added?
Param | Type | Description |
---|---|---|
dictionaryKey | object |
The dictionary key to add |
boolean
il8n.addDictionaryKeys(dictionaryKeys) ⇒ Adds a collection of dictionary keys to the DICTIONARY; key format (provide as many language/country values as needed):
{
"name": "A unique name for the dictionary key",
"en": "A default English value; use ISO 639-1 values for the language code",
"en-US": "The US English value; use IETF language tags"
}
Kind: static method of il8n
Returns: boolean
- Were the key successfully added?
Param | Type | Description |
---|---|---|
dictionaryKeys | array |
The dictionary keys to add |
string
il8n.formatDate(date, language) ⇒ Formats an instance of Date as a localized string for a given language
Kind: static method of il8n
Returns: string
- The formatted date
Param | Type | Description |
---|---|---|
date | Date |
The date to format |
language | string |
The language/locale to format the date for |
string
il8n.formatDateString(dateString, language) ⇒ Formats a date string for a given language
Kind: static method of il8n
Returns: string
- The formatted date or an empty string
Param | Type | Description |
---|---|---|
dateString | string |
The date to format |
language | string |
The language/locale to format the date for |
string
il8n.formatNumber(numberValue, language, options) ⇒ Formats a number for display in a given language
Kind: static method of il8n
Returns: string
- The formatted number or an empty string
Param | Type | Description |
---|---|---|
numberValue | number | string |
The number to format, either a number or a string |
language | string |
The language/locale to format the number for |
options | object |
Configuration to tell the localization how to format the number, defaults to { style: 'decimal' } |
string
il8n.getKeyValue(dictionaryKeyName, language) ⇒ Retrieves the localized value for the given dictionary key
Kind: static method of il8n
Returns: string
- The dictionary key value or an empty string
Param | Type | Description |
---|---|---|
dictionaryKeyName | string |
The name of the dictionary key to retrieve |
language | string |
The language/locale to retrieve the value for |
boolean
il8n.setKeyValue(dictionaryKeyName, language, value) ⇒ Updates the value of a given dictionary key for the specified language
Kind: static method of il8n
Returns: boolean
- Was the dictionary key updated?
Param | Type | Description |
---|---|---|
dictionaryKeyName | string |
The name of the dictionary key to set |
language | string |
The language/locale to set the value for |
value | string |
The new value for the dictionary key |
object
smize.responsive : Provides utilities for handling responsive behavior
Kind: static namespace of smize
- .responsive :
object
- .currentBreakpoint
- .addBreakpoint(breakpointName, breakpointSettings) ⇒
boolean
- .addSubscriber(breakpointNames, subscriberFunction) ⇒
boolean
- .bindEventHandlers() ⇒
boolean
- .getBreakpoint(breakpointName) ⇒
object
- .getCurrentBreakpoints(viewport) ⇒
Array
- .getSubscriberCount(breakpointName) ⇒
number
- .removeBreakpoint(breakpointName) ⇒
boolean
responsive.currentBreakpoint
Kind: static property of responsive
Properties
Name | Type | Description |
---|---|---|
currentBreakpoint | object |
The current breakpoint object - defaults to the best match |
boolean
responsive.addBreakpoint(breakpointName, breakpointSettings) ⇒ Adds a breakpoint to handle specific screen information
Kind: static method of responsive
Returns: boolean
- Was the named breakpoint added?
Param | Type | Description |
---|---|---|
breakpointName | string |
the name of the breakpoint to add |
breakpointSettings | object |
The settings for the breakpoint, accepted settings (only width and height are needed):
|
boolean
responsive.addSubscriber(breakpointNames, subscriberFunction) ⇒ Adds a subscriber to one or more breakpoints Consumers can subscribe individually without this method See: smize.events.subscribe
Kind: static method of responsive
Returns: boolean
- Was the subscription successful?
Param | Type | Description |
---|---|---|
breakpointNames | object |
A string, comma-separated list, or Array of breakpointNames |
subscriberFunction | function |
The subscriber function to add to each |
boolean
responsive.bindEventHandlers() ⇒ Binds the responsive event handlers to manage breakpoints This is consumer-initialized to ensure additional breakpoints are added first
Kind: static method of responsive
Returns: boolean
- Were the event handlers bound?
object
responsive.getBreakpoint(breakpointName) ⇒ Returns the named breakpoint
Kind: static method of responsive
Returns: object
- The breakpoint
Param | Type | Description |
---|---|---|
breakpointName | string |
The name of the breakpoint to retrieve |
Array
responsive.getCurrentBreakpoints(viewport) ⇒ Returns all breakpoints that match the current viewport
Kind: static method of responsive
Returns: Array
- A collection of matching viewports
Param | Type | Description |
---|---|---|
viewport | object |
An optional viewport object to evaluate breakpoints for |
number
responsive.getSubscriberCount(breakpointName) ⇒ Returns a count of subscribers for a given breakpoint
Kind: static method of responsive
Returns: number
- The subscriber count for the breakpoint
Param | Type | Description |
---|---|---|
breakpointName | string |
The name of the breakpoint |
boolean
responsive.removeBreakpoint(breakpointName) ⇒ Removes the given breakpoint from the list of breakpoints to handle
Kind: static method of responsive
Returns: boolean
- Was the named breakpoint removed?
Param | Type | Description |
---|---|---|
breakpointName | string |
The name of the breakpoint to remove |
object
smize.ui : Provides helper methods and generic user interface classes to be extended
Kind: static namespace of smize
- .ui :
object
- .bindModule(element) ⇒
boolean
- .bindScope(scope, deferSelector) ⇒
boolean
- .registerModule(moduleName, ClassReference, defaultConfiguration) ⇒
boolean
- .bindModule(element) ⇒
boolean
ui.bindModule(element) ⇒ Determines which module to bind to an element and performs binding
Kind: static method of ui
Returns: boolean
- Was the element successfully bound?
Param | Type | Description |
---|---|---|
element | object |
The element to bind |
boolean
ui.bindScope(scope, deferSelector) ⇒ Binds all elements within the provided scope with the [data-module]
attribute to the appropriate module
Kind: static method of ui
Returns: boolean
- Was the scope successfully bound?
Param | Type | Description |
---|---|---|
scope | object |
The HTML element to search for module elements within |
deferSelector | string |
An optional selector to filter items you don't wish to bind |
boolean
ui.registerModule(moduleName, ClassReference, defaultConfiguration) ⇒ Registers a module for binding
Kind: static method of ui
Returns: boolean
- Was the module successfully registered?
Param | Type | Description |
---|---|---|
moduleName | string |
The name of the module to register |
ClassReference | class |
The reference to the class to bind |
defaultConfiguration | object |
A default configuration to pass to new instances |
object
smize.utils : Provides generic utilities
Kind: static namespace of smize
- .utils :
object
- .arrayFromArrayLike(arrayLike) ⇒
array
- .objectFromString(string) ⇒
object
- .replaceTokens(originalString, tokenSources, removeRemainder) ⇒
string
- .resolveBits(bits, expectedType, root) ⇒
object
- .stringFromObject(obj) ⇒
string
- .arrayFromArrayLike(arrayLike) ⇒
array
utils.arrayFromArrayLike(arrayLike) ⇒ Creates an array from an array-like, including comma-separated strings
Kind: static method of utils
Returns: array
- An array created from the array-like
Param | Type | Description |
---|---|---|
arrayLike | object |
The array-like to turn into an array |
object
utils.objectFromString(string) ⇒ Attempts to parse a valid object from a string representation
Kind: static method of utils
Returns: object
- The parsed object or null
Param | Type | Description |
---|---|---|
string | string |
The string to parse as an object |
string
utils.replaceTokens(originalString, tokenSources, removeRemainder) ⇒ Replaces tokens in the {token}
format with key values from one or more objects
Kind: static method of utils
Returns: string
- The new string with all tokens replaced
Param | Type | Description |
---|---|---|
originalString | string |
The string to perform the token replacement on |
tokenSources | object |
One or more objects to find tokens in |
removeRemainder | boolean |
Remove the remaining tokens, defaults to false |
object
utils.resolveBits(bits, expectedType, root) ⇒ Traverses an object to resolve the dot-notated bits as nested items
Kind: static method of utils
Returns: object
- The type-correct bit or null
Param | Type | Description |
---|---|---|
bits | string |
The bits to resolve |
expectedType | string |
The expected type of the final bit, defaults to object |
root | object |
The root object to traverse, defaults to window |
string
utils.stringFromObject(obj) ⇒ Attempts to create a string representation of an object
Kind: static method of utils
Returns: string
- The string representation of the object or ''
Param | Type | Description |
---|---|---|
obj | object |
The object to stringify |
object
smize.valid : Provides generic utilities for validation
Kind: static namespace of smize
- .valid :
object
- .isDocumentValid() ⇒
boolean
- .isFalsy(value) ⇒
boolean
- .isOfType(value, checkType) ⇒
boolean
- .isTruthy(value) ⇒
boolean
- .isValidArray(value) ⇒
boolean
- .isValidCountryCode(countryCode) ⇒
boolean
- .isValidObject(value) ⇒
boolean
- .isValidString(value) ⇒
boolean
- .isWindowValid() ⇒
boolean
- .validBoolean(value, defaultValue) ⇒
boolean
- .validNumber(value, defaultValue) ⇒
number
- .validObject(value, defaultValue) ⇒
object
- .validString(value, defaultValue) ⇒
string
- .isDocumentValid() ⇒
boolean
valid.isDocumentValid() ⇒ Determines if the document
object is available
Kind: static method of valid
Returns: boolean
- Is document
valid?
boolean
valid.isFalsy(value) ⇒ Quickly determine if a value is falsy
Kind: static method of valid
Returns: boolean
- Was the value falsy?
Param | Type | Description |
---|---|---|
value | object |
The value to verify |
boolean
valid.isOfType(value, checkType) ⇒ Checks that an object is of the desired type
Kind: static method of valid
Returns: boolean
- Is the value of the requested type?
Param | Type | Description |
---|---|---|
value | object |
The value to verify |
checkType | string |
The type to check the value against |
boolean
valid.isTruthy(value) ⇒ Quickly determine if a value is truthy
Kind: static method of valid
Returns: boolean
- Was the value truthy?
Param | Type | Description |
---|---|---|
value | object |
The value to verify |
boolean
valid.isValidArray(value) ⇒ Determines if an object is an array-like
Kind: static method of valid
Returns: boolean
- Is the value an array-like?
Param | Type | Description |
---|---|---|
value | object |
The value to verify |
boolean
valid.isValidCountryCode(countryCode) ⇒ Determines if a value is a valid country code string
Kind: static method of valid
Returns: boolean
- Was the input a valid country code?
Param | Type | Description |
---|---|---|
countryCode | object |
The value to test as a valid country code |
boolean
valid.isValidObject(value) ⇒ Determines is of type 'object'
and non-null
Kind: static method of valid
Returns: boolean
- Is the value a valid object?
Param | Type | Description |
---|---|---|
value | object |
The value to verify |
boolean
valid.isValidString(value) ⇒ Determines is of type 'string'
and non-empty
Kind: static method of valid
Returns: boolean
- Is the value a string?
Param | Type | Description |
---|---|---|
value | object |
The value to verify |
boolean
valid.isWindowValid() ⇒ Determines if the window
object is available
Kind: static method of valid
Returns: boolean
- Is window
valid?
boolean
valid.validBoolean(value, defaultValue) ⇒ Generates a valid boolean
Kind: static method of valid
Returns: boolean
- The resulting boolean value
Param | Type | Description |
---|---|---|
value | object |
The value to validate as a boolean |
defaultValue | object |
An optional default value to return |
number
valid.validNumber(value, defaultValue) ⇒ Generates a valid number
Kind: static method of valid
Returns: number
- The resulting number value
Todo
- Eliminate try/catch
Param | Type | Description |
---|---|---|
value | object |
The value to validate as a number |
defaultValue | object |
An optional default value to return |
object
valid.validObject(value, defaultValue) ⇒ Generates a valid object
Kind: static method of valid
Returns: object
- The resulting object
Todo
- Eliminate try/catch
Param | Type | Description |
---|---|---|
value | object |
The value to validate as an object-type |
defaultValue | object |
An optional default value to return |
string
valid.validString(value, defaultValue) ⇒ Generates a valid string
Kind: static method of valid
Returns: string
- The resulting string value
Param | Type | Description |
---|---|---|
value | object |
The value to validate as a string |
defaultValue | object |
An optional default value to return |
object
smize.ns(bitParts, root) ⇒ Builds a namespace with strict rules around extension
Kind: static method of smize
Returns: object
- A namespace instance to extend
Param | Type | Description |
---|---|---|
bitParts | string |
The dot-notated namespace bits to split |
root | object |
The root object to extend |