Constructor
new Utils()
Methods
(static) ajaxJson(url, args, method, cb) → {jqXHR}
Do a Ajax call of json data
Parameters:
Name | Type | Description |
---|---|---|
url |
string | the url to call |
args |
object | arguments to send |
method |
string | POST|PUT|GET|DELETE |
cb |
function | callback function with "data" argument |
Returns:
- Type
- jqXHR
(static) clone(obj) → {object}
Clone an object... simple level !!!!
Parameters:
Name | Type | Description |
---|---|---|
obj |
object |
Returns:
the new object
- Type
- object
(static) createUUID() → {string}
Create a UUID with a random algorithme
Returns:
The number is like 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
- Type
- string
(static) delay(callback, time, arbitralNameopt)
Create a delay
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
callback |
function | une fonction à appeler | ||
time |
number | un temp en millisecondes | ||
arbitralName |
string |
<optional> |
"arbitralName" | donner de préférence un nom unique |
(static) deleteJson(url, args, cb) → {jqXHR}
Do a DELETE of json data
Parameters:
Name | Type | Description |
---|---|---|
url |
string | the url to call |
args |
object | arguments to send |
cb |
function | callback function with "data" argument |
Returns:
- Type
- jqXHR
(static) formatPhone(num) → {string}
Format a phone number... for french format !!! to update...
Parameters:
Name | Type | Description |
---|---|---|
num |
string |
Returns:
the formated number
- Type
- string
(static) formatPrice(nb, decimal, devise) → {string}
Format a number with good decimal and add devise
Parameters:
Name | Type | Default | Description |
---|---|---|---|
nb |
Number | ||
decimal |
Number | 2 | |
devise |
string |
Returns:
- Type
- string
(static) getBaseNameFromPath(path) → {string}
Return the base name of a path.
Parameters:
Name | Type | Description |
---|---|---|
path |
string | The path |
Returns:
The name of the file
- Type
- string
Example
var filename = getBaseNameFromPath("foo/bar/myfile.html") ;
// filename = "myfile.html"
(static) getCookie(cname) → {string}
Get cookie
Parameters:
Name | Type | Description |
---|---|---|
cname |
string | the name of the cookie |
Returns:
the value of the cookie
- Type
- string
(static) getDirFromPath(path) → {string}
Return the directory of a path.
Parameters:
Name | Type | Description |
---|---|---|
path |
string | The path |
Returns:
The name of the file
- Type
- string
Example
var filename = getDirFromPath("foo/bar/myfile.html") ;
// filename = "foo/bar"
(static) getExtensionFromPath(path) → {string}
Return the extension of a path.
Parameters:
Name | Type | Description |
---|---|---|
path |
string | The path |
Returns:
The extension or ''
- Type
- string
Example
var ext = M_.Utils.getExtensionFromPath("foo/bar/my_file.html") ;
// ext = "html"
(static) getFromArrayObjects(cname) → {string}
Get cookie
Parameters:
Name | Type | Description |
---|---|---|
cname |
string | the name of the cookie |
Returns:
the value of the cookie
- Type
- string
(static) getFromSimpleArray(cname) → {string}
Get cookie
Parameters:
Name | Type | Description |
---|---|---|
cname |
string | the name of the cookie |
Returns:
the value of the cookie
- Type
- string
(static) getJson(url, args, cb) → {jqXHR}
Do a GET of json data
Parameters:
Name | Type | Description |
---|---|---|
url |
string | the url to call |
args |
object | arguments to send |
cb |
function | callback function with "data" argument |
Returns:
- Type
- jqXHR
(static) getMaxZIndex(selectorLimitopt) → {number}
Return the upper z-index
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
selectorLimit |
jQuery |
<optional> |
null |
Returns:
- Type
- number
(static) getNextZIndex(incrementopt) → {number}
Get max z-index + 10
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
increment |
Number |
<optional> |
10 | number to increment |
Returns:
next z-index
- Type
- number
(static) getSimpleArray(cname) → {string}
Get cookie
Parameters:
Name | Type | Description |
---|---|---|
cname |
string | the name of the cookie |
Returns:
the value of the cookie
- Type
- string
(static) getSpeedAnim() → {Number}
Get default speed limit
Returns:
number of milliseconds
- Type
- Number
(static) hexToRgb(hex) → {object}
Convert hexadecimal to RGB
Parameters:
Name | Type | Description |
---|---|---|
hex |
number | Number to convert |
Returns:
Object contain keys : r, g, b ; {r:x, g:y, b:z}
- Type
- object
(static) hideSmoothly(jEl, cb)
Hide smoothly an element
Parameters:
Name | Type | Description |
---|---|---|
jEl |
jQuery | the element |
cb |
function | callback function after finished animation |
(static) id() → {string}
Return a uniq ID
Returns:
A incremental number start from 1
- Type
- string
(static) inArray()
To document
(static) isArray(obj) → {boolean}
Idem as jQuery $.isArray(obj)
Parameters:
Name | Type | Description |
---|---|---|
obj |
object | The object to test |
Returns:
True if obj is an array
- Type
- boolean
(static) isDate(obj) → {boolean}
Check if d is a moment date
Parameters:
Name | Type | Description |
---|---|---|
obj |
moment | The object to test |
Returns:
True if obj is {}
- Type
- boolean
(static) isEmpty(obj) → {boolean}
Check if variable is empty : [], undef, null, false, 0, "", "0", "undefined", undefined
Parameters:
Name | Type | Description |
---|---|---|
obj |
object |
Returns:
true if empty
- Type
- boolean
(static) isEmptyObject(obj) → {boolean}
Idem as jQuery $.isEmptyObject()
Parameters:
Name | Type | Description |
---|---|---|
obj |
object | The object to test |
Returns:
True if obj is {}
- Type
- boolean
(static) isFunction(obj) → {boolean}
Idem as jQuery $.isFunction()
Parameters:
Name | Type | Description |
---|---|---|
obj |
object | The object to test |
Returns:
True if obj is an function
- Type
- boolean
(static) isLoadedScript(url) → {Boolean}
Check if a script is loaded (warning : check exactly the file name)
Parameters:
Name | Type | Description |
---|---|---|
url |
string | url to call |
Returns:
true if already loaded
- Type
- Boolean
(static) isMacos() → {boolean}
Check if browser is on macos
Returns:
true if ok
- Type
- boolean
(static) isset(tab, field) → {Boolean}
Like PHP function
Parameters:
Name | Type | Description |
---|---|---|
tab |
Array | |
field |
string |
Returns:
true if is set
- Type
- Boolean
(static) loadScript(url)
Load a javascript file dynamically ; warning, no callback !!!
Parameters:
Name | Type | Description |
---|---|---|
url |
string | url to call |
(static) moment() → {boolean}
Return moment object
Returns:
True if obj is an array
- Type
- boolean
(static) nl2br(str, is_xhtml) → {string}
To document
Parameters:
Name | Type | Description |
---|---|---|
str |
string | the string to convert |
is_xhtml |
Boolean | [description] |
Returns:
modified string
- Type
- string
(static) number_format(a, b, c, d) → {string}
Like PHP function
Parameters:
Name | Type | Description |
---|---|---|
a |
Number | |
b |
Number | Number of decimal |
c |
string | decimal separator |
d |
string | thousen separator |
Returns:
this formated number
- Type
- string
(static) pathinfo(path, options) → {string}
Like PHP function
Parameters:
Name | Type | Description |
---|---|---|
path |
string | |
options |
string |
Returns:
- Type
- string
(static) plural(nb, singular, pluralopt) → {object}
Clone an object... simple level !!!!
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
nb |
object | |||
singular |
object | |||
plural |
object |
<optional> |
null | le pluriel d'une chaine, sinon rajoute un "s" |
Returns:
singular
- Type
- object
Example
var plural1 = M_.Utils.plural(3, "guitare")
// plural1 = guitares
var plural2 = M_.Utils.plural(3, "guitare", "guitarez")
// plural2 = guitarez
var plural3 = M_.Utils.plural(3, "une guitare", "une des {nb} guitares")
// plural3 = une des 3 guitares
(static) postJson(url, args, cb) → {jqXHR}
Do a POST of json data
Parameters:
Name | Type | Description |
---|---|---|
url |
string | the url to call |
args |
object | arguments to send |
cb |
function | callback function with "data" argument |
Returns:
- Type
- jqXHR
(static) price(nb, decimal, devise) → {string}
Alias of formatPrice
Parameters:
Name | Type | Default | Description |
---|---|---|---|
nb |
Number | ||
decimal |
Number | 2 | |
devise |
string |
Returns:
- Type
- string
(static) purcent(nb, decimal) → {string}
Format number in %
Parameters:
Name | Type | Default | Description |
---|---|---|---|
nb |
Number | ||
decimal |
Number | 2 |
Returns:
- Type
- string
(static) putJson(url, args, cb) → {jqXHR}
Do a PUT of json data
Parameters:
Name | Type | Description |
---|---|---|
url |
string | the url to call |
args |
object | arguments to send |
cb |
function | callback function with "data" argument |
Returns:
- Type
- jqXHR
(static) removeEventsNotAttachedToDocument()
Don't use that...
(static) replaceCommaWithPoint(txt) → {string}
replaceCommaWithPoint description
Parameters:
Name | Type | Description |
---|---|---|
txt |
string |
Returns:
- Type
- string
(static) restoreSelection()
To document
(static) rgbFromCssToHex(rgb) → {number}
Convert RGB from css (like #FFFFFF) to Hexa
Parameters:
Name | Type | Description |
---|---|---|
rgb |
number |
Returns:
Object contain keys : r, g, b ; {r:x, g:y, b:z}
- Type
- number
(static) rgbToHex(r, g, b) → {number}
Convert RGB to Hexa
Parameters:
Name | Type | Description |
---|---|---|
r |
number | Red |
g |
integer | Green |
b |
integer | Blue |
Returns:
Number of hexadecimal
- Type
- number
(static) saveFiles(files, url, moreArgs, cb) → {jqXHR}
Save a file with Ajax technic
Parameters:
Name | Type | Default | Description |
---|---|---|---|
files |
Array | array of input html files | |
url |
string | url to call | |
moreArgs |
Object | send more arguments | |
cb |
function | null | callback after finished |
Returns:
- Type
- jqXHR
Example
M_.Utils.saveFiles([form.find('co_avatar_send').jEl.get(0)], '/avatarupdate', {}, function() {}) ;
(static) saveSelection()
To document
(static) searchArrayObjects(cname) → {string}
Get cookie
Parameters:
Name | Type | Description |
---|---|---|
cname |
string | the name of the cookie |
Returns:
the value of the cookie
- Type
- string
(static) searchSimpleArray(cname) → {string}
Get cookie
Parameters:
Name | Type | Description |
---|---|---|
cname |
string | the name of the cookie |
Returns:
the value of the cookie
- Type
- string
(static) setCookie(cname, cvalue, expireDaysopt)
Set cookie
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
cname |
string | the name of the cookie | ||
cvalue |
string | the value of the cookie | ||
expireDays |
string |
<optional> |
7 | expiration in days |
(static) setSelectionRange(jEl, start, stop)
Text selection in HTML input field
Parameters:
Name | Type | Default | Description |
---|---|---|---|
jEl |
jQuery | ||
start |
Number | 0 | from which char |
stop |
Number | 0 | to which char |
(static) setZIndexForModal(jEl)
Set the z-index upper
Parameters:
Name | Type | Description |
---|---|---|
jEl |
jQuery | jQuery object |
(static) showSmoothly(jEl, cb)
Display smoothly an element
Parameters:
Name | Type | Description |
---|---|---|
jEl |
jQuery | the element |
cb |
function | callback function after finished animation |
(static) str_pad(str, len, padStropt, directionopt) → {string}
First char to upper case
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
str |
string | the base string | ||
len |
number | add 'padStr' X times | ||
padStr |
string |
<optional> |
'0' | the string to add |
direction |
number |
<optional> |
-1 | -1=left, 1=right |
Returns:
the new string
- Type
- string
(static) strip_tags(num, allowed) → {string}
Strip html tags
Parameters:
Name | Type | Description |
---|---|---|
num |
string | |
allowed |
string |
Returns:
the new string
- Type
- string
(static) toggleAppFullScreen() → {Boolean}
toggleAppFullScreen description
Returns:
true if actually passed in full screen (after function executed)
- Type
- Boolean
(static) trim(str) → {string}
Remove break line, space and tabulation
Parameters:
Name | Type | Description |
---|---|---|
str |
string | the base string |
Returns:
the new string
- Type
- string
(static) ucfirst(str) → {string}
First char to upper case
Parameters:
Name | Type | Description |
---|---|---|
str |
string |
Returns:
the new string
- Type
- string