Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bootstrap
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 263
    • Issues 263
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 114
    • Merge requests 114
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Bootstrap
  • bootstrap
  • Merge requests
  • !7298

Conveniently use objects in Typeahead

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/pickypg/3.0.0-wip into 3.0.0-wip Mar 16, 2013
  • Overview 0
  • Commits 14
  • Pipelines 0
  • Changes 4

Created by: pickypg

http://jsfiddle.net/Mtxkn/15/

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.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/pickypg/3.0.0-wip