diff options
Diffstat (limited to 'js/vendor/angular-ui/modules/filters/highlight/highlight.js')
-rw-r--r-- | js/vendor/angular-ui/modules/filters/highlight/highlight.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/js/vendor/angular-ui/modules/filters/highlight/highlight.js b/js/vendor/angular-ui/modules/filters/highlight/highlight.js new file mode 100644 index 000000000..1d1cf6e48 --- /dev/null +++ b/js/vendor/angular-ui/modules/filters/highlight/highlight.js @@ -0,0 +1,21 @@ +/** + * Wraps the + * @param text {string} haystack to search through + * @param search {string} needle to search for + * @param [caseSensitive] {boolean} optional boolean to use case-sensitive searching + */ +angular.module('ui.filters').filter('highlight', function () { + return function (text, search, caseSensitive) { + if (search || angular.isNumber(search)) { + text = text.toString(); + search = search.toString(); + if (caseSensitive) { + return text.split(search).join('<span class="ui-match">' + search + '</span>'); + } else { + return text.replace(new RegExp(search, 'gi'), '<span class="ui-match">$&</span>'); + } + } else { + return text; + } + }; +}); |