Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conveniently use objects in Typeahead #7298

Closed
wants to merge 14 commits into from
Closed

Commits on Mar 16, 2013

  1. Merge pull request #1 from twitter/3.0.0-wip

    Use translucent box shadow on hr elements; colorize hr elements within a...
    pickypg committed Mar 16, 2013
    Configuration menu
    Copy the full SHA
    ab0a283 View commit details
    Browse the repository at this point in the history
  2. Fix dropdown (and therefore typeahead) wrap

    I have recently been experimenting with a lot of Typeahead controls, and I ran into a situation where my Typeahead was too wide for my screen, particularly on mobile devices, and it was not wrapping as I had expected it to do.
    
    http://jsfiddle.net/Mtxkn/4/
    
    Changing the CSS for .dropdown-menu > li > a to white-space: normal causes it to wrap in every scenario that I have seen, whereas leaving it as nowrap never does what I want when the text is too long for a given item.
    
    It's possible that this has ramifications for other dropdown menus, but honestly I expect that even those would prefer to wrap than to extend the screen horizontally.  If that is not the case, then it would work to change the typeahead version of this only:
    
    ```css
    .typeahead > li > a {
      white-space: normal;
    }
    ```
    pickypg committed Mar 16, 2013
    Configuration menu
    Copy the full SHA
    db8996a View commit details
    Browse the repository at this point in the history
  3. Flexibly support JSON object in Typeahead

    http://jsfiddle.net/Mtxkn/11/
    
    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 to 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.
    
    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 would want to at least override `matcher`:
    
    ```javascript
    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.
    pickypg committed Mar 16, 2013
    Configuration menu
    Copy the full SHA
    e1bc820 View commit details
    Browse the repository at this point in the history
  4. Unit tests for object friendly sorting

    Verifying details of sorting work as intended
    pickypg committed Mar 16, 2013
    Configuration menu
    Copy the full SHA
    60904c0 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    5152f6c View commit details
    Browse the repository at this point in the history
  6. Simplifying method name caught by unit test

    Woops
    pickypg committed Mar 16, 2013
    Configuration menu
    Copy the full SHA
    ded6297 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    e52dbd4 View commit details
    Browse the repository at this point in the history
  8. Testing

    pickypg committed Mar 16, 2013
    Configuration menu
    Copy the full SHA
    2f489a3 View commit details
    Browse the repository at this point in the history
  9. Singling out failures

    pickypg committed Mar 16, 2013
    Configuration menu
    Copy the full SHA
    1ab7259 View commit details
    Browse the repository at this point in the history
  10. Verifying failure

    pickypg committed Mar 16, 2013
    Configuration menu
    Copy the full SHA
    74e0591 View commit details
    Browse the repository at this point in the history
  11. Fixing sleepy mistake caught by unit test

    Just goes to show why unit testing is so good. Catches stupid mistakes
    pickypg committed Mar 16, 2013
    Configuration menu
    Copy the full SHA
    5c5d59c View commit details
    Browse the repository at this point in the history
  12. Re-adding unit test for corrected code

    Glad I did the test. Next time I'll have to set up the unit test environment locally so there isn't so much pull request spam.
    pickypg committed Mar 16, 2013
    Configuration menu
    Copy the full SHA
    f718caa View commit details
    Browse the repository at this point in the history
  13. Adding overridable behavior when showing menu

    Enables simpler overriding of either just showing the menu (location) or changing behavior for `show` without effecting `showMenu`.
    pickypg committed Mar 16, 2013
    Configuration menu
    Copy the full SHA
    a345147 View commit details
    Browse the repository at this point in the history

Commits on Apr 3, 2013

  1. Fix return inconsistent return points

    If the position is out of range, then it would simply `return` unlike all other `return`s in the function.  This can at least break at line 201, as well as anyone overriding expecting a return.
    
    This change causes it to return `this` in all cases to avoid any unexpected exceptions.
    pickypg committed Apr 3, 2013
    Configuration menu
    Copy the full SHA
    cf5f40c View commit details
    Browse the repository at this point in the history