Now the search box is automatically resized for placeholders to
fit the available space, so we don't need to worry about the
placeholder not being visible. When the placeholder doesn't need
to be visible, the size of the search box is determined based on
the length of the current search term.
This adds a search box to the main container for multiple select
boxes, similar to the what the old version had. This can still be
swapped out such that the search box displays above the results
like it previously did.
The placeholder for multiple selects will also now use the input
attribute of the search box instead of generating a custom element.
This also changes the selector for the search container to
`.select2-search`, which is consistent with the old class and
reduces the complexity of the selectors.
This fixes an issue with how decorators worked, where the constructor
from the parent class would clobber the custom constructor that is
generated for the new decorated class. This has been fixed by
excluding the constructor from the list of fields which are
transferred when decorating classes.
This adds a dictionary for converting diacritics to a normalized
representation. This dictionary is used in the default matcher.
The code for stripping the diacritics was pulled from the current
implementation in Select2 3.x.
This migrates over the required English translations under their
new names.
The "Searching" message has also been adjusted to use "Searching..."
instead of "Loading more results...", which is what it used to
say sometimes.
This also changes the AJAX handler to call `abort` when needed.
Now when searching, a loading message is prepended to the top of
the results. This replaces the old spinner image and allows for it
to be translated across different languages.
The loading message can be styled differently and is passed
through the results formatters.
Previously, a result was no longer highlighted when the mouse was
no longer over it. While this was useful for resetting the
highlight automatically, we started doing this when a new result
was highlighted to make sure that we never had multiple options
highlighted.
Now, a result will always be highlighted until the highlight is
removed when the next result is highlighted. While this shouldn't
affect many users, it is closer to how native select boxes work.
This also allows users using keyboard navigation to jump between
mouse and keyboard navigation without the highlight reseting to
the top of the results.
This fixes many of the speed issues the results had when working
with large data sets. jQuery has been completely dropped, with the
exception of setting the data, which does not require a jQuery
object but instead works directly with the DOM. This does not
include options with children, which still uses jQuery to deal
with the nested objects.
This only works with IE 8+, which is fine.
This fixes caching when querying, so the data object no longer
needs to be completely regenerated whenever the `<option>` is
queried.
While this does not fix the speed issues on the first opening of
the instance, it does fix the speed issues during searching.
This improves the speeds of creating the `<option>` tags for array
data. By creating the HTML ahead of time and putting it into an
`<option>` element before passing it to jQuery, it cuts down on the
time it takes for jQuery to process the HTML string and convert it
into DOM elements. This proved to be incredibly slow.
This also changes the `item` function to return early when the
data exists. The `$e.data` call has also been switched to a
`$.data` call, which doesn't need to check the DOM to see if the
data attributes already exist. This cuts down on a bit of wasted
time, as the `data` key should never be present in the DOM, and it
should be ignored if it is.
Now the options are mostly generated by hand before being passed
off to jQuery for templating. This fixes much of the speed issues
we had when they were entirely being generated through jQuery.
This converts individual objects passed in through the `array`
parameter to `<option>` tags when Select2 is initialized. This
removes a lot of duplicate code from the `ArrayAdapter`, and keeps
everything closer to the native `<select>` element.
This introduces a breaking change from previous versions of Select2,
where the initial value for array data was blank, even if a blank
option was not present in the original array of objects. Now the
first object passed in will be selected by default, following the
behavior of a standard `<select>` element.
This breaking change does not affect `<select multiple="multiple">`
elements, which by default have no selection.
The matcher example now matches the old matcher example, and the
compatibility module has been turned into a function decorator
instead of a class decorator.
Only show the "No results found" message when there are no results
visible in the list. This avoid issues when loading more data, and
it returns no results.
Only try to see if the load more button is visible if it is present
in the DOM. This prevents making continuous requests when there are
no more results.
This starts work on the example, which currently uses the GitHub
API.
The `ajax.delay` option has been added that allows for debouncing
requests made within a certain number of milliseconds.
This allows for any control to emit key events, and for the Select2
instance to handle them. So now the search box will allow for
results to be scrolled and selected, bringing back the old expected
functionality. This also stops triggering new queries when the
arrow keys are pressed.
The container will also be automatically focused when the dropdown
is closed, which is consistent with the old Select2.
The results will no longer be queried on initialization, but
instead will be queried when the dropdown is opened. This is more
consistent with the previous version of Select2.
The search box will now be cleared when the dropdown is closed.
The placeholder will not only be automatically hidden if the
results adapter was not already overridden. This will allow users
to override the results adapter to now hide the placeholder, if
they do not want that functionality.
This allows them to be overridden, allowing for things like
attaching the dropdown to a different part of the DOM.
The id is also now generated in a function that can be overridden.
Now we point users to the `LICENSE.md` file for the license,
instead of including it in the README. This also removes the
example integrations, which are no longer officially maintained
by Select2.
The translation section has also been updated.
This was only done to maintain compatibility with labels, back
when we could capture the focus events from the original element.
Now that we handle them in a different way, this is no longer
needed.
This fixes#2769.