Table of contents


Metro 4 objects and types extensions.


Metro 4 contains the number of extensions for standard javascript types and objects.

Object Extension Desc
$.fn toggleAttr(attribute, value) toggle element attribute
$.fn clearClasses() remove all element classes
Array shuffle() Shuffle array elements
Array clone() Clone array
Array unique() Get array unique element
Number format(n, x, s, c) Format number value. n: length of decimal, x: length of whole part, s: sections delimiter, c: decimal delimiter
String capitalize(str) Capitalize string
String contains(substr, index) Check if string contains substring
String toDate(mask[, locale]) Convert string to date by mask. You can use next identifiers: dd, %d - for day, mm, %m - for month, yy, yyyy, %y, %Y - for year, hh, %h - for hours, ii, %i - for minutes, ss, %s - for seconds. Example: "1972-12-21 04:30:00".toDate("yyyy-mm-dd hh:ii:ss"); "21-12-1972".toDate("dd-mm-yyyy"); "21 грудня 1972".toDate("dd mm yyyy", "uk-UA");
Date format(format, locale) Format Date object (see this article)
Date addHours(hours) Add hours to date