Util

Simplicite.UI. Util

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

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 code:text#level[#field] (or json object)

obj Simplicite.Ajax.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.Ajax.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 {left,top} to substract

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.Ajax.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 resize triggers