[IMP] now uses bower for some libs
bzr revid: nicolas.vanhoren@openerp.com-20130731131731-9yq9deun2b5q6sxv
This commit is contained in:
parent
cf4c185f8c
commit
e4acf6c902
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"directory": "static/lib/"
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"name": "web",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"ignore": [
|
||||||
|
"**/.*",
|
||||||
|
"node_modules",
|
||||||
|
"bower_components",
|
||||||
|
"test",
|
||||||
|
"tests"
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"jquery": "1.8.3",
|
||||||
|
"underscore": "1.3.1",
|
||||||
|
"underscore.string": "2.2.1"
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -4,7 +4,7 @@
|
||||||
// Documentation: https://github.com/epeli/underscore.string
|
// Documentation: https://github.com/epeli/underscore.string
|
||||||
// Some code is borrowed from MooTools and Alexandru Marasteanu.
|
// Some code is borrowed from MooTools and Alexandru Marasteanu.
|
||||||
|
|
||||||
// Version 1.2.0
|
// Version 2.2.0rc
|
||||||
|
|
||||||
(function(root){
|
(function(root){
|
||||||
'use strict';
|
'use strict';
|
||||||
|
@ -12,12 +12,17 @@
|
||||||
// Defining helper functions.
|
// Defining helper functions.
|
||||||
|
|
||||||
var nativeTrim = String.prototype.trim;
|
var nativeTrim = String.prototype.trim;
|
||||||
|
var nativeTrimRight = String.prototype.trimRight;
|
||||||
|
var nativeTrimLeft = String.prototype.trimLeft;
|
||||||
|
|
||||||
var parseNumber = function(source) { return source * 1 || 0; };
|
var parseNumber = function(source) { return source * 1 || 0; };
|
||||||
|
|
||||||
var strRepeat = function(i, m) {
|
var strRepeat = function(str, qty, separator){
|
||||||
for (var o = []; m > 0; o[--m] = i) {}
|
// ~~var — is the fastest available way to convert anything to Integer in javascript.
|
||||||
return o.join('');
|
// We'll use it extensively in this lib.
|
||||||
|
str += ''; qty = ~~qty;
|
||||||
|
for (var repeat = []; qty > 0; repeat[--qty] = str) {}
|
||||||
|
return repeat.join(separator == null ? '' : separator);
|
||||||
};
|
};
|
||||||
|
|
||||||
var slice = function(a){
|
var slice = function(a){
|
||||||
|
@ -25,21 +30,23 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
var defaultToWhiteSpace = function(characters){
|
var defaultToWhiteSpace = function(characters){
|
||||||
if (characters) {
|
if (characters != null) {
|
||||||
return _s.escapeRegExp(characters);
|
return '[' + _s.escapeRegExp(''+characters) + ']';
|
||||||
}
|
}
|
||||||
return '\\s';
|
return '\\s';
|
||||||
};
|
};
|
||||||
|
|
||||||
var sArgs = function(method){
|
var escapeChars = {
|
||||||
return function(){
|
lt: '<',
|
||||||
var args = slice(arguments);
|
gt: '>',
|
||||||
for(var i=0; i<args.length; i++)
|
quot: '"',
|
||||||
args[i] = args[i] == null ? '' : '' + args[i];
|
apos: "'",
|
||||||
return method.apply(null, args);
|
amp: '&'
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var reversedEscapeChars = {};
|
||||||
|
for(var key in escapeChars){ reversedEscapeChars[escapeChars[key]] = key; }
|
||||||
|
|
||||||
// sprintf() for JavaScript 0.7-beta1
|
// sprintf() for JavaScript 0.7-beta1
|
||||||
// http://www.diveintojavascript.com/projects/javascript-sprintf
|
// http://www.diveintojavascript.com/projects/javascript-sprintf
|
||||||
//
|
//
|
||||||
|
@ -168,213 +175,229 @@
|
||||||
|
|
||||||
var _s = {
|
var _s = {
|
||||||
|
|
||||||
VERSION: '1.2.0',
|
VERSION: '2.2.0rc',
|
||||||
|
|
||||||
isBlank: sArgs(function(str){
|
isBlank: function(str){
|
||||||
return (/^\s*$/).test(str);
|
return (/^\s*$/).test(str);
|
||||||
}),
|
},
|
||||||
|
|
||||||
stripTags: sArgs(function(str){
|
stripTags: function(str){
|
||||||
return str.replace(/<\/?[^>]+>/ig, '');
|
return (''+str).replace(/<\/?[^>]+>/g, '');
|
||||||
}),
|
},
|
||||||
|
|
||||||
capitalize : sArgs(function(str) {
|
capitalize : function(str) {
|
||||||
return str.charAt(0).toUpperCase() + str.substring(1).toLowerCase();
|
str += '';
|
||||||
}),
|
return str.charAt(0).toUpperCase() + str.substring(1);
|
||||||
|
},
|
||||||
|
|
||||||
chop: sArgs(function(str, step){
|
chop: function(str, step){
|
||||||
step = parseNumber(step) || str.length;
|
str = str+'';
|
||||||
|
step = ~~step || str.length;
|
||||||
var arr = [];
|
var arr = [];
|
||||||
for (var i = 0; i < str.length;) {
|
for (var i = 0; i < str.length; i += step)
|
||||||
arr.push(str.slice(i,i + step));
|
arr.push(str.slice(i,i + step));
|
||||||
i = i + step;
|
|
||||||
}
|
|
||||||
return arr;
|
return arr;
|
||||||
}),
|
},
|
||||||
|
|
||||||
clean: sArgs(function(str){
|
clean: function(str){
|
||||||
return _s.strip(str.replace(/\s+/g, ' '));
|
return _s.strip(str).replace(/\s+/g, ' ');
|
||||||
}),
|
},
|
||||||
|
|
||||||
count: sArgs(function(str, substr){
|
count: function(str, substr){
|
||||||
var count = 0, index;
|
str += ''; substr += '';
|
||||||
for (var i=0; i < str.length;) {
|
return str.split(substr).length - 1;
|
||||||
index = str.indexOf(substr, i);
|
},
|
||||||
index >= 0 && count++;
|
|
||||||
i = i + (index >= 0 ? index : 0) + substr.length;
|
chars: function(str) {
|
||||||
|
return (''+str).split('');
|
||||||
|
},
|
||||||
|
|
||||||
|
escapeHTML: function(str) {
|
||||||
|
return (''+str).replace(/[&<>"']/g, function(match){ return '&' + reversedEscapeChars[match] + ';'; });
|
||||||
|
},
|
||||||
|
|
||||||
|
unescapeHTML: function(str) {
|
||||||
|
return (''+str).replace(/\&([^;]+);/g, function(entity, entityCode){
|
||||||
|
var match;
|
||||||
|
|
||||||
|
if (entityCode in escapeChars) {
|
||||||
|
return escapeChars[entityCode];
|
||||||
|
} else if (match = entityCode.match(/^#x([\da-fA-F]+)$/)) {
|
||||||
|
return String.fromCharCode(parseInt(match[1], 16));
|
||||||
|
} else if (match = entityCode.match(/^#(\d+)$/)) {
|
||||||
|
return String.fromCharCode(~~match[1]);
|
||||||
|
} else {
|
||||||
|
return entity;
|
||||||
}
|
}
|
||||||
return count;
|
});
|
||||||
}),
|
},
|
||||||
|
|
||||||
chars: sArgs(function(str) {
|
escapeRegExp: function(str){
|
||||||
return str.split('');
|
|
||||||
}),
|
|
||||||
|
|
||||||
escapeHTML: sArgs(function(str) {
|
|
||||||
return str.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>')
|
|
||||||
.replace(/"/g, '"').replace(/'/g, "'");
|
|
||||||
}),
|
|
||||||
|
|
||||||
unescapeHTML: sArgs(function(str) {
|
|
||||||
return str.replace(/</g, '<').replace(/>/g, '>')
|
|
||||||
.replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, '&');
|
|
||||||
}),
|
|
||||||
|
|
||||||
escapeRegExp: sArgs(function(str){
|
|
||||||
// From MooTools core 1.2.4
|
// From MooTools core 1.2.4
|
||||||
return str.replace(/([-.*+?^${}()|[\]\/\\])/g, '\\$1');
|
return str.replace(/([-.*+?^${}()|[\]\/\\])/g, '\\$1');
|
||||||
}),
|
},
|
||||||
|
|
||||||
insert: sArgs(function(str, i, substr){
|
insert: function(str, i, substr){
|
||||||
var arr = str.split('');
|
var arr = _s.chars(str);
|
||||||
arr.splice(parseNumber(i), 0, substr);
|
arr.splice(~~i, 0, ''+substr);
|
||||||
return arr.join('');
|
return arr.join('');
|
||||||
}),
|
},
|
||||||
|
|
||||||
include: sArgs(function(str, needle){
|
include: function(str, needle){
|
||||||
return str.indexOf(needle) !== -1;
|
return !!~(''+str).indexOf(needle);
|
||||||
}),
|
},
|
||||||
|
|
||||||
join: sArgs(function(sep) {
|
join: function() {
|
||||||
var args = slice(arguments);
|
var args = slice(arguments);
|
||||||
return args.join(args.shift());
|
return args.join(args.shift());
|
||||||
}),
|
},
|
||||||
|
|
||||||
lines: sArgs(function(str) {
|
lines: function(str) {
|
||||||
return str.split("\n");
|
return (''+str).split("\n");
|
||||||
}),
|
},
|
||||||
|
|
||||||
reverse: sArgs(function(str){
|
reverse: function(str){
|
||||||
return Array.prototype.reverse.apply(String(str).split('')).join('');
|
return _s.chars(str).reverse().join('');
|
||||||
}),
|
},
|
||||||
|
|
||||||
splice: sArgs(function(str, i, howmany, substr){
|
splice: function(str, i, howmany, substr){
|
||||||
var arr = str.split('');
|
var arr = _s.chars(str);
|
||||||
arr.splice(parseNumber(i), parseNumber(howmany), substr);
|
arr.splice(~~i, ~~howmany, substr);
|
||||||
return arr.join('');
|
return arr.join('');
|
||||||
}),
|
},
|
||||||
|
|
||||||
startsWith: sArgs(function(str, starts){
|
startsWith: function(str, starts){
|
||||||
|
str += ''; starts += '';
|
||||||
return str.length >= starts.length && str.substring(0, starts.length) === starts;
|
return str.length >= starts.length && str.substring(0, starts.length) === starts;
|
||||||
}),
|
},
|
||||||
|
|
||||||
endsWith: sArgs(function(str, ends){
|
endsWith: function(str, ends){
|
||||||
|
str += ''; ends += '';
|
||||||
return str.length >= ends.length && str.substring(str.length - ends.length) === ends;
|
return str.length >= ends.length && str.substring(str.length - ends.length) === ends;
|
||||||
}),
|
},
|
||||||
|
|
||||||
succ: sArgs(function(str){
|
succ: function(str){
|
||||||
var arr = str.split('');
|
str += '';
|
||||||
|
var arr = _s.chars(str);
|
||||||
arr.splice(str.length-1, 1, String.fromCharCode(str.charCodeAt(str.length-1) + 1));
|
arr.splice(str.length-1, 1, String.fromCharCode(str.charCodeAt(str.length-1) + 1));
|
||||||
return arr.join('');
|
return arr.join('');
|
||||||
}),
|
},
|
||||||
|
|
||||||
titleize: sArgs(function(str){
|
titleize: function(str){
|
||||||
var arr = str.split(' '),
|
return (''+str).replace(/\b./g, function(ch){ return ch.toUpperCase(); });
|
||||||
word;
|
},
|
||||||
for (var i=0; i < arr.length; i++) {
|
|
||||||
word = arr[i].split('');
|
|
||||||
if(typeof word[0] !== 'undefined') word[0] = word[0].toUpperCase();
|
|
||||||
i+1 === arr.length ? arr[i] = word.join('') : arr[i] = word.join('') + ' ';
|
|
||||||
}
|
|
||||||
return arr.join('');
|
|
||||||
}),
|
|
||||||
|
|
||||||
camelize: sArgs(function(str){
|
camelize: function(str){
|
||||||
return _s.trim(str).replace(/(\-|_|\s)+(.)?/g, function(match, separator, chr) {
|
return _s.trim(str).replace(/[-_\s]+(.)?/g, function(match, chr){
|
||||||
return chr ? chr.toUpperCase() : '';
|
return chr && chr.toUpperCase();
|
||||||
});
|
});
|
||||||
}),
|
},
|
||||||
|
|
||||||
underscored: function(str){
|
underscored: function(str){
|
||||||
return _s.trim(str).replace(/([a-z\d])([A-Z]+)/g, '$1_$2').replace(/\-|\s+/g, '_').toLowerCase();
|
return _s.trim(str).replace(/([a-z\d])([A-Z]+)/g, '$1_$2').replace(/[-\s]+/g, '_').toLowerCase();
|
||||||
},
|
},
|
||||||
|
|
||||||
dasherize: function(str){
|
dasherize: function(str){
|
||||||
return _s.trim(str).replace(/([a-z\d])([A-Z]+)/g, '$1-$2').replace(/^([A-Z]+)/, '-$1').replace(/\_|\s+/g, '-').toLowerCase();
|
return _s.trim(str).replace(/[_\s]+/g, '-').replace(/([A-Z])/g, '-$1').replace(/-+/g, '-').toLowerCase();
|
||||||
|
},
|
||||||
|
|
||||||
|
classify: function(str){
|
||||||
|
str += '';
|
||||||
|
return _s.titleize(str.replace(/_/g, ' ')).replace(/\s/g, '')
|
||||||
},
|
},
|
||||||
|
|
||||||
humanize: function(str){
|
humanize: function(str){
|
||||||
return _s.capitalize(this.underscored(str).replace(/_id$/,'').replace(/_/g, ' '));
|
return _s.capitalize(this.underscored(str).replace(/_id$/,'').replace(/_/g, ' '));
|
||||||
},
|
},
|
||||||
|
|
||||||
trim: sArgs(function(str, characters){
|
trim: function(str, characters){
|
||||||
if (!characters && nativeTrim) {
|
str += '';
|
||||||
return nativeTrim.call(str);
|
if (!characters && nativeTrim) { return nativeTrim.call(str); }
|
||||||
|
characters = defaultToWhiteSpace(characters);
|
||||||
|
return str.replace(new RegExp('\^' + characters + '+|' + characters + '+$', 'g'), '');
|
||||||
|
},
|
||||||
|
|
||||||
|
ltrim: function(str, characters){
|
||||||
|
str+='';
|
||||||
|
if (!characters && nativeTrimLeft) {
|
||||||
|
return nativeTrimLeft.call(str);
|
||||||
}
|
}
|
||||||
characters = defaultToWhiteSpace(characters);
|
characters = defaultToWhiteSpace(characters);
|
||||||
return str.replace(new RegExp('\^[' + characters + ']+|[' + characters + ']+$', 'g'), '');
|
return str.replace(new RegExp('^' + characters + '+'), '');
|
||||||
}),
|
},
|
||||||
|
|
||||||
ltrim: sArgs(function(str, characters){
|
rtrim: function(str, characters){
|
||||||
|
str+='';
|
||||||
|
if (!characters && nativeTrimRight) {
|
||||||
|
return nativeTrimRight.call(str);
|
||||||
|
}
|
||||||
characters = defaultToWhiteSpace(characters);
|
characters = defaultToWhiteSpace(characters);
|
||||||
return str.replace(new RegExp('\^[' + characters + ']+', 'g'), '');
|
return str.replace(new RegExp(characters + '+$'), '');
|
||||||
}),
|
},
|
||||||
|
|
||||||
rtrim: sArgs(function(str, characters){
|
truncate: function(str, length, truncateStr){
|
||||||
characters = defaultToWhiteSpace(characters);
|
str += ''; truncateStr = truncateStr || '...';
|
||||||
return str.replace(new RegExp('[' + characters + ']+$', 'g'), '');
|
length = ~~length;
|
||||||
}),
|
return str.length > length ? str.slice(0, length) + truncateStr : str;
|
||||||
|
},
|
||||||
truncate: sArgs(function(str, length, truncateStr){
|
|
||||||
truncateStr = truncateStr || '...';
|
|
||||||
length = parseNumber(length);
|
|
||||||
return str.length > length ? str.slice(0,length) + truncateStr : str;
|
|
||||||
}),
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _s.prune: a more elegant version of truncate
|
* _s.prune: a more elegant version of truncate
|
||||||
* prune extra chars, never leaving a half-chopped word.
|
* prune extra chars, never leaving a half-chopped word.
|
||||||
* @author github.com/sergiokas
|
* @author github.com/sergiokas
|
||||||
*/
|
*/
|
||||||
prune: sArgs(function(str, length, pruneStr){
|
prune: function(str, length, pruneStr){
|
||||||
pruneStr = pruneStr || '...';
|
str += ''; length = ~~length;
|
||||||
length = parseNumber(length);
|
pruneStr = pruneStr != null ? ''+pruneStr : '...';
|
||||||
var pruned = '';
|
|
||||||
|
var pruned, borderChar, template = str.replace(/\W/g, function(ch){
|
||||||
|
return (ch.toUpperCase() !== ch.toLowerCase()) ? 'A' : ' ';
|
||||||
|
});
|
||||||
|
|
||||||
|
borderChar = template.charAt(length);
|
||||||
|
|
||||||
|
pruned = template.slice(0, length);
|
||||||
|
|
||||||
// Check if we're in the middle of a word
|
// Check if we're in the middle of a word
|
||||||
if( str.substring(length-1, length+1).search(/^\w\w$/) === 0 )
|
if (borderChar && borderChar.match(/\S/))
|
||||||
pruned = _s.rtrim(str.slice(0,length).replace(/([\W][\w]*)$/,''));
|
pruned = pruned.replace(/\s\S+$/, '');
|
||||||
else
|
|
||||||
pruned = _s.rtrim(str.slice(0,length));
|
|
||||||
|
|
||||||
pruned = pruned.replace(/\W+$/,'');
|
pruned = _s.rtrim(pruned);
|
||||||
|
|
||||||
return (pruned.length+pruneStr.length>str.length) ? str : pruned + pruneStr;
|
return (pruned+pruneStr).length > str.length ? str : str.substring(0, pruned.length)+pruneStr;
|
||||||
}),
|
|
||||||
|
|
||||||
words: function(str, delimiter) {
|
|
||||||
return String(str).split(delimiter || " ");
|
|
||||||
},
|
},
|
||||||
|
|
||||||
pad: sArgs(function(str, length, padStr, type) {
|
words: function(str, delimiter) {
|
||||||
var padding = '',
|
return _s.trim(str, delimiter).split(delimiter || /\s+/);
|
||||||
padlen = 0;
|
},
|
||||||
|
|
||||||
length = parseNumber(length);
|
pad: function(str, length, padStr, type) {
|
||||||
|
str += '';
|
||||||
|
|
||||||
|
var padlen = 0;
|
||||||
|
|
||||||
|
length = ~~length;
|
||||||
|
|
||||||
|
if (!padStr) {
|
||||||
|
padStr = ' ';
|
||||||
|
} else if (padStr.length > 1) {
|
||||||
|
padStr = padStr.charAt(0);
|
||||||
|
}
|
||||||
|
|
||||||
if (!padStr) { padStr = ' '; }
|
|
||||||
else if (padStr.length > 1) { padStr = padStr.charAt(0); }
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case 'right':
|
case 'right':
|
||||||
padlen = (length - str.length);
|
padlen = (length - str.length);
|
||||||
padding = strRepeat(padStr, padlen);
|
return str + strRepeat(padStr, padlen);
|
||||||
str = str+padding;
|
|
||||||
break;
|
|
||||||
case 'both':
|
case 'both':
|
||||||
padlen = (length - str.length);
|
padlen = (length - str.length);
|
||||||
padding = {
|
return strRepeat(padStr, Math.ceil(padlen/2)) +
|
||||||
'left' : strRepeat(padStr, Math.ceil(padlen/2)),
|
str +
|
||||||
'right': strRepeat(padStr, Math.floor(padlen/2))
|
strRepeat(padStr, Math.floor(padlen/2));
|
||||||
};
|
|
||||||
str = padding.left+str+padding.right;
|
|
||||||
break;
|
|
||||||
default: // 'left'
|
default: // 'left'
|
||||||
padlen = (length - str.length);
|
padlen = (length - str.length);
|
||||||
padding = strRepeat(padStr, padlen);;
|
return strRepeat(padStr, padlen) + str;
|
||||||
str = padding+str;
|
|
||||||
}
|
}
|
||||||
return str;
|
},
|
||||||
}),
|
|
||||||
|
|
||||||
lpad: function(str, length, padStr) {
|
lpad: function(str, length, padStr) {
|
||||||
return _s.pad(str, length, padStr);
|
return _s.pad(str, length, padStr);
|
||||||
|
@ -396,41 +419,76 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
toNumber: function(str, decimals) {
|
toNumber: function(str, decimals) {
|
||||||
var num = parseNumber(parseNumber(str).toFixed(parseNumber(decimals)));
|
str += '';
|
||||||
return (!(num === 0 && (str !== "0" && str !== 0))) ? num : Number.NaN;
|
var num = parseNumber(parseNumber(str).toFixed(~~decimals));
|
||||||
|
return num === 0 && !str.match(/^0+$/) ? Number.NaN : num;
|
||||||
},
|
},
|
||||||
|
|
||||||
strRight: sArgs(function(sourceStr, sep){
|
strRight: function(str, sep){
|
||||||
var pos = (!sep) ? -1 : sourceStr.indexOf(sep);
|
str += ''; sep = sep != null ? ''+sep : sep;
|
||||||
return (pos != -1) ? sourceStr.slice(pos+sep.length, sourceStr.length) : sourceStr;
|
var pos = !sep ? -1 : str.indexOf(sep);
|
||||||
}),
|
return ~pos ? str.slice(pos+sep.length, str.length) : str;
|
||||||
|
},
|
||||||
|
|
||||||
strRightBack: sArgs(function(sourceStr, sep){
|
strRightBack: function(str, sep){
|
||||||
var pos = (!sep) ? -1 : sourceStr.lastIndexOf(sep);
|
str += ''; sep = sep != null ? ''+sep : sep;
|
||||||
return (pos != -1) ? sourceStr.slice(pos+sep.length, sourceStr.length) : sourceStr;
|
var pos = !sep ? -1 : str.lastIndexOf(sep);
|
||||||
}),
|
return ~pos ? str.slice(pos+sep.length, str.length) : str;
|
||||||
|
},
|
||||||
|
|
||||||
strLeft: sArgs(function(sourceStr, sep){
|
strLeft: function(str, sep){
|
||||||
var pos = (!sep) ? -1 : sourceStr.indexOf(sep);
|
str += ''; sep = sep != null ? ''+sep : sep;
|
||||||
return (pos != -1) ? sourceStr.slice(0, pos) : sourceStr;
|
var pos = !sep ? -1 : str.indexOf(sep);
|
||||||
}),
|
return ~pos ? str.slice(0, pos) : str;
|
||||||
|
},
|
||||||
|
|
||||||
strLeftBack: sArgs(function(sourceStr, sep){
|
strLeftBack: function(str, sep){
|
||||||
var pos = sourceStr.lastIndexOf(sep);
|
str += ''; sep = sep != null ? ''+sep : sep;
|
||||||
return (pos != -1) ? sourceStr.slice(0, pos) : sourceStr;
|
var pos = str.lastIndexOf(sep);
|
||||||
}),
|
return ~pos ? str.slice(0, pos) : str;
|
||||||
|
},
|
||||||
|
|
||||||
|
toSentence: function(array, separator, lastSeparator) {
|
||||||
|
separator || (separator = ', ');
|
||||||
|
lastSeparator || (lastSeparator = ' and ');
|
||||||
|
var length = array.length, str = '';
|
||||||
|
|
||||||
|
for (var i = 0; i < length; i++) {
|
||||||
|
str += array[i];
|
||||||
|
if (i === (length - 2)) { str += lastSeparator; }
|
||||||
|
else if (i < (length - 1)) { str += separator; }
|
||||||
|
}
|
||||||
|
|
||||||
|
return str;
|
||||||
|
},
|
||||||
|
|
||||||
|
slugify: function(str) {
|
||||||
|
var from = "ąàáäâãćęèéëêìíïîłńòóöôõùúüûñçżź",
|
||||||
|
to = "aaaaaaceeeeeiiiilnooooouuuunczz",
|
||||||
|
regex = new RegExp(defaultToWhiteSpace(from), 'g');
|
||||||
|
|
||||||
|
str = (''+str).toLowerCase();
|
||||||
|
|
||||||
|
str = str.replace(regex, function(ch){
|
||||||
|
var index = from.indexOf(ch);
|
||||||
|
return to.charAt(index) || '-';
|
||||||
|
});
|
||||||
|
|
||||||
|
return _s.trim(str.replace(/[^\w\s-]/g, '').replace(/[-\s]+/g, '-'), '-');
|
||||||
|
},
|
||||||
|
|
||||||
exports: function() {
|
exports: function() {
|
||||||
var result = {};
|
var result = {};
|
||||||
|
|
||||||
for (var prop in this) {
|
for (var prop in this) {
|
||||||
if (!this.hasOwnProperty(prop) || prop == 'include' || prop == 'contains' || prop == 'reverse') continue;
|
if (!this.hasOwnProperty(prop) || ~_s.words('include contains reverse').indexOf(prop)) continue;
|
||||||
result[prop] = this[prop];
|
result[prop] = this[prop];
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
},
|
||||||
|
|
||||||
|
repeat: strRepeat
|
||||||
};
|
};
|
||||||
|
|
||||||
// Aliases
|
// Aliases
|
||||||
|
@ -439,8 +497,8 @@
|
||||||
_s.lstrip = _s.ltrim;
|
_s.lstrip = _s.ltrim;
|
||||||
_s.rstrip = _s.rtrim;
|
_s.rstrip = _s.rtrim;
|
||||||
_s.center = _s.lrpad;
|
_s.center = _s.lrpad;
|
||||||
_s.ljust = _s.lpad;
|
_s.rjust = _s.lpad;
|
||||||
_s.rjust = _s.rpad;
|
_s.ljust = _s.rpad;
|
||||||
_s.contains = _s.include;
|
_s.contains = _s.include;
|
||||||
|
|
||||||
// CommonJS module is defined
|
// CommonJS module is defined
|
||||||
|
@ -451,18 +509,17 @@
|
||||||
}
|
}
|
||||||
exports._s = _s;
|
exports._s = _s;
|
||||||
|
|
||||||
// Integrate with Underscore.js
|
} else if (typeof define === 'function' && define.amd) {
|
||||||
} else if (typeof root._ !== 'undefined') {
|
// Register as a named module with AMD.
|
||||||
// root._.mixin(_s);
|
define('underscore.string', function() {
|
||||||
root._.string = _s;
|
return _s;
|
||||||
root._.str = root._.string;
|
});
|
||||||
|
|
||||||
// Or define it
|
|
||||||
} else {
|
} else {
|
||||||
root._ = {
|
// Integrate with Underscore.js if defined
|
||||||
string: _s,
|
// or create our own underscore object.
|
||||||
str: _s
|
root._ = root._ || {};
|
||||||
};
|
root._.string = root._.str = _s;
|
||||||
}
|
}
|
||||||
|
|
||||||
}(this || window));
|
}(this || window));
|
|
@ -1,31 +0,0 @@
|
||||||
// Underscore.js 1.3.1
|
|
||||||
// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
|
|
||||||
// Underscore is freely distributable under the MIT license.
|
|
||||||
// Portions of Underscore are inspired or borrowed from Prototype,
|
|
||||||
// Oliver Steele's Functional, and John Resig's Micro-Templating.
|
|
||||||
// For all details and documentation:
|
|
||||||
// http://documentcloud.github.com/underscore
|
|
||||||
(function(){function q(a,c,d){if(a===c)return a!==0||1/a==1/c;if(a==null||c==null)return a===c;if(a._chain)a=a._wrapped;if(c._chain)c=c._wrapped;if(a.isEqual&&b.isFunction(a.isEqual))return a.isEqual(c);if(c.isEqual&&b.isFunction(c.isEqual))return c.isEqual(a);var e=l.call(a);if(e!=l.call(c))return false;switch(e){case "[object String]":return a==String(c);case "[object Number]":return a!=+a?c!=+c:a==0?1/a==1/c:a==+c;case "[object Date]":case "[object Boolean]":return+a==+c;case "[object RegExp]":return a.source==
|
|
||||||
c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if(typeof a!="object"||typeof c!="object")return false;for(var f=d.length;f--;)if(d[f]==a)return true;d.push(a);var f=0,g=true;if(e=="[object Array]"){if(f=a.length,g=f==c.length)for(;f--;)if(!(g=f in a==f in c&&q(a[f],c[f],d)))break}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return false;for(var h in a)if(b.has(a,h)&&(f++,!(g=b.has(c,h)&&q(a[h],c[h],d))))break;if(g){for(h in c)if(b.has(c,
|
|
||||||
h)&&!f--)break;g=!f}}d.pop();return g}var r=this,G=r._,n={},k=Array.prototype,o=Object.prototype,i=k.slice,H=k.unshift,l=o.toString,I=o.hasOwnProperty,w=k.forEach,x=k.map,y=k.reduce,z=k.reduceRight,A=k.filter,B=k.every,C=k.some,p=k.indexOf,D=k.lastIndexOf,o=Array.isArray,J=Object.keys,s=Function.prototype.bind,b=function(a){return new m(a)};if(typeof exports!=="undefined"){if(typeof module!=="undefined"&&module.exports)exports=module.exports=b;exports._=b}else r._=b;b.VERSION="1.3.1";var j=b.each=
|
|
||||||
b.forEach=function(a,c,d){if(a!=null)if(w&&a.forEach===w)a.forEach(c,d);else if(a.length===+a.length)for(var e=0,f=a.length;e<f;e++){if(e in a&&c.call(d,a[e],e,a)===n)break}else for(e in a)if(b.has(a,e)&&c.call(d,a[e],e,a)===n)break};b.map=b.collect=function(a,c,b){var e=[];if(a==null)return e;if(x&&a.map===x)return a.map(c,b);j(a,function(a,g,h){e[e.length]=c.call(b,a,g,h)});if(a.length===+a.length)e.length=a.length;return e};b.reduce=b.foldl=b.inject=function(a,c,d,e){var f=arguments.length>2;a==
|
|
||||||
null&&(a=[]);if(y&&a.reduce===y)return e&&(c=b.bind(c,e)),f?a.reduce(c,d):a.reduce(c);j(a,function(a,b,i){f?d=c.call(e,d,a,b,i):(d=a,f=true)});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(z&&a.reduceRight===z)return e&&(c=b.bind(c,e)),f?a.reduceRight(c,d):a.reduceRight(c);var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect=
|
|
||||||
function(a,c,b){var e;E(a,function(a,g,h){if(c.call(b,a,g,h))return e=a,true});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(A&&a.filter===A)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(B&&a.every===B)return a.every(c,b);j(a,function(a,g,h){if(!(e=
|
|
||||||
e&&c.call(b,a,g,h)))return n});return e};var E=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(C&&a.some===C)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return n});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;return p&&a.indexOf===p?a.indexOf(c)!=-1:b=E(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck=
|
|
||||||
function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a))return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b<e.computed&&(e={value:a,computed:b})});
|
|
||||||
return e.value};b.shuffle=function(a){var b=[],d;j(a,function(a,f){f==0?b[0]=a:(d=Math.floor(Math.random()*(f+1)),b[f]=b[d],b[d]=a)});return b};b.sortBy=function(a,c,d){return b.pluck(b.map(a,function(a,b,g){return{value:a,criteria:c.call(d,a,b,g)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;return c<d?-1:c>d?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};j(a,function(a,b){var c=e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a,
|
|
||||||
c,d){d||(d=b.identity);for(var e=0,f=a.length;e<f;){var g=e+f>>1;d(a[g])<d(c)?e=g+1:f=g}return e};b.toArray=function(a){return!a?[]:a.toArray?a.toArray():b.isArray(a)?i.call(a):b.isArguments(a)?i.call(a):b.values(a)};b.size=function(a){return b.toArray(a).length};b.first=b.head=function(a,b,d){return b!=null&&!d?i.call(a,0,b):a[0]};b.initial=function(a,b,d){return i.call(a,0,a.length-(b==null||d?1:b))};b.last=function(a,b,d){return b!=null&&!d?i.call(a,Math.max(a.length-b,0)):a[a.length-1]};b.rest=
|
|
||||||
b.tail=function(a,b,d){return i.call(a,b==null||d?1:b)};b.compact=function(a){return b.filter(a,function(a){return!!a})};b.flatten=function(a,c){return b.reduce(a,function(a,e){if(b.isArray(e))return a.concat(c?e:b.flatten(e));a[a.length]=e;return a},[])};b.without=function(a){return b.difference(a,i.call(arguments,1))};b.uniq=b.unique=function(a,c,d){var d=d?b.map(a,d):a,e=[];b.reduce(d,function(d,g,h){if(0==h||(c===true?b.last(d)!=g:!b.include(d,g)))d[d.length]=g,e[e.length]=a[h];return d},[]);
|
|
||||||
return e};b.union=function(){return b.uniq(b.flatten(arguments,true))};b.intersection=b.intersect=function(a){var c=i.call(arguments,1);return b.filter(b.uniq(a),function(a){return b.every(c,function(c){return b.indexOf(c,a)>=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1));return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e<c;e++)d[e]=b.pluck(a,""+e);return d};b.indexOf=function(a,c,
|
|
||||||
d){if(a==null)return-1;var e;if(d)return d=b.sortedIndex(a,c),a[d]===c?d:-1;if(p&&a.indexOf===p)return a.indexOf(c);for(d=0,e=a.length;d<e;d++)if(d in a&&a[d]===c)return d;return-1};b.lastIndexOf=function(a,b){if(a==null)return-1;if(D&&a.lastIndexOf===D)return a.lastIndexOf(b);for(var d=a.length;d--;)if(d in a&&a[d]===b)return d;return-1};b.range=function(a,b,d){arguments.length<=1&&(b=a||0,a=0);for(var d=arguments[2]||1,e=Math.max(Math.ceil((b-a)/d),0),f=0,g=Array(e);f<e;)g[f++]=a,a+=d;return g};
|
|
||||||
var F=function(){};b.bind=function(a,c){var d,e;if(a.bind===s&&s)return s.apply(a,i.call(arguments,1));if(!b.isFunction(a))throw new TypeError;e=i.call(arguments,2);return d=function(){if(!(this instanceof d))return a.apply(c,e.concat(i.call(arguments)));F.prototype=a.prototype;var b=new F,g=a.apply(b,e.concat(i.call(arguments)));return Object(g)===g?g:b}};b.bindAll=function(a){var c=i.call(arguments,1);c.length==0&&(c=b.functions(a));j(c,function(c){a[c]=b.bind(a[c],a)});return a};b.memoize=function(a,
|
|
||||||
c){var d={};c||(c=b.identity);return function(){var e=c.apply(this,arguments);return b.has(d,e)?d[e]:d[e]=a.apply(this,arguments)}};b.delay=function(a,b){var d=i.call(arguments,2);return setTimeout(function(){return a.apply(a,d)},b)};b.defer=function(a){return b.delay.apply(b,[a,1].concat(i.call(arguments,1)))};b.throttle=function(a,c){var d,e,f,g,h,i=b.debounce(function(){h=g=false},c);return function(){d=this;e=arguments;var b;f||(f=setTimeout(function(){f=null;h&&a.apply(d,e);i()},c));g?h=true:
|
|
||||||
a.apply(d,e);i();g=true}};b.debounce=function(a,b){var d;return function(){var e=this,f=arguments;clearTimeout(d);d=setTimeout(function(){d=null;a.apply(e,f)},b)}};b.once=function(a){var b=false,d;return function(){if(b)return d;b=true;return d=a.apply(this,arguments)}};b.wrap=function(a,b){return function(){var d=[a].concat(i.call(arguments,0));return b.apply(this,d)}};b.compose=function(){var a=arguments;return function(){for(var b=arguments,d=a.length-1;d>=0;d--)b=[a[d].apply(this,b)];return b[0]}};
|
|
||||||
b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=J||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.defaults=function(a){j(i.call(arguments,
|
|
||||||
1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return q(a,b,[])};b.isEmpty=function(a){if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=o||function(a){return l.call(a)=="[object Array]"};b.isObject=function(a){return a===Object(a)};
|
|
||||||
b.isArguments=function(a){return l.call(a)=="[object Arguments]"};if(!b.isArguments(arguments))b.isArguments=function(a){return!(!a||!b.has(a,"callee"))};b.isFunction=function(a){return l.call(a)=="[object Function]"};b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate=function(a){return l.call(a)=="[object Date]"};
|
|
||||||
b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.has=function(a,b){return I.call(a,b)};b.noConflict=function(){r._=G;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e<a;e++)b.call(d,e)};b.escape=function(a){return(""+a).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")};b.mixin=function(a){j(b.functions(a),
|
|
||||||
function(c){K(c,b[c]=a[c])})};var L=0;b.uniqueId=function(a){var b=L++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var t=/.^/,u=function(a){return a.replace(/\\\\/g,"\\").replace(/\\'/g,"'")};b.template=function(a,c){var d=b.templateSettings,d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(d.escape||t,function(a,b){return"',_.escape("+
|
|
||||||
u(b)+"),'"}).replace(d.interpolate||t,function(a,b){return"',"+u(b)+",'"}).replace(d.evaluate||t,function(a,b){return"');"+u(b).replace(/[\r\n\t]/g," ")+";__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');",e=new Function("obj","_",d);return c?e(c,b):function(a){return e.call(this,a,b)}};b.chain=function(a){return b(a).chain()};var m=function(a){this._wrapped=a};b.prototype=m.prototype;var v=function(a,c){return c?b(a).chain():a},K=function(a,c){m.prototype[a]=
|
|
||||||
function(){var a=i.call(arguments);H.call(a,this._wrapped);return v(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];m.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return v(d,this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];m.prototype[a]=function(){return v(b.apply(this._wrapped,arguments),this._chain)}});m.prototype.chain=function(){this._chain=
|
|
||||||
true;return this};m.prototype.value=function(){return this._wrapped}}).call(this);
|
|
|
@ -1,14 +0,0 @@
|
||||||
(function(k){var o=String.prototype.trim,l=function(a,b){for(var c=[];b>0;c[--b]=a);return c.join("")},d=function(a){return function(){for(var b=Array.prototype.slice.call(arguments),c=0;c<b.length;c++)b[c]=b[c]==null?"":""+b[c];return a.apply(null,b)}},m=function(){function a(a){return Object.prototype.toString.call(a).slice(8,-1).toLowerCase()}var b=function(){b.cache.hasOwnProperty(arguments[0])||(b.cache[arguments[0]]=b.parse(arguments[0]));return b.format.call(null,b.cache[arguments[0]],arguments)};
|
|
||||||
b.format=function(b,n){var e=1,d=b.length,f="",j=[],h,i,g,k;for(h=0;h<d;h++)if(f=a(b[h]),f==="string")j.push(b[h]);else if(f==="array"){g=b[h];if(g[2]){f=n[e];for(i=0;i<g[2].length;i++){if(!f.hasOwnProperty(g[2][i]))throw m('[_.sprintf] property "%s" does not exist',g[2][i]);f=f[g[2][i]]}}else f=g[1]?n[g[1]]:n[e++];if(/[^s]/.test(g[8])&&a(f)!="number")throw m("[_.sprintf] expecting number but found %s",a(f));switch(g[8]){case "b":f=f.toString(2);break;case "c":f=String.fromCharCode(f);break;case "d":f=
|
|
||||||
parseInt(f,10);break;case "e":f=g[7]?f.toExponential(g[7]):f.toExponential();break;case "f":f=g[7]?parseFloat(f).toFixed(g[7]):parseFloat(f);break;case "o":f=f.toString(8);break;case "s":f=(f=String(f))&&g[7]?f.substring(0,g[7]):f;break;case "u":f=Math.abs(f);break;case "x":f=f.toString(16);break;case "X":f=f.toString(16).toUpperCase()}f=/[def]/.test(g[8])&&g[3]&&f>=0?"+"+f:f;i=g[4]?g[4]=="0"?"0":g[4].charAt(1):" ";k=g[6]-String(f).length;i=g[6]?l(i,k):"";j.push(g[5]?f+i:i+f)}return j.join("")};b.cache=
|
|
||||||
{};b.parse=function(a){for(var b=[],e=[],d=0;a;){if((b=/^[^\x25]+/.exec(a))!==null)e.push(b[0]);else if((b=/^\x25{2}/.exec(a))!==null)e.push("%");else if((b=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(a))!==null){if(b[2]){d|=1;var f=[],j=b[2],h=[];if((h=/^([a-z_][a-z_\d]*)/i.exec(j))!==null)for(f.push(h[1]);(j=j.substring(h[0].length))!=="";)if((h=/^\.([a-z_][a-z_\d]*)/i.exec(j))!==null)f.push(h[1]);else if((h=/^\[(\d+)\]/.exec(j))!==null)f.push(h[1]);
|
|
||||||
else throw"[_.sprintf] huh?";else throw"[_.sprintf] huh?";b[2]=f}else d|=2;if(d===3)throw"[_.sprintf] mixing positional and named placeholders is not (yet) supported";e.push(b)}else throw"[_.sprintf] huh?";a=a.substring(b[0].length)}return e};return b}(),e={VERSION:"1.2.0",isBlank:d(function(a){return/^\s*$/.test(a)}),stripTags:d(function(a){return a.replace(/<\/?[^>]+>/ig,"")}),capitalize:d(function(a){return a.charAt(0).toUpperCase()+a.substring(1).toLowerCase()}),chop:d(function(a,b){for(var b=
|
|
||||||
b*1||0||a.length,c=[],e=0;e<a.length;)c.push(a.slice(e,e+b)),e+=b;return c}),clean:d(function(a){return e.strip(a.replace(/\s+/g," "))}),count:d(function(a,b){for(var c=0,e,d=0;d<a.length;)e=a.indexOf(b,d),e>=0&&c++,d=d+(e>=0?e:0)+b.length;return c}),chars:d(function(a){return a.split("")}),escapeHTML:d(function(a){return a.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}),unescapeHTML:d(function(a){return a.replace(/</g,"<").replace(/>/g,
|
|
||||||
">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&")}),escapeRegExp:d(function(a){return a.replace(/([-.*+?^${}()|[\]\/\\])/g,"\\$1")}),insert:d(function(a,b,c){a=a.split("");a.splice(b*1||0,0,c);return a.join("")}),include:d(function(a,b){return a.indexOf(b)!==-1}),join:d(function(a){var b=Array.prototype.slice.call(arguments);return b.join(b.shift())}),lines:d(function(a){return a.split("\n")}),reverse:d(function(a){return Array.prototype.reverse.apply(String(a).split("")).join("")}),
|
|
||||||
splice:d(function(a,b,c,e){a=a.split("");a.splice(b*1||0,c*1||0,e);return a.join("")}),startsWith:d(function(a,b){return a.length>=b.length&&a.substring(0,b.length)===b}),endsWith:d(function(a,b){return a.length>=b.length&&a.substring(a.length-b.length)===b}),succ:d(function(a){var b=a.split("");b.splice(a.length-1,1,String.fromCharCode(a.charCodeAt(a.length-1)+1));return b.join("")}),titleize:d(function(a){for(var a=a.split(" "),b,c=0;c<a.length;c++)b=a[c].split(""),typeof b[0]!=="undefined"&&(b[0]=
|
|
||||||
b[0].toUpperCase()),c+1===a.length?a[c]=b.join(""):a[c]=b.join("")+" ";return a.join("")}),camelize:d(function(a){return e.trim(a).replace(/(\-|_|\s)+(.)?/g,function(a,c,e){return e?e.toUpperCase():""})}),underscored:function(a){return e.trim(a).replace(/([a-z\d])([A-Z]+)/g,"$1_$2").replace(/\-|\s+/g,"_").toLowerCase()},dasherize:function(a){return e.trim(a).replace(/([a-z\d])([A-Z]+)/g,"$1-$2").replace(/^([A-Z]+)/,"-$1").replace(/\_|\s+/g,"-").toLowerCase()},humanize:function(a){return e.capitalize(this.underscored(a).replace(/_id$/,
|
|
||||||
"").replace(/_/g," "))},trim:d(function(a,b){if(!b&&o)return o.call(a);b=b?e.escapeRegExp(b):"\\s";return a.replace(RegExp("^["+b+"]+|["+b+"]+$","g"),"")}),ltrim:d(function(a,b){b=b?e.escapeRegExp(b):"\\s";return a.replace(RegExp("^["+b+"]+","g"),"")}),rtrim:d(function(a,b){b=b?e.escapeRegExp(b):"\\s";return a.replace(RegExp("["+b+"]+$","g"),"")}),truncate:d(function(a,b,c){b=b*1||0;return a.length>b?a.slice(0,b)+(c||"..."):a}),prune:d(function(a,b,c){var c=c||"...",b=b*1||0,d="",d=a.substring(b-
|
|
||||||
1,b+1).search(/^\w\w$/)===0?e.rtrim(a.slice(0,b).replace(/([\W][\w]*)$/,"")):e.rtrim(a.slice(0,b)),d=d.replace(/\W+$/,"");return d.length+c.length>a.length?a:d+c}),words:function(a,b){return String(a).split(b||" ")},pad:d(function(a,b,c,e){var d="",d=0,b=b*1||0;c?c.length>1&&(c=c.charAt(0)):c=" ";switch(e){case "right":d=b-a.length;d=l(c,d);a+=d;break;case "both":d=b-a.length;d={left:l(c,Math.ceil(d/2)),right:l(c,Math.floor(d/2))};a=d.left+a+d.right;break;default:d=b-a.length,d=l(c,d),a=d+a}return a}),
|
|
||||||
lpad:function(a,b,c){return e.pad(a,b,c)},rpad:function(a,b,c){return e.pad(a,b,c,"right")},lrpad:function(a,b,c){return e.pad(a,b,c,"both")},sprintf:m,vsprintf:function(a,b){b.unshift(a);return m.apply(null,b)},toNumber:function(a,b){var c;c=(a*1||0).toFixed(b*1||0)*1||0;return!(c===0&&a!=="0"&&a!==0)?c:Number.NaN},strRight:d(function(a,b){var c=!b?-1:a.indexOf(b);return c!=-1?a.slice(c+b.length,a.length):a}),strRightBack:d(function(a,b){var c=!b?-1:a.lastIndexOf(b);return c!=-1?a.slice(c+b.length,
|
|
||||||
a.length):a}),strLeft:d(function(a,b){var c=!b?-1:a.indexOf(b);return c!=-1?a.slice(0,c):a}),strLeftBack:d(function(a,b){var c=a.lastIndexOf(b);return c!=-1?a.slice(0,c):a}),exports:function(){var a={},b;for(b in this)if(this.hasOwnProperty(b)&&!(b=="include"||b=="contains"||b=="reverse"))a[b]=this[b];return a}};e.strip=e.trim;e.lstrip=e.ltrim;e.rstrip=e.rtrim;e.center=e.lrpad;e.ljust=e.lpad;e.rjust=e.rpad;e.contains=e.include;if(typeof exports!=="undefined"){if(typeof module!=="undefined"&&module.exports)module.exports=
|
|
||||||
e;exports._s=e}else typeof k._!=="undefined"?(k._.string=e,k._.str=k._.string):k._={string:e,str:e}})(this||window);
|
|
Loading…
Reference in New Issue