From 6a8a403cc95543f34d0662fbfeebaf024ce66c01 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Tue, 16 Jul 2013 17:46:12 -0400 Subject: [PATCH] Make prefix_sort just use obj itself if get_item is not passed in (This facilitates using prefix_sort for a list that doesn't require a function call to get to the object of interest.) (imported from commit 5a0e550c313b9c57f0434c7246fcea451219d1b8) --- zephyr/static/js/typeahead_helper.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/zephyr/static/js/typeahead_helper.js b/zephyr/static/js/typeahead_helper.js index cd8a88c1c5..6f6ab9132d 100644 --- a/zephyr/static/js/typeahead_helper.js +++ b/zephyr/static/js/typeahead_helper.js @@ -115,7 +115,13 @@ function prefix_sort(query, objs, get_item) { var obj = objs.shift(); while (obj) { - var item = get_item(obj); + var item; + if (get_item) { + item = get_item(obj); + } + else { + item = obj; + } if (item.indexOf(query) === 0) beginswithCaseSensitive.push(obj); else if (item.toLowerCase().indexOf(query.toLowerCase()) === 0)