Contains helper methods and properties
Members
-
<static> deviceType :"desktop"|"phone"|"tablet"
-
Contains user's device type. This detection has been performed using only user agent. If you want to implement something that relies on actual device type, consider performing feature detection by yourself. Otherwise, use this property to maintain consistent look and feel.
Type:
- "desktop" | "phone" | "tablet"
-
<static> isChrome :boolean
-
Indicates whether user's browser is Chrome.
Type:
- boolean
-
<static> isElectron
-
Indicates whether this library is running inside Electron.
This is based on user agent:
navigator.userAgent.indexOf('Electron') !== -1If you've modified user agent, feel free to change this field too.
-
<static> isIE :boolean
-
Indicates whether user's browser is IE (any version).
Type:
- boolean
-
<static> isIE11 :boolean
-
Indicates whether user's browser is IE11.
Type:
- boolean
-
<static> isIElte9 :boolean
-
Indicates whether user's browser is IE9 or older.
Type:
- boolean
-
<static> isMobile :boolean
-
Equals to
deviceType === "phone"Type:
- boolean
-
<static> localStorage :WindowLocalStorage
-
By default, points to window.localStorage. If user's browser doesn't support LocalStorage, will use temporary "polyfill" which acts like LocalStorage but doesn't actually save anything.
Type:
- WindowLocalStorage
-
<static> mergeOptions
-
Merges two options into one object without modifying them. It checks if property is present in the
defaultOptions,defaultOptionsshould contain ALL the needed properties. -
<static> supportsBlob :boolean
-
Indicates whether user's browser supports Blob or not
Type:
- boolean
-
<static> supportsDataURL :boolean
-
If user's browser doesn't support Data URLs (URLs in form:
data:[<mediatype>][;base64],<data>), this will true. Otherwise will be false.Type:
- boolean
-
<static> supportsFlexbox :boolean
-
Indicates whether user's browser supports flexbox.
Type:
- boolean
Methods
-
<static> createDataURL(filename, mediatype, encoding, data, notifyIfCantKeepExtension)
-
Makes browser download data by creating data URL.
Parameters:
Name Type Description filenamestring Name of the file to save
mediatypestring Data URL media type
encodingstring Data or text encoding
datastring Data itself
notifyIfCantKeepExtensionboolean If user's browser can't keep extension, notify them about it
-
<static> dispatchEvent(object, type)
-
Dispatches event of given type to given object.
Parameters:
Name Type Description objectObject Object to dispatch event to
typestring Type of event
-
<static> formatNumber(number)
-
Formats number to more readable format by inserting spaces
Parameters:
Name Type Description numbernumber | string Number to format
Returns:
Formatted number
- Type
- string
-
<static> generateID()
-
Generates random and unique ID
Returns:
Generated ID
- Type
- string
-
<static> getFileExtension(filename)
-
Finds extension of the given filename, i.e. part after last dot.
Parameters:
Name Type Description filenamestring Filaname
Returns:
Extension
- Type
- string
-
<static> HTMLToElement(html, appendTo)
-
Parses given HTML and appends it to given element as a child
Parameters:
Name Type Description htmlstring HTML to parse
appendToElement Element to append parsed HTML to
-
<static> isObjectEmpty(object)
-
Checks if given object is empty
Parameters:
Name Type Description objectObject Object to check
Returns:
True, if object is empty. False otherwise.
- Type
- boolean
-
<static> makeCollapsible(button, element, clickAfter)
-
Makes an element collapsible with an animation.
Parameters:
Name Type Description buttonHTMLElement Button that will show or collapse an element
elementHTMLElement Element to make collapsible
clickAfterboolean If true, button will be clicked when everything's applied.
-
<static> makeHideable(button, element, onHideCallback, onShowCallback, clickAfter)
-
Makes button hide or show element on click. Both button and element will have attribute "data-hidden" equal to 0 or 1.
Parameters:
Name Type Description buttonElement Button that will control visibility of the element.
elementElement Element that will be controlled
onHideCallbackfunction Function to call on hiding
onShowCallbackfunction Function to call on showing
clickAfterboolean If true, button will be clicked after all the things will be applied. You may want to set it to false if your callbacks affects unfinished stuff.
-
<static> notifyIfDataURLIsNotSupported(extension)
-
Displays notification if Data URL is not supported
Parameters:
Name Type Description extensionstring file extension to display in notification
-
<static> readTextFile(fileInput, notSupportedNotification, callback)
-
Reads file opened on fileInput as text, calls given callback and passes text to it
Parameters:
Name Type Description fileInputHTMLInputElement File input to read file from
notSupportedNotificationstring If user's browser doesn't support reading text files, this notification will be presented.
callbackfunction Callback to pass text to
-
<static> saveAsText(string, filename)
-
Saves string as text
Parameters:
Name Type Description stringstring String to save
filenamestring Name of the file to save