www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit f5a9dd6812f84d2d38af6568567147e7fbda6af7
parent d1d70d3df8546a94e8dab0ab59346d3e33b97788
Author: Dan Stillman <dstillman@zotero.org>
Date:   Wed, 16 Dec 2009 00:28:24 +0000

Missing file from previous commit: Zotero.Utilities.ellipsize(str, len, countChars)


Diffstat:
Mchrome/content/zotero/xpcom/utilities.js | 18++++++++++++++++++
1 file changed, 18 insertions(+), 0 deletions(-)

diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js @@ -529,6 +529,24 @@ Zotero.Utilities.prototype.lpad = function(string, pad, length) { /** + * Shorten and add an ellipsis to a string if necessary + * + * @param {String} str + * @param {Integer} len + * @param {Boolean} [countChars=false] + */ +Zotero.Utilities.prototype.ellipsize = function (str, len, countChars) { + if (!len) { + throw ("Length not specified in Zotero.Utilities.ellipsize()"); + } + if (str.length > len) { + return str.substr(0, len) + '...' + (countChars ? ' (' + str.length + ' chars)' : ''); + } + return str; +} + + +/** * Port of PHP's number_format() * * MIT Licensed