1
0
mirror of synced 2024-11-22 21:16:10 +03:00
Commit Graph

1744 Commits

Author SHA1 Message Date
Kevin Brown
ce38cd5b9c Allow the dropdown to point up
Up until now, the container could only have a dropdown that was
displayed below the container. While this worked well, there are
some cases where the dropdown should be displayed above the
container. Most notably, this is when the conatainer is displayed
towards the bottom of the page, and displaying the dropdown would
cause the page to be extended. Because we close the dropdown
when the page is scrolled, the user would not be able to access any
options that were displayed outside of the viewpoint.

Because of the order that events are fired, we attach the handlers
for repositioning the dropdown after results are displayed when the
container is opened for the first time.  This allows it to be
registered after the results container registers their events, so
the dropdown is repositioned after the results have been displayed.

The logic for determining the direction that the dropdown will be
shown in is very similar to the positioning code used in
Select2 3.x. Unlike previous versions of Select2, a class is used
to indicate the direction of the dropdown, even if it is displaying
below the container.

The themes provided with Select2 have been updated to correctly
render the dropdown in both directions.
2014-12-05 20:09:42 -05:00
Kevin Brown
fda973c34f Started adding more translations 2014-11-26 23:19:04 -05:00
Kevin Brown
07575f051c Automatically close on scroll
This now matches how the browser works, where the dropdown is
closed when the window scrolls.

The arrow was also covering the clear placeholder icon, this has
now been fixed and the clear icon is now placed correctly.
2014-11-26 22:30:31 -05:00
Kevin Brown
e3647051de Added maximumInputLength support 2014-11-26 21:52:49 -05:00
Kevin Brown
43efd43d57 Add tests for the multiple selection container 2014-11-26 20:50:39 -05:00
Kevin Brown
7fc195f70d Fix hiding search
When the dropdown is in the dropdown that is attached to the body,
the call to `show` causes `display: inline` to be set directly on
the search container. This causes rendering issues, so this change
uses a class instead of calling `show` and `hide` directly.

This is most likely a jQuery bug of some form, as it only happens
when using the dropdown that is attached to the body.
2014-11-26 20:39:52 -05:00
Kevin Brown
4cab421966 Added tests for the single selection container 2014-11-26 20:25:56 -05:00
Kevin Brown
56d5778590 Finished off tests for tags
This also adds back the ability for tags to return `null` in order
for no tag to be added to the results.
2014-11-26 19:53:15 -05:00
Kevin Brown
76e4ea8340 Added tests for tags 2014-11-25 21:28:16 -05:00
Kevin Brown
16e565e28e Added tests for minimumInputLength 2014-11-25 20:12:17 -05:00
Kevin Brown
389c3ed866 More work on the release announcement 2014-11-25 19:42:53 -05:00
Kevin Brown
593a357886 Automatically push docs updates 2014-11-25 16:23:53 -05:00
Kevin Brown
a4af105a6e Fixed the default translations
Previously the default translations would break for custom AMD
builds. This fixes it so it does not rely on a hard-coded import
path.
2014-11-25 16:09:52 -05:00
Kevin Brown
81db43fa99 Extracted the original positioning out
With this change, any instances overriding the dropdown is
required to decorate it with the positioning module.
2014-11-25 15:59:35 -05:00
Kevin Brown
6a0c002f94 Add a module for attaching the dropdown to the body
In Select2 3.x, the dropdown is attached to the body element and
it is floated above all other elements.

In Select2 4.x, the dropdown is attached directly to the Select2
container, which allows us to skip any special placing logic. This
happens to be how Chosen currently does it, and it prevents us
from having the dropdown display up, as well as a few other strange
issues that can't be prevented.

This new module will most likely become the default, as it matches
the functionality of Select2 3.x and has quite a few advantages.
The other positioning code will need to be broken out into a
separate module in the future.
2014-11-25 15:39:42 -05:00
Kevin Brown
31c09315c8 Move positioning into the components
The main container should not need to position the individual
components. This makes it easier for components to override where
they should be placed, such as adding the dropdown outside of the
container.
2014-11-25 14:19:07 -05:00
Kevin Brown
be3414f6fe Moved the body click handlers out
This should allow us to start working on the body mask handler,
and make future implementations easier to work with.
2014-11-25 14:03:21 -05:00
Kevin Brown
85593de1fa Fixed bug when destroying Select2
When destroying Select2, an error could be raised while destroying
the selection container. This was because the destroy handler was
relying on the container id being present.

The old functionality has been restored where Select2 will destroy
itself when it is initialized again.
2014-11-25 13:39:46 -05:00
Kevin Brown
ade7180d70 Updated with master 2014-11-25 08:56:36 -05:00
Kevin Brown
12de3c2b5e Set up the GitHub Pages command
Now we can synchronize GitHub Pages with the docs in the master
branch quickly and easily.
2014-11-25 08:36:01 -05:00
Kevin Brown
d9e254ed27 Fixed the theme example 2014-11-24 21:37:29 -05:00
Kevin Brown
ac5d584f3d Added the arrow for the dropdown 2014-11-24 21:33:22 -05:00
Kevin Brown
ffed37013d Added back the allowClear option 2014-11-24 20:43:15 -05:00
Kevin Brown
dafa99bf40 Working on the classic theme 2014-11-24 20:08:24 -05:00
Kevin Brown
e686bce9d0 Converted classic theme to BEM
This should be the last of the changes.
2014-11-24 19:11:02 -05:00
Kevin Brown
3e54fc97e5 Finish the core switch to BEM
This switches all of the dropdown components to use BEM.
2014-11-24 18:59:19 -05:00
Kevin Brown
8cb074ccef Finished switching main container to BEM 2014-11-24 18:38:58 -05:00
Kevin Brown
7933eb77c1 Switch the multiple selection container
This switches the container to use BEM for the class naming.
2014-11-24 18:30:58 -05:00
Kevin Brown
971422f92e Start the switch to BEM
This is inspired by https://github.com/ivaynberg/select2/issues/2826
and starts the general transition to using selectors with a lower
specificity. This should make it considerably easier to override
the styles in the long run.

Unfortunately libsass does not support the SASS 3.3 style for BEM
where we can just use `&__m` for defining sub-modules. For now we
are still using a limited amount of nesting, but nowhere near as
much as we did in the past.
2014-11-24 18:11:03 -05:00
Kevin Brown
f1c02db189 Automatically resize the search box
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.
2014-11-22 20:32:25 -05:00
Kevin Brown
217cd4cfd0 Added inline searching for multiple selects
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.
2014-11-22 19:21:46 -05:00
Kevin Brown
f382f3d02d Merge pull request #2755 from kupishkis/2753
After clearSearch nextSearchTerm is not cleared
2014-11-21 08:47:35 -05:00
Kevin Brown
9913cb7c25 Merge pull request #2730 from od3n/master
updated Malay & Indonesian translations
2014-11-20 21:46:38 -05:00
Kevin Brown
2bec6e2579 Automatically strip diacritics
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.
2014-11-19 18:12:59 -05:00
Kevin Brown
5ec201ca30 Built out the translations
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.
2014-11-19 17:48:46 -05:00
Kevin Brown
7e6782d580 Display a loading message when searching
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.
2014-11-19 17:22:37 -05:00
Kevin Brown
28c56e7885 Better accessibility for multiple select boxes 2014-11-19 15:50:53 -05:00
Kevin Brown
cee8c18c23 Change how the results are highlighted
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.
2014-11-19 14:29:28 -05:00
Kevin Brown
849a9c7a32 Started work on the classic theme
Some people like the old theme, so we're going to also include that
one as well as the easier-to-extend flat theme.
2014-11-19 14:26:52 -05:00
Kevin Brown
69e8e6e355 Merge pull request #2808 from yuks/patch-1
formatMatches translation added
2014-11-14 17:38:28 -05:00
Yuksel
ced4bf692c formatMatches translation added 2014-11-14 22:17:49 +01:00
Kevin Brown
a2766b7ed6 Added destroy method
Now Select2 supports destroying itself, and all elements that it
creates.
2014-11-13 18:36:40 -05:00
Kevin Brown
a8377e3681 Merge pull request #2789 from RustyToms/drop_above_dropHeight_fix
recalculate $dropdown height after drop-above class added
2014-11-13 17:56:14 -05:00
Kevin Brown
78ee1bc01e Continued work on the documentation 2014-11-08 16:48:57 -05:00
Kevin Brown
10536370de Add support for initializing tags
This adds backwards compatibility for the old tags.
2014-11-07 20:31:27 -05:00
Kevin Brown
d306fcf82c Added default selection for AJAX 2014-11-07 20:20:37 -05:00
Kevin Brown
5535f072e1 Focus the search upon opening 2014-11-07 20:16:59 -05:00
Kevin Brown
07e82d6be8 Automatically create options on select 2014-11-07 20:13:59 -05:00
Kevin Brown
d411a0fa76 Fixed default selections for arrays 2014-11-07 19:53:50 -05:00
Kevin Brown
e3deb3ae03 Remove jQuery from building the options
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.
2014-11-07 19:37:07 -05:00