Skip to content

A simple collection of functionality for the Kony SDK

Notifications You must be signed in to change notification settings

Phil-Venter/enhance-kony

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

enhance-kony

A simple collection of functionality for the Kony SDK. I personally use this and Krōnin by Miguelángel Fernández.

kony.ui

fontAwesome

returns: object

An object that contains "The complete set of 675 icons in Font Awesome 4.7.0" found here

Accessing it is relatively easy

// access fa-user-circle icon
kony.ui.fontAwesome['fa-user-circle']
// access fa-sitemap icon
kony.ui.fontAwesome['fa-sitemap']

generateComponent(string, object, object, object, object)

returns: object

A function that generates components much like calling kony.ui.<component name here>(...) would. What makes this function different is that it is more geared towards applying additional properties.

Traditional way of creating button and setting it's width and adding an onClick method:

const btn = new kony.ui.Button(...);
btn.width = '100dp';
btn.onClick = <some function>

This library's way of doing so:

const btn = kony.ui.generateComponent('Button', ..., {
  width: '100dp',
  onClick: <some function>
});

In the end it boils down to preference...

kony.utils

getType(any)

returns: string

typeof is very limited in its use some might even call it broken, Angus Croll is one of them read more. This uses his code that aims to fix that issue.

typeof {a: 4}; //"object"
typeof [1, 2, 3]; //"object"
typeof new ReferenceError; //"object"
typeof new Date; //"object"
typeof /a-z/; //"object"
typeof Math; //"object"
typeof JSON; //"object"
typeof new Number(4); //"object"
typeof new String("abc"); //"object"
typeof new Boolean(true); //"object"

kony.utils.getType({a: 4}); //"object"
kony.utils.getType([1, 2, 3]); //"array"
kony.utils.getType(new ReferenceError); //"error"
kony.utils.getType(new Date); //"date"
kony.utils.getType(/a-z/); //"regexp"
kony.utils.getType(Math); //"math"
kony.utils.getType(JSON); //"json"
kony.utils.getType(new Number(4)); //"number"
kony.utils.getType(new String("abc")); //"string"
kony.utils.getType(new Boolean(true)); //"boolean"

isArray(any)

returns: boolean

checks to see if passed variable is an array, uses kony.utils.getType(...) internally.

isBoolean(any)

returns: boolean

checks to see if passed variable is a boolean, uses kony.utils.getType(...) internally.

isDate(any)

returns: boolean

checks to see if passed variable is a date instance, uses kony.utils.getType(...) internally.

isEmpty(any)

returns: boolean

checks to see if passed variable is empty (falsey).

isError(any)

returns: boolean

checks to see if passed variable is an error instance, uses kony.utils.getType(...) internally.

isFunction(any)

returns: boolean

checks to see if passed variable is a function, uses kony.utils.getType(...) internally.

isNull(any)

returns: boolean

checks to see if passed variable is null, uses kony.utils.getType(...) internally.

isNumber(any)

returns: boolean

checks to see if passed variable is a number, uses kony.utils.getType(...) internally.

isObject(any)

returns: boolean

checks to see if passed variable is an object, uses kony.utils.getType(...) internally.

isRegExp(any)

returns: boolean

checks to see if passed variable is a regular expression instance, uses kony.utils.getType(...) internally.

isString(any)

returns: boolean

checks to see if passed variable is a string, uses kony.utils.getType(...) internally.

isType(any, string)

returns: boolean

checks to see if passed variable is of type passed, uses kony.utils.getType(...) internally.

isUndefined(any)

returns: boolean

checks to see if passed variable is undefined, uses kony.utils.getType(...) internally.

prePad(any, string)

returns: string

uses the second parameter as a template and prepends that to the first parameter, used internally in kony.utils.transformDate(...).

prePad(1, '0000') // '0001'
prePad('hello', '0000') // 'hello'
prePad('hello', '000000') // '0hello'

transformDate(date)

returns: string

converts the passed date object to the format used by MSSQL as it differs slightly from Date.prototype.toISOString() the ISO 8601 Extended Format JavaScript follows.

About

A simple collection of functionality for the Kony SDK

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published