/*
No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
The length also accounts for the ellipsis, so a maximum length of 10 and a string
'Hello World!' produces 'Hello W...'.
@function
@param {String} str The string to truncate.
@param {Number} chars Max number of characters.
@param {Boolean} opt_protectEscapedCharacters Whether to protect escaped characters from being cut off in the middle.
@return {String} The truncated {@code str} string.
*/
var truncate = exports.truncate = function(str, chars, opt_protectEscapedCharacters) {
if (opt_protectEscapedCharacters) {
goog.string.unescapeEntities(this);
}
if (str.length > chars) {
return str.substring(0, chars - 3) + '…';
}
if (opt_protectEscapedCharacters) {
str.htmlEscape(this);
}
return this;
};
// Validators
/**
Base validator object.
@class module:montage/core/converter.Validator
@extends module:montage/core/core.Montage
*/
var Validator = exports.Validator = Montage.create(Montage, /** @lends module:montage/core/converter.Validator# */{
/**
@type {Object}
@default null
*/
validate: {
value: null
}
});
// Converters
/**
@class module:montage/core/converter.Converter
@classdesc The base Converter class that is extended by specific converter classes. A Converter has two primary methods:
convert(value)
: Convert value to a String.
revert(value)
: Do the reverse. Depending on the specific converter being used, the reverse operation may be "lossy".