Differential D4581 Diff 9612 externals/javelin/src/lib/control/typeahead/normalizer/TypeaheadNormalizer.js
Changeset View
Changeset View
Standalone View
Standalone View
externals/javelin/src/lib/control/typeahead/normalizer/TypeaheadNormalizer.js
- This file was added.
| Property | Old Value | New Value |
|---|---|---|
| File Mode | null | 100755 |
| /** | |||||
| * @requires javelin-install | |||||
| * @provides javelin-typeahead-normalizer | |||||
| * @javelin | |||||
| */ | |||||
| /** | |||||
| * @group control | |||||
| */ | |||||
| JX.install('TypeaheadNormalizer', { | |||||
| statics : { | |||||
| /** | |||||
| * Normalizes a string by lowercasing it and stripping out extra spaces | |||||
| * and punctuation. | |||||
| * | |||||
| * @param string | |||||
| * @return string Normalized string. | |||||
| */ | |||||
| normalize : function(str) { | |||||
| return ('' + str) | |||||
| .toLocaleLowerCase() | |||||
| .replace(/[\.,-\/#!$%\^&\*;:{}=\-_`~()]/g, '') | |||||
| .replace(/ +/g, ' ') | |||||
| .replace(/^\s*|\s*$/g, ''); | |||||
| } | |||||
| } | |||||
| }); | |||||