ku4es-ui-kernel

kodmunki Utilities for ECMAScript UI Kernel

Usage no npm install needed!

<script type="module">
  import ku4esUiKernel from 'https://cdn.skypack.dev/ku4es-ui-kernel';
</script>

README

Classes

Cookie
Dto
Device
Document
Event
Key
Keyboard
Swipe
Store

Objects

form : object
string : object

Functions

worker(func)Worker

Cookie

Kind: global class
Summary: serializes, deserializes, and reads browser cookies.

Cookie.serialize(value, [params]) ⇒ string

Kind: static method of Cookie
Access: public

Param Type Description
value Object Data to be serialized
[params] Object Cookie parameters
[params.name] string Cookie name
[params.expires] Date Cookie expiry date
[params.path] string Cookie path
[params.domain] string Cookie domain
[params.secure] boolean Sets cookie to 'secure' when true

Cookie.deserialize(value) ⇒ *

Kind: static method of Cookie
Access: public

Param Type
value string

Cookie.read(value) ⇒ Object

Kind: static method of Cookie
Summary: Read data stored in a cookie
Access: public

Param Type Description
value string Browser cookie to read.

Dto

Kind: global class
Summary: A powerful data object that can parse and serialize JavaScript data into multiple formats: JSON, Query String, Form Data, JWT, base64.

dto.value ⇒ * | Object

Kind: instance property of Dto
Access: public

dto.name ⇒ string

Kind: instance property of Dto
Access: public

dto.name

Kind: instance property of Dto
Access: public

Param Type
value string

dto.read([key]) ⇒ *

Kind: instance method of Dto
Summary: Return value for key or all values if not passed.
Access: public

Param Type
[key] string | number

dto.remove(key) ⇒ Dto

Kind: instance method of Dto
Summary: Remove value at key
Access: public

Param Type
key string | function

dto.write(key, value) ⇒ Dto

Kind: instance method of Dto
Summary: Write value to key
Access: public

Param
key
value

dto.update(value) ⇒ Dto

Kind: instance method of Dto
Summary: Update data with passed data
Access: public

Param
value

dto.clear() ⇒ Dto

Kind: instance method of Dto
Summary: Clears all data from this Dto. It does not remove this Dto from persistent storage.
Access: public

dto.encode([stripPadding], [unsafe]) ⇒ string | undefined

Kind: instance method of Dto
Summary: Returns a base64 encoded string containg the value of of this Dto.
Access: public

Param Type Default Description
[stripPadding] boolean false Will strip base64 padding when true.
[unsafe] boolean false Will escape special characters when encoding preventing erroneous errors in some cases, but making the value unsafe for transfer and decoding outside of Dto as special characters will have to be unescaped after decoding.

dto.toFormData() ⇒ FormData

Kind: instance method of Dto
Summary: Returns Dto as FormData
Access: public

dto.toJson() ⇒ string

Kind: instance method of Dto
Summary: Returns Dto as JSON
Access: public

dto.toQueryString() ⇒ string

Kind: instance method of Dto
Summary: Returns Dto as query string
Access: public

Dto.decode(value, [name]) ⇒ Dto

Kind: static method of Dto
Summary: Returns a new Dto having value of the passed base64 encoded string.
Access: public

Param Type Description
value string Initial value for the returned Dto.
[name] string Name for the returned Dto.

Dto.parseFormData(value) ⇒ Dto

Kind: static method of Dto
Summary: Parse a Dto from FormData
Access: public

Param
value

Dto.parseJson(value) ⇒ Dto

Kind: static method of Dto
Summary: Parse a Dto from JSON data
Access: public

Param
value

Dto.parseJwt(value) ⇒ any

Kind: static method of Dto
Summary: Parse a Dto from a JWT
Access: public

Param
value

Dto.parseQueryString(value) ⇒ Dto

Kind: static method of Dto
Summary: Parse a Dto from a query string
Access: public

Param
value

Device

Kind: global class
Summary: Device abstraction

Device.orientation ⇒ string

Kind: static property of Device
Summary: Returns the current Device orientation which can be tested against the available Device orientation constants to determine the orientation of the device.
Access: public

Device.landscapePrimary ⇒ string

Kind: static property of Device
Summary: Constant to test if device is oriented in landscape.
Access: public

Device.landscapeSecondary ⇒ string

Kind: static property of Device
Summary: Constant to test if device is oriented in landscape.
Access: public

Device.portraitPrimary ⇒ string

Kind: static property of Device
Summary: Constant to test if device is oriented in portrait.
Access: public

Device.portraitSecondary ⇒ string

Kind: static property of Device
Summary: Constant to test if device is oriented in portrait and upside-down.
Access: public

Device.isMobile ⇒ boolean

Kind: static property of Device
Summary: Returns true if device is mobile.
Access: public

Document

Kind: global class
Summary: Document abstraction

Document.scrollbarWidth ⇒ number

Kind: static property of Document
Summary: Width of the scrollbar
Access: public

Document.isScrollPrevented ⇒ boolean

Kind: static property of Document
Summary: Returns true if document scrolling is prevented
Access: public

Document.scroll ⇒ Scroll

Kind: static property of Document
Summary: Gets the Document Scroll instance that can be queried to determine scroll direction: left, right, up, down.
Access: public

Document.preventScroll()

Kind: static method of Document
Summary: Prevents document from being scrollable
Access: public

Document.resumeScroll()

Kind: static method of Document
Summary: Resumes scrollability for document after being rendered unscrollable.
Access: public

Document.onPreventScroll(method)

Kind: static method of Document
Summary: Adds a method to call when scroll is prevented.
Access: public

Param Type
method function

Document.onResumeScroll(method)

Kind: static method of Document
Summary: Adds a method to call when scroll is resumed.
Access: public

Param Type
method function

Document.on(event, key, method, options) ⇒ Object

Kind: static method of Document
Summary: Subscribes to keyboard event
Returns: Object - - method to call to unsubscribe target listener from keyboard.
Access: public

Param Type
event
key Key
method function
options Object

Document.onKeyPress(key, method, options) ⇒ Object

Kind: static method of Document
Summary: Subscribes to keyboard keypress event
Returns: Object - - method to call to unsubscribe target listener from keyboard.
Access: public

Param Type
key Key
method function
options Object

Document.onKeyDown(key, method, options) ⇒ Object

Kind: static method of Document
Summary: Subscribes to keyboard keydown event
Returns: Object - - method to call to unsubscribe target listener from keyboard.
Access: public

Param Type
key Key
method function
options Object

Document.onKeyUp(key, method, options) ⇒ Object

Kind: static method of Document
Summary: Subscribes to keyboard keyup event
Returns: Object - - method to call to unsubscribe target listener from keyboard.
Access: public

Param Type
key Key
method function
options Object

Event

Kind: global class
Summary: Event abstraction

Event.mute(event) ⇒ boolean

Kind: static method of Event
Summary: Hard stops any further activity from passed event.
Access: public

Param Type Description
event Event Event to hard stop.

Key

Kind: global class
Summary: Keyboard Key abstraction

new Key(MDNKeyIdentifier, [MSKeyIdentifier])

Param Type Description
MDNKeyIdentifier String The MDN Key Identifier https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values
[MSKeyIdentifier] String The Microsoft Key Identifier for those keys that have browser specific implementations for MS https://msdn.microsoft.com/en-us/ie/gg305568(v=vs.94)

key.alt ⇒ Key

Kind: instance property of Key
Summary: Returns Key with alt.
Returns: Key - - Key with alt
Access: public

key.ctrl ⇒ Key

Kind: instance property of Key
Summary: Returns Key with ctrl.
Returns: Key - - Key with ctrl
Access: public

key.meta ⇒ Key

Kind: instance property of Key
Summary: Returns Key with meta.
Returns: Key - - Key with meta
Access: public

key.shift ⇒ Key

Kind: instance property of Key
Summary: Returns Key with shift.
Returns: Key - - this Key with shift
Access: public

key.equals(other) ⇒ boolean

Kind: instance method of Key
Summary: Returns true if this Key equals other.
Access: public

Param Type
other Key

key.didFire(event) ⇒ boolean

Kind: instance method of Key
Summary: Returns true if this Key did fire event.
Access: public

Param Type
event KeyboardEvent

Key.press ⇒ Key

Kind: static property of Key
Summary: Returns a Key action keypress.
Access: public

Key.down ⇒ Key

Kind: static property of Key
Summary: Returns a Key action keydown.
Access: public

Key.up ⇒ Key

Kind: static property of Key
Summary: Returns a Key action keyup.
Access: public

Key.any ⇒ Key

Kind: static property of Key
Summary: Returns a Key that will equal any other Key.
Access: public

Key.esc ⇒ Key

Kind: static property of Key
Summary: Returns Key, Esacpe.
Access: public

Key.enter ⇒ Key

Kind: static property of Key
Summary: Returns Key, Enter.
Access: public

Key.space ⇒ Key

Kind: static property of Key
Summary: Returns Key, Space.
Access: public

Key.tab ⇒ Key

Kind: static property of Key
Summary: Returns Key, Tab.
Access: public

Key.left ⇒ Key

Kind: static property of Key
Summary: Returns Key, Left Arrow.
Access: public

Key.right ⇒ Key

Kind: static property of Key
Summary: Returns Key, Right Arrow.
Access: public

Keyboard

Kind: global class
Summary: a global keyboard abstraction

Swipe

Kind: global class
Summary: Encapsulates touch event management.

new Swipe(element, tolerance)

Param Type Description
element Element Element that will listen for swipe events.
tolerance number The distance in pixels a swipe must travel to trigger a swipe event.

swipe.onLeft(method) ⇒ this

Kind: instance method of Swipe
Summary: Subscribes method to be called when user swipes left.
Access: public

Param Type
method function

swipe.onRight(method) ⇒ this

Kind: instance method of Swipe
Summary: Subscribes method to be called when user swipes right.
Access: public

Param Type
method function

swipe.onMove(method) ⇒ this

Kind: instance method of Swipe
Summary: Subscribes method to be called when user swipes.
Access: public

Param Type
method function

swipe.destroy() ⇒ this

Kind: instance method of Swipe
Summary: Clean up all potential memory leaks.
Access: public

Store

Kind: global class
Summary: Global persistent data store.

Store.connected

Kind: static property of Store
Summary: Returns true when Store is connected to data store.
Access: public

Store.connect()

Kind: static method of Store
Summary: Connect Store to data store.
Access: public

Store.disconnect()

Kind: static method of Store
Summary: Disconnect Store from data store.
Access: public

Store.read(name) ⇒ Promise.<*>

Kind: static method of Store
Summary: Read data from collection with name.
Access: public

Param Type Description
name string Name of target collection.

Store.write(name, data) ⇒ Promise.<*>

Kind: static method of Store
Summary: Write data to the collection with name.
Access: public

Param Type Description
name string Name of target collection.
data * Data to write to collection

Store.remove(name) ⇒ Promise.<*>

Kind: static method of Store
Summary: Remove collection with name.
Access: public

Param Type Description
name string Name of target collection.

Store.delete(name) ⇒ Promise.<*>

Kind: static method of Store
Summary: Delete collection with name.
Access: public

Param Type Description
name string Name of target collection.

Store.save() ⇒ Promise.<*>

Kind: static method of Store
Summary: Save Store (Requires secure connection, i.e. HTTPS)
Access: public

Store.estimate() ⇒ Promise.<*>

Kind: static method of Store
Summary: Storage estimates.
Access: public

Store.saved() ⇒ Promise.<*>

Kind: static method of Store
Summary: True if the Store is saved.
Access: public

form : object

Kind: global namespace

form.readData(form) ⇒ FormData

Kind: static method of form
Summary: Reads data as FormData from a form.

Param Type Description
form HTMLFormElement the form to read.

form.read(form) ⇒ Object

Kind: static method of form
Summary: Reads data as an object of key value pairs from a form. Where the keys are the names of each field and the values are the value of these fields.

Param Type Description
form HTMLFormElement the form to read.

form.readJson(form) ⇒ string

Kind: static method of form
Summary: Reads data as JSON of key value pairs from a form. Where the keys are the names of each field and the values are the value of these fields.

Param Type Description
form HTMLFormElement the form to read.

form.write(form, data)

Kind: static method of form
Summary: Write data as an object to a form. Where the keys are the names of each field and the values are the value of these fields.

Param Type Description
form HTMLFormElement the form to write to.
data Object

string : object

Kind: global namespace

string.encodeBase64(string, [stripPadding]) ⇒ string

Kind: static method of string
Summary: Base64 encodes a string.

Param Type Description
string string string to encode
[stripPadding] boolean return value will have base64 padding characters stripped when true.

string.exports.decodeBase64(string) ⇒ string

Kind: static method of string
Summary: Decodes Base64 encoded string.

Param Type Description
string string string to decode.

string.exports.encodeUtf8(string) ⇒ string

Kind: static method of string
Summary: UTF8 encodes a string.

Param Type Description
string string string to encode

string.exports.decodeUtf8(string) ⇒ string

Kind: static method of string
Summary: Decodes UTF8 encoded string.

Param Type Description
string string string to decode.

worker(func) ⇒ Worker

Kind: global function
Summary: Returns a new Worker that runs the logic of the passed function.

Param Type Description
func function Function containing the logic to be run in the Worker.