cms7
v1.4.1
Published
- __log__: which is a shortcut for console.log - __$__ and __jQuery__: the jquery's famous $ and jQuery variable - __unerscore(_)__: underscore - __stackTrace function() -> Error__: returns an error object containing current stack trace - __logStackTr
Downloads
42
Readme
CMS7
Adds following to window variable:
- log: which is a shortcut for console.log
- $ and jQuery: the jquery's famous $ and jQuery variable
- unerscore(_): underscore
- stackTrace function() -> Error: returns an error object containing current stack trace
- logStackTrace function() -> void: prints current stack trace in console
Adds the following methods to any jQuery variable:
- hasAttr function (name) -> Boolean: checks if a jquery object has the given attribute.
$('.test').hasAttr('id')
- equals function(jQueryObject) -> Boolean: checks if a jquery object equals the given jquery object.
$('.test').equals($('.test'))
- outerHTML function() -> String: returns the jquery object's outer html.
$('.test').outerHTML()
Adds the following methods to javascript Number:
- padZero function(size) -> String: inserts 0s before a number until the length is equal to size parameter
var x = 123; x.padZero(5) prints: 00123
- format function(separator = ',') -> String: thousand separator for mostly currencies
var x = 123000; x.format('/') prints: 123/000
Adds the following methods to javascript String:
- format function(templateString, ...args): just like c# String.format function
String.format('Hi, {0}', 'Akbar') prints: Hi, Akbar
- endsWith function(suffix): just like c# String.endsWith function
Adds the following to FormData:
- print function() -> String: prints FormData object
- put function(object) -> FormData: puts all properties of object recursively into FormData
jQuery classes polyfill for IE
will be automatically injected on import
IE10 viewport hack for Surface/desktop Windows 8 bug
will be automatically injected on import
fix for safari bug on readonly input
will be automatically injected on import
Opacity:
- import 'cms7/dist/opacity.css' to add opacity-{0, 25, 50, 75, 100} css classes
- getOpacityCss(opactiy) -> String: returns css style for the given opacity parameter. opacity must be a fload number between 0 and 1
Media Query:
queryMedia function(query, callOnChange, callback) -> void:
- @param {string} query: e.g: '(max-width: 769px)'
- @param {boolean} callOnChange: whether or not to invoke callback parameter on window resize
- @event callback : function (isMatch: boolean) -> void
queryMediaSync function(query = '(max-width: 769px)') -> Boolean: checks css query and returns the result immediateley
Id Generator:
- 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
Browser support:
- browserSupport class():
- methods:
- fileInput(): returns true if browser supports file input
- fileApi(): returns true if browser supports FileReader
- dragDropApi(): returns true if browser supports drag & drop
- methods:
Type system:
- 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
Utility:
- callSafe function(func) -> return value of func: calls the given function if it is available
- 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
- render function(template: String, data: Object) -> String: renders a template using the data as its model with underscorejs template engine
- toEnglishNumbers function(string) -> String: changes arabic or persian digits in a string to english digits
- flatten and unflatten from https://www.npmjs.com/package/flat
- isBuffer from https://github.com/feross/is-buffer
Synchronization:
- 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): invokes the callback asynchronously when the object is unlocked
- methods:
Mime types:
- MediaTypes class():
- methods:
- acceptToFileTypes(accept): convert Html5 accept string to array of separate accepts
- @param {String} accept example: image/*, audio/*, video/*, ....
- getExtension(type): returns file extension of the given mime type.
- getMediaType(extensionOrPath): returns mime type of given file extension or url
- getIconPath(fileIconPath, extension, size = 48, type = 'png'): returns icon url of the given file extension
- @param {String} fileIconPath: folder in wwwroot on server e.g: /file-icon-set
- @param {Number} size: 16, 24, 48, 64, 128
- @param {String} type: png | gif
- getUrlThumb(url, done, iconSize = 48, iconType = 'png'): returns icon for a given url (of a file)
- @returns an object of type:
- path {String}: url of the icon
- isIcon {Boolean}: whether it is icon or not
- height {Number | Null}: iconSize parameter if isIcon is true
- @returns an object of type:
- getFileThumb(file, done, iconSize = 48, iconType = 'png'): returns icon for a given file (File)
- @returns an object of type:
- path {String}: data uri of icon
- isIcon {Boolean}: whether it is icon or not
- height {Number | Undefined}: iconSize parameter if isIcon is true
- @returns an object of type:
- acceptToFileTypes(accept): convert Html5 accept string to array of separate accepts
- methods:
Local Database:
- Database class():
- methods:
- set(key, value): sets the value of key
- get(key, seed): gets the value of key and seeds that key for the first usage
- remove(key): removes key
- clear(): clears database
- all(): returns all as array of:
- key
- value
- methods:
Ajax:
- registerXsrfHeaderInAjaxPost function() -> void: registers current xsrf.headerName() and xsrf.value() 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
XSRF:
- xsrfConfig class():
- methods:
- headerName(xsrfHeaderName): gets or sets XSRF header name
- value(containerSelector, tagName): gets or sets XSRF value
- tag(): gets hidden input of xsrf tag provided by asp.net core
- methods:
Culture:
- cultureConfig class():
- methods;
- cultures(cultures): gets or sets allowed cultures
- cultureObjects(): gets culture objects as array of:
- id: culture
- text: name of culture
- url: current url with this culture
- defaultCulture(culture): gets or sets default (fallback) culture, used for routing and operational stuff
- defaultUICulture(culture): gets or sets default UI culture, used for localization mostly
- culture(culture): gets or sets current culture
- getCultureName(culture): gets name of the give culture
- dir(culture): gets direction (rtl, ltr) of the give culture. if the culture passed is null or undefined gets direction of current culture
- calendar(): gets calendar of the current culture
- methods;
Google:
- googleConfig class():
- methods:
- googletMapApiKey(apiKey): gets or sets current google map api key
- methods:
Url:
- currentUrl: a method returning info about current url
- culture: culture
- url: path part of url
- query: query string
Server Data:
- serverItems():
- properties:
- serverItems: An object of server and tags
- serverResults: An array of server Results
- name
- title
- message
- color
- duration
- returnValue
- properties:
Imaging:
- thumberOptions(options): gets or sets thumber options
- @param options:
- extensions: 'png, jpg, jpeg, bmp'
- widthParameterName: 'w'
- heightParameterName: 'h'
- qualityParameterName: 'q'
- @param options:
- getImageUrl(path, quality = 100, width = null, height = null): gets url of the compressed image
Scrollbar:
- import 'cms7/dist/scrollbar.css' to have nice little scrollbar on the window instead of the default one
- infiniteScroller(scrollTarget, callback, locked, unlocked):
- @param scrollTarget: jQuery object for target container. pass undefined to watch window scroll
- @param callback: function (page, done: function(boolean)) -> void
- @param locked: function () -> void
- @param unlocked: function () -> void
- windowScroll object:
- methods:
- remove() -> void: removes window scrollbar
- restore() -> void: restores window scrollbar
- methods: