cms7-underscore
v1.0.5
Published
- ### _: which is a shortcut for import _ from 'underscore'
Downloads
3
Readme
underscore extensions
Adds following variables to window variable:
_: which is a shortcut for import _ from 'underscore'
Exports:
isVoid function(value) -> Boolean: checks if the value is either null or undefined
isVoid(null) returns: true
isJquery function(value) -> Boolean: checks if the value is an instance of jQuery
isJquery($('.test')) returns: true
toJquery function(value) -> jQuery: if the value is not a jQuery instance, assumes that value is a jquery selector and returns the jquery instance of that selector
toJquery($('.test')) returns: $('.test') variable toJquery('.test') returns: $('.test') variable
callSafe function(func) -> return value of func: calls the given function if it is available
guid function() -> String: returns a c# Guid.NewGuid().ToString("N") like string
guid() returns: 976edaa0d2464573a6ea01aabaa98899
newId function() -> String: returns guid() plus a prefix to make it suitable for html id attributes
newId() returns: e_976edaa0d2464573a6ea01a4bca98899
kebab_case_to_camelCase function(kebabCase) -> String: converts kebab-case string into camelCase equivalent
kebab_case_to_camelCase('cms7-underscore') returns: cms7Underscore
containsArabic function(value) -> Boolean: checks if a string contains persian or arabic characters
isKeyAlphaNumeric function(keyCode) -> Boolean: checks if the given keyCode of a jquery's keyup or keydown events is either digit or letter
isKeyTextInput function(keyCode) -> Boolean: checks if the given keyCode of a jquery's keyup or keydown events is either digit or letter and is NOT backspace: 8 nor delete: 46
spinLock class(locked: func, unlocked: func):
methods:
- lock() -> void: locks the object
- unlock() -> void: unlocks the object
- isLocked() -> Boolean: tells if the object is locked
- waitForLock(callback: func) -> void: invokes the callback asynchronously when the object is unlocked
render function(template: String, data: Object) -> String: renders a template using the data as its model with underscorejs template engine
culture function(culture) -> String: sets or gets current culture
dir function(culture) -> String: gets current direction based on the given culture or current culture (if culture is null)
cultures function(cultures) -> Array: sets or gets current allowed cultures
xsrfHeaderName function(xsrfHeaderName) -> String: sets or gets current XSRF header name
xsrfValue function(containerSelector, tagName) -> String: sets or gets current XSRF value
googletMapApiKey function(apiKey) -> String: sets or gets current google map api key
googleAnalyticsId function(gaid) -> String: sets or gets current google analytics id
calendar function() -> calendars: gets current calendar based on current culture
newDat function(calendar, year, month, day, hour = 0, minute = 0, second = 0, millisecond = 0) -> dat: creates a new dat
dateTimeFormats:
all: "year-month-day-hour-minute-second-millisecond", ymdhms: "year-month-day-hour-minute-second", ymdhm: "year-month-day-hour-minute", ymdh: "year-month-day-hour", ymd: "year-month-day", ym: "year-month", y: "year", hmsm: "hour-minute-second-millisecond", hms: "hour-minute-second", hm: "hour-minute", h: "hour"calendars:
gregorian: moment, jalaali: jmoment, hijri: imomentdat: dat class for date-time operations
registerXsrfHeaderInAjaxPost function() -> void: registers current xsrfHeaderName and xsrfValue in ajax-post
createUrl function(url) -> String: gets localized url
createAjaxOptions function(method, url, data, success, error, completed) -> jQuery ajax options
send function(method, url, data, success, error, completed) -> void
sendGet function(url, data, success, error, completed) -> void
sendPost function(url, data, success, error, completed) -> void
Adds the above methods to any underscore variable:
for example _.isVoid, _.isJquery, ...