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

1726 Commits

Author SHA1 Message Date
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
Kevin Brown
cbfe23eb52 Added basic tests for select2/data/array 2014-10-21 21:43:58 -04:00
Kevin Brown
5f176b66f2 Add tests for select data adapter 2014-10-21 21:43:58 -04:00
Kevin Brown
26986cacb6 Fix undefined variable, rebuild dist 2014-10-21 21:43:58 -04:00
Kevin Brown
f0b819336a Linted select2/data/* and select2/dropdown/* 2014-10-21 21:43:58 -04:00
Kevin Brown
981432ee89 More linting on select2/* 2014-10-21 21:43:58 -04:00
Kevin Brown
f0e3968989 Linted select2/selection/* 2014-10-21 21:43:58 -04:00
Kevin Brown
898db2e74a Linted select2/utils
For the most part this was semicolon fixes, but there was a
function, `calledMethod`, which did need to be moved out of the
loop.
2014-10-21 21:43:58 -04:00
Kevin Brown
ed6eb4ff92 Dropped old js files 2014-10-21 21:43:57 -04:00
Kevin Brown
0bc56a922b Linted tests 2014-10-21 21:43:57 -04:00
Kevin Brown
aebc7ce0d2 Added very basic jshint config 2014-10-21 21:43:57 -04:00
Kevin Brown
114732ec25 Broke out a base data adapter
This should allow us to create a basic interface that all adapters
must follow.
2014-10-21 21:43:57 -04:00
Kevin Brown
08ac13d510 Two spaces indentation for tests 2014-10-21 21:43:57 -04:00
Kevin Brown
5a17226ba6 Minify assets 2014-10-21 21:43:57 -04:00
Kevin Brown
0f30667f01 Added very basic AJAX adapter 2014-10-21 21:43:57 -04:00
Kevin Brown
cbc2d2f3ec Trigger events when the dropdown opens and closes 2014-10-21 21:43:57 -04:00
Kevin Brown
315b1b3c12 Added array adapter
This should add support for dynamically generated array data that
still works with a basic `<select>` element.
2014-10-21 21:43:57 -04:00
Kevin Brown
3e05e32eda Small changes in preparation for more adapters 2014-10-21 21:43:57 -04:00
Kevin Brown
d57f8b2203 Clicking on a selected option triggers an unselect event 2014-10-21 21:43:57 -04:00
Kevin Brown
94b460f930 Limit the explicit coupling between adapters 2014-10-21 21:43:57 -04:00
Kevin Brown
0081716841 Header and footer decorators
Added examples of header and footer decorators.
2014-10-21 21:43:57 -04:00
Kevin Brown
f82202036f Added example
People have asked about getting the multiple selection container
to show for a single selection.  This is a basic example that shows
that it could easily be done now.
2014-10-21 21:43:57 -04:00
Kevin Brown
14d3d99868 Basic multiple select implementation 2014-10-21 21:43:57 -04:00
Kevin Brown
1197960a4e Add proof-of-concept decorator for clearing 2014-10-21 21:43:57 -04:00