new Util()
- Description:
UI common tools
Members
MEDIA_SIZE
- Description:
Media sizes (XS=576, SM=768, MD=992, LG=1200) mobile | tablet | medium | large
Media sizes (XS=576, SM=768, MD=992, LG=1200) mobile | tablet | medium | large
screenSize
- Description:
Current screen size
{w,h}
Current screen size {w,h}
Methods
addImagesPromise(p, ctn)
- Description:
Append a promise to wait for all async images (exclude sized .icon by css)
Parameters:
Name | Type | Description |
---|---|---|
p |
Object | Array | context parameters with array of promises |
ctn |
jQuery | images container |
addPromise(p, f)
- Description:
Append a promise to parameters
Parameters:
Name | Type | Description |
---|---|---|
p |
Object | Array | context parameters with array of promises |
f |
Promise | function | a promise or a function(resolve, reject) |
concatMessages(r)
- Description:
Concat all backend messages
Parameters:
Name | Type | Description |
---|---|---|
r |
response with message or messages |
copyToClipboard(text, silent)
- Description:
Copy a text to clipboard
Parameters:
Name | Type | Description |
---|---|---|
text |
string | Text to copy |
silent |
boolean | True to hide the toast |
decodeImage(buffer, {function)
- Description:
Convert bytes to Image (supports gif, png and jpeg)
Parameters:
Name | Type | Description |
---|---|---|
buffer |
Array | Image as bytes |
{function |
onload Optional callback |
dispatchMessages(messages, obj)
- Description:
Set visible field messages and returns other/head messages
Parameters:
Name | Type | Description |
---|---|---|
messages |
Array.<string> | Array.<Object> | Backend messages |
obj |
Simplicite.UI.BusinessObject | Optional object to affect message when #field matches |
dontAskAgain()
- Description:
Don't ask again a question'
findAction(o, name, list, plus)
- Description:
Find an action in plain or plus actions
Parameters:
Name | Type | Description |
---|---|---|
o |
Simplicite.UI.BusinessObject | Object |
name |
string | Action name |
list |
Array.<Object> | List of actions |
plus |
Array.<Object> | List of 'plus' actions |
getFileIcon()
- Description:
Get icon from the file name
gotoDefinition(name, id)
- Description:
Open one object definition if granted
Parameters:
Name | Type | Description |
---|---|---|
name |
string | Object name (Field...) |
id |
string | Object id |
isMediaDesktop()
- Description:
Is the media a desktop ?
isMediaMobile()
- Description:
Is the media a mobile ?
isMediaTablet()
- Description:
Is the media a tablet ?
isServiceLost()
- Description:
Test if the service is loadt
keysLabel(keys)
- Description:
Translate sort keys
Parameters:
Name | Type | Description |
---|---|---|
keys |
string | Ctrl+Shift+Alt+Left... |
mediaSize(w)
- Description:
Get the media size
Parameters:
Name | Type | Description |
---|---|---|
w |
number | viewport width |
Returns:
media size
mousePos(e, o)
- Description:
Get the mouse/touch position
{x,y}
on screen
Parameters:
Name | Type | Description |
---|---|---|
e |
Object | Mouse or touch event |
o |
Object | Optional offset |
randomString(len)
- Description:
Random string
Parameters:
Name | Type | Description |
---|---|---|
len |
Length |
Returns:
Random string of specified length
readCookie(name)
- Description:
Read a cookie
Parameters:
Name | Type | Description |
---|---|---|
name |
string | cookie name |
readField(ctn, obj, f, index, cbk)
- Description:
Read the form field into object field (async/file reading)
- Deprecated:
- Yes
Parameters:
Name | Type | Description |
---|---|---|
ctn |
string | jQuery | Container to find field |
obj |
Simplicite.UI.BusinessObject | Optional business object |
f |
Simplicite.Ajax.ObjectField | Business field |
index |
string | Optional index of field (list edit) |
cbk |
function | Callback when readed |
readFile(file, cbk, output, progress, optional)
- Description:
Read a form input file
Parameters:
Name | Type | Description |
---|---|---|
file |
Object | Input file (jQuery, input or file) |
cbk |
function | Required callback |
output |
string | Base64 (default) | ArrayBuffer | File |
progress |
function | Optional progress callback(loaded, total, percent) |
optional |
number | size limit (Mo) 0:no error or null=MAX_UPLOAD_SIZE |
resize(force)
- Description:
Resize window handler
Parameters:
Name | Type | Description |
---|---|---|
force |
boolean | True to force a full redraw |
timeoutPromise(p, timeout, ex)
- Description:
Execute a promise with a timeout
Parameters:
Name | Type | Description |
---|---|---|
p |
Promise | a promise |
timeout |
number | optional timeout in ms |
ex |
Object | any exception |
Returns:
Promise resolved when p is resolved or rejected on timeout
waitImagesPromise(p, ctn)
- Description:
Wait for all async images (exclude sized .icon by css)
Parameters:
Name | Type | Description |
---|---|---|
p |
Object | Array | context parameters with array of promises |
ctn |
jQuery | images container |
Returns:
Promise resolved when all images are loaded or not
waitPromises(p, timeout)
- Description:
Wait for all promises of parameters
Parameters:
Name | Type | Description |
---|---|---|
p |
Object | Array | context parameters with array of promises |
timeout |
number | optional timeout in ms |
Returns:
Promise resolved when all contextual promises are settled and removed