Alien-Web-ExtJS-V3
view release on metacpan or search on metacpan
share/docs/source/Format.html view on Meta::CPAN
return {
<span id='Ext-util-Format-method-ellipsis'> /**
</span> * Truncate a string and add an ellipsis ('...') to the end if it exceeds the specified length
* @param {String} value The string to truncate
* @param {Number} length The maximum length to allow before truncating
* @param {Boolean} word True to try to find a common work break
* @return {String} The converted text
*/
ellipsis : function(value, len, word) {
if (value && value.length > len) {
if (word) {
var vs = value.substr(0, len - 2),
index = Math.max(vs.lastIndexOf(' '), vs.lastIndexOf('.'), vs.lastIndexOf('!'), vs.lastIndexOf('?'));
if (index == -1 || index < (len - 15)) {
return value.substr(0, len - 3) + "...";
} else {
return vs.substr(0, index) + "...";
}
} else {
return value.substr(0, len - 3) + "...";
}
}
return value;
},
<span id='Ext-util-Format-method-undef'> /**
</span> * Checks a reference and converts it to empty string if it is undefined
* @param {Mixed} value Reference to check
* @return {Mixed} Empty string if converted, otherwise the original value
*/
undef : function(value) {
return value !== undefined ? value : "";
},
<span id='Ext-util-Format-method-defaultValue'> /**
</span> * Checks a reference and converts it to the default value if it's empty
* @param {Mixed} value Reference to check
* @param {String} defaultValue The value to insert if it's undefined (defaults to "")
* @return {String}
*/
defaultValue : function(value, defaultValue) {
if (!defaultValue && defaultValue !== 0) {
defaultValue = '';
}
return value !== undefined && value !== '' ? value : defaultValue;
},
<span id='Ext-util-Format-method-htmlEncode'> /**
</span> * Convert certain characters (&, <, >, and ') to their HTML character equivalents for literal display in web pages.
* @param {String} value The string to encode
* @return {String} The encoded text
*/
htmlEncode : function(value) {
return !value ? value : String(value).replace(/&/g, "&amp;").replace(/>/g, "&gt;").replace(/</g, "&lt;").replace(/"/g, "&quot;");
},
<span id='Ext-util-Format-method-htmlDecode'> /**
</span> * Convert certain characters (&, <, >, and ') from their HTML character equivalents.
* @param {String} value The string to decode
* @return {String} The decoded text
*/
htmlDecode : function(value) {
return !value ? value : String(value).replace(/&gt;/g, ">").replace(/&lt;/g, "<").replace(/&quot;/g, '"').replace(/&amp;/g, "&");
},
<span id='Ext-util-Format-method-trim'> /**
</span> * Trims any whitespace from either side of a string
* @param {String} value The text to trim
* @return {String} The trimmed text
*/
trim : function(value) {
return String(value).replace(trimRe, "");
},
<span id='Ext-util-Format-method-substr'> /**
</span> * Returns a substring from within an original string
* @param {String} value The original text
* @param {Number} start The start index of the substring
* @param {Number} length The length of the substring
* @return {String} The substring
*/
substr : function(value, start, length) {
return String(value).substr(start, length);
},
<span id='Ext-util-Format-method-lowercase'> /**
</span> * Converts a string to all lower case letters
* @param {String} value The text to convert
* @return {String} The converted text
*/
lowercase : function(value) {
return String(value).toLowerCase();
},
<span id='Ext-util-Format-method-uppercase'> /**
</span> * Converts a string to all upper case letters
* @param {String} value The text to convert
* @return {String} The converted text
*/
uppercase : function(value) {
return String(value).toUpperCase();
},
<span id='Ext-util-Format-method-capitalize'> /**
</span> * Converts the first character only of a string to upper case
* @param {String} value The text to convert
* @return {String} The converted text
*/
capitalize : function(value) {
return !value ? value : value.charAt(0).toUpperCase() + value.substr(1).toLowerCase();
},
// private
call : function(value, fn) {
if (arguments.length > 2) {
var args = Array.prototype.slice.call(arguments, 2);
args.unshift(value);
return eval(fn).apply(window, args);
} else {
return eval(fn).call(window, value);
( run in 0.922 second using v1.01-cache-2.11-cpan-3d66aa2751a )