1
0
mirror of synced 2024-11-23 21:36:09 +03:00
Commit Graph

2149 Commits

Author SHA1 Message Date
Kevin Brown
7581fa5708 Merge pull request #2588 from fabdouglas/patch-8
Redirect the focus of original input to Select2
2014-10-31 18:13:47 -04:00
Kevin Brown
0daee34626 Fixed Select2 jumping around in Chrome
This fixes #2769, where Select2 will jump around because of how
focus moves to the original element when selections are made.

Because absolute positioning pushed the original element out of the
viewport, bringing it back into the viewport should be the best
fix.
2014-10-31 18:10:13 -04:00
Kevin Brown
0ed9e0283d Merge pull request #2775 from Splaktar/patch-1
Update link for AngularUI
2014-10-31 16:32:56 -04:00
Kevin Brown
f16eb6c621 Merge pull request #2776 from bjornjohansen/master
Replaced nonexistent locale "no" with "nb" (Norwegian Bokmål).
2014-10-30 11:51:11 -04:00
Bjørn Johansen
d1c19eb012 Added the formatMatches string 2014-10-29 22:36:54 +01:00
Bjørn Johansen
3a9896dc4b Replaced nonexistent locale "no" with "nb" (Norwegian Bokmål). Added space before ellipsis for correct punctuation. 2014-10-29 22:13:48 +01:00
Michael Prentice
9ff939b534 Updated AngularJS link to HTTPS
HTTPS everywhere
2014-10-29 12:45:07 -04:00
Michael Prentice
fd9006047c Updated link for AngularUI
They have deprecated the original ui-select2 directive in favor of the new and better supported ui-select directive. This happened a couple weeks ago.
2014-10-29 12:41:03 -04:00
Kevin Brown
dd323687f3 Merge pull request #2364 from joshuajonah/master
Stopped refresh to top when `closeOnSelect: false`
2014-10-24 18:27:25 -04:00
Valdas Petrulis
c1f338cfbf Dont update the results if the term hasn't changed.
https://github.com/ivaynberg/select2/issues/2751
2014-10-23 10:04:39 +03:00
Valdas Petrulis
0cc0ac43f5 Fixed not to break use case: setting the new value after someone was just searching with a different value
https://github.com/ivaynberg/select2/issues/2751
2014-10-22 16:34:28 +03:00
Kevin Brown
f4f09c9d7e Dropping the new translation for now 2014-10-21 21:44:49 -04:00
Kevin Brown
86cd7245d2 Working on the contributor pages 2014-10-21 21:44:01 -04:00
Kevin Brown
19033f60f7 Added disabled example 2014-10-21 21:44:01 -04:00
Kevin Brown
5dd7df33bb Allow programmatic access of Select2 2014-10-21 21:44:01 -04:00
Kevin Brown
5dd5ad93a6 Ensure that the highlighted result is visible
When opening the dropdown, the highlighted result will not always
be scrolled into view if it isn't already.
2014-10-21 21:44:01 -04:00
Kevin Brown
a728d948c1 Added some content to the tagging section 2014-10-21 21:44:01 -04:00
Kevin Brown
559a93bcb6 Added basic implementation of tags
Tags no longer takes an array, as pre-existing tags should already
exist as options in the data adapter.  A compatibility module will
later be added to convert tag data that is passed in to array data.

Tags allow for users to enter their own options, which will be
added to the beginning of the results list.
2014-10-21 21:44:01 -04:00
Kevin Brown
9e130956fc Better compatibility with array data
When using array data, and an option is selected, the data that is
attached to the DOM element will be run through `item` and should
have any private, automatically generated attributes added and
merged with it.
2014-10-21 21:44:00 -04:00
Kevin Brown
72ae0da879 Only generate result ids when the container has an id 2014-10-21 21:44:00 -04:00
Kevin Brown
cdfa0499f4 Accessibility matches better
Now the accessibility for the single select box better matches what
is picked up for a native select.

This fixes an issue with us always setting `aria-activedescendant`,
which caused Orca to always say the full path to the selected
result, instead of saying that the box was a combobox with a
selection. This means that the `aria-activedescendant` attribute
will now only be set when the dropdown is open.

This also switches the results list from a listbox to a tree, which
is what Firefox tells screen readers that a standard select is.
Combined with a change to use `role=group` and `aria-label` for
option group labels, screen readers will now announce the group
that they are in as well.
2014-10-21 21:44:00 -04:00
Kevin Brown
7c8601d33b Better accessibility for results
Options are correctly called out as focus moves around the results
list.
2014-10-21 21:44:00 -04:00
Kevin Brown
00a31df47a Generate more consistent ids
A global id is generated for the container, and each further id
builds off of the global id.
2014-10-21 21:44:00 -04:00
Kevin Brown
e018a6f69e Changed tests to not use deepEqual
We should only be checking the option values that matter, such as
`id` and `text`, instead of checking all of the option values. This
will prevent unexpected breaking when new properties are added to
the options.

Existing properties should be covered by tests to avoid regressions.
2014-10-21 21:44:00 -04:00
Kevin Brown
9102cf9473 Fixed keyboard scrolling
Now when scrolling through results with the keyboard, the
highlighted option will always be visible.
2014-10-21 21:44:00 -04:00
Kevin Brown
9ada3712f7 Single select accessibility
Now the Select2 instance is correctly recognized as a combobox, and
the selected option is read aloud when it is focused, just like in
a standard select box.

This works by generating semi-random ids that are used for the
ARIA attributes.  These are not intended to be consistent by any
means, they are just generated to make the instance accessible by
screen readers.
2014-10-21 21:44:00 -04:00
Kevin Brown
8dfd6d6960 Add more keyboard support
When the main container is focused, you can now move the highlighted
result by using the up and down arrows on the keyboard.

This does not yet keep the highlighted result visible at all times,
and it only is implemented on single selects, but that will come in
the future.
2014-10-21 21:44:00 -04:00
Kevin Brown
cc9419928e Working on accessibility
This makes quite a few changes, one of the major ones being the
removal of classes for marking options as selected or selectable,
and instead using the ARIA attributes which should already be
present.
2014-10-21 21:44:00 -04:00
Kevin Brown
e601e33ff3 Added a base class for the selection container 2014-10-21 21:44:00 -04:00
Kevin Brown
a07fc21815 Added remove button on multiple select choices 2014-10-21 21:43:59 -04:00
Kevin Brown
3d1dc36711 Added support for placeholders
Placeholder support has been implemented as a separate module, so
any selection container should be able to be decorated and get
instant placeholder support. It hooks into the updating method of
selections, and determines when to display the placeholder based
on the options that are being updated.

It works in the same way as the old placeholders. If no options
are selected and being displayed, like in the case of a multiple
select, then the placeholder will always be shown.  If one option
is being displayed, and the id of the placeholder matches the id
of the selected element, then the placeholder will be shown.  This
is similar to the functionality that was present in Select2 2.x,
where the placeholder could be passed in as an object that would
be compared to the selection.

This still requires that, for single selects, the first element
must match the placeholder id.  Because the default placeholder id
is a blank string, this will maintain backwards compatibility with
past versions where the first option should be blank.  This can
still be overridden to point at a different id, keeping support
for systems where the placeholder doesn't use a blank value.

**Note:** This does not hide the blank option for single selects,
but that will still be maintained for backwards compatibility
within the results module.  It will not depend on a placeholder
being present, but instead will hide any options with blank text.
2014-10-21 21:43:59 -04:00
Kevin Brown
5cf0dbf114 Visibility of the search can be controlled 2014-10-21 21:43:59 -04:00
Kevin Brown
5b98f690c1 Fixed examples page 2014-10-21 21:43:59 -04:00
Kevin Brown
1aff36d28f Add internal support for sorting options 2014-10-21 21:43:59 -04:00
Kevin Brown
4f8fb28d93 Add backwards compatibility with the old matcher
This adds a module for the old matcher, so users can decorate a
data adapter with the module to get the old matcher functionality.

The third parameter to the old matcher, the full element, will
always be the full object now. This does not match the old
functionality, where the third parameter for a `<select>` element
would be the `<option>` element.
2014-10-21 21:43:59 -04:00
Kevin Brown
6d5b0a6c59 Add getters and setters for options
This also gets an object set up that handles the default options.
2014-10-21 21:43:59 -04:00
Kevin Brown
d0fe07f954 Added tests for the query function 2014-10-21 21:43:59 -04:00
Kevin Brown
6375e2ee09 Working on searching results 2014-10-21 21:43:59 -04:00
Kevin Brown
fa3495de24 Drop the playground 2014-10-21 21:43:59 -04:00
Kevin Brown
845f245e1c Fixed sizing of the new select element 2014-10-21 21:43:59 -04:00
Kevin Brown
27ac50a854 Fixed problems with non-string ids
We have to enforce ids being strings as the values of options within
a select will always be an id.  This fixes an issue that we had with
array selections not being highlighted in the results.
2014-10-21 21:43:59 -04:00
Kevin Brown
ac7e7dae24 Added example for disabled results 2014-10-21 21:43:59 -04:00
Kevin Brown
acd469c658 Added optgroup support 2014-10-21 21:43:58 -04:00
Kevin Brown
fd5603be11 Examples use groups now 2014-10-21 21:43:58 -04:00
Kevin Brown
c51a6d6cee Examples are good for now 2014-10-21 21:43:58 -04:00
Kevin Brown
d386849c1f Started building out the examples
This also adds the `select2` function back to jQuery, so you can
still initialize Select2 using the old syntax.
2014-10-21 21:43:58 -04:00
Kevin Brown
4ae3439dbc Started building the docs site 2014-10-21 21:43:58 -04:00
Kevin Brown
c74aeeb5c8 Start working on docs 2014-10-21 21:43:58 -04:00
Kevin Brown
e48d8c2218 Minify dist again 2014-10-21 21:43:58 -04:00
Kevin Brown
9c6a18700b Improved the jshint config a bit more 2014-10-21 21:43:58 -04:00