Created by: pickypg
This adds the ability to conveniently override a lot more methods (ones that I arbitrarily identified as reasonable through my own usage), as well as providing an updated sorter
method for interaction with objects. Further, by exposing each internal sorting step as a method, as well as the query values, each piece can be overridden to enable Typeahead to work with arbitrary data. With the changes, default behavior should remain unchanged.
The extra sorting option, sortAny
, is added to support the case where the source gives results that may not match the actual query at all, such as through Ajax results that may have typo correction. Such cases must also override matcher
:
matcher: function() {
return true
}
That can be done without changes, but the sorting would have to be completely overridden in its current form even for simple, arbitrary object sorting. Allowing each step to be overridden enables arbitrary object support for both the item
and the query due to the one-time expense of looking up the query in both normal and lowercase form; those methods could return anything relevant to the actual task at hand rather than a single string as well.
Overriding highlighter
will always be necessary to support JSON objects, but that is already exposed.
Also attached are a few unit tests to test the minor added functions.
Finally, this is my first attempt at a multi-file pull request, and it's bringing across a CSS change that I referenced in a different pull request (dropdowns.less). I don't know how to remove that as part of the current request, so I apologize for the clutter.