1
0
mirror of synced 2024-11-23 05:26:10 +03:00
Commit Graph

308 Commits

Author SHA1 Message Date
Stretch
698fe7b9e1 Focus is lost when the change event is triggered
This closes https://github.com/select2/select2/issues/3332.
2015-06-21 21:40:50 -04:00
Ryan Dale
d2346cc331 Change ALT + UP to close the dropdown instead of opening it
This closes https://github.com/select2/select2/issues/3471.
2015-06-21 20:47:05 -04:00
Kevin Brown
79cdcc0956 Fix focus wars in multiple selects
In the previous commit (02cca7b) support was added for multiple
selects to automatically focus when they were tabbed into. While
this did actually work, it caused a few bugs with the focus that
prevented users from tabbing out of the container, effectively
trapping keyboard users in Select2.

This makes a few major changes to how things work in Select2, but
should not break any backwards compatibility.

 - The internal `focus` event is now proxied through a `focus`
   method on the core object. This allows for two important things

   1. The `focus` event will only be triggered if Select2 was in an
      unfocused state.
   2. Select2 now (unofficially) supports the `select2('focus')`
      method again.

   But that does mean that it is possible to trigger the `focus`
   event now and not have it propagate throughout the widget. As
   it would previously trigger multiple times, even when Select2
   had not actually lost focus, this is considered a fix to a bug
   instead of a breaking change.

 - The internal `blur` event in selections is only triggered when
   the focus is moved off of all elements within the selection. This
   allows for better tracking of where the focus is within Select2,
   but as a result of the asynchronous approach it does mean that the
   `blur` event is not necessarily synchronous and may be more
   difficult to trace.

 - On multiple selects, the standard selection container is never
   visually focused. Instead, the focus is always shifted over to
   the search box when it is requested. The tab index of the selection
   container is also always copied to the search box, so the search
   will always be in the tab order instead of the selection container.

It's important to note that these changes to the tab order and how
the focus is shifted do not apply to multiple selects that do not
have a search box. Those changes also do not apply to single select
boxes, which will still have the same focus and tabbing behaviours
as they previously did.
2015-06-21 20:07:35 -04:00
Ryan Wallace
02cca7baa7 Allow immediate typing when tabbing to multiple select. 2015-06-21 14:16:31 -04:00
Itai Nathaniel
4811ff2c59 Fixed direction bug in RTL mode of the text input 2015-06-19 18:09:25 +03:00
Quentin Pradet
5efdc35aeb Replace tabs with spaces for consistency 2015-06-18 10:19:56 +02:00
Seigo ISHINO
2dcc9ef18b Add Japanese translation 2015-06-15 14:30:08 +09:00
Kevin Brown
d7e137f8a8 Merge pull request #3464 from molily/issues/3446
ContainerCss: Remove magic `:all:` correctly. Fixes #3446.
2015-06-11 09:44:22 -04:00
Mathias Schaefer (molily)
d130bd4fa7 DropdownCSS: Remove magic :all: correctly. 2015-06-11 12:09:02 +02:00
Kevin Brown
04a4e41504 Merge pull request #3324 from stretch4x4/MultiSelectStyling
Adding container support issue #3222
2015-06-10 20:09:28 -04:00
Mathias Schaefer (molily)
62b2391972 ContainerCss: Remove magic :all: correctly. Fixes #3446. 2015-06-10 23:15:43 +02:00
Stretch
e60ab22a85 Adding single select support and testing 2015-06-10 20:05:07 +10:00
Jason
da5a72c3ac Fixed AjaxAdapter's super constructor call
Replaced ArrayAdapter super constructor call with correct AjaxAdapter super constructor call. This will allow users to initialize an Ajax select with data.
2015-05-19 16:10:16 -07:00
Stretch
13cead0bd0 Adding container support #3222
Fixes issue #3222
Now templateSelection can have access to the parent container so that
classes can be added for styling
2015-05-07 21:59:51 +10:00
Kevin Brown
ac1680d81d Merge pull request #3290 from Sopamo/master
Improving Foundation Zurb compatibility
2015-05-03 10:45:29 -04:00
Florian Kissling
73fb9a1367 Fix indention to match Select2's (and Bootstrap Sass') style. 2015-05-02 22:40:44 +02:00
Florian Kissling
a9beac83c3 Update Sass vertical gradient mixin to latest version from Bootstrap.
As described in https://github.com/select2/select2/issues/3304#issuecomment-98395238, this updates the mixin to the latest stable version from Bootstrap Sass which adds Sass' http://sass-lang.com/documentation/Sass/Script/Functions.html#ie_hex_str-instance_method to ensure that colors are converted "into the format understood by IE filters".
2015-05-02 22:38:18 +02:00
Florian Kissling
31830c7b32 Add !important to .select2-hidden-accessible.
`.select2-hidden-accessible` is the CSS class that is added to the original `<select>` element (that Select2 is initialized on) to hide it.
In cases where the original `<select>` has other style declarations assigned which conflict with those of `.select2-hidden-accessible`, the latter styles may be overridden, possibly resulting in the original `<select>` element not being properly hidden.

Similar to what https://github.com/select2/select2/pull/1549 did for Select2 v3's CSS, this adds the `!important` rule to all style declarations for `.select2-hidden-accessible` to make it exponentially harder to override them.
2015-04-30 19:09:18 +02:00
Aitor García Rey
42075c6233 Swap inputTooLong and inputTooShort error messages
"Engada"  in galician is "to add" and therefore should be the base text used for the inputTooShort method, asking the use to add more chars. It seems to be mistakenly defined exactly the opposite it should be (as inputTooLong was containing the right text).
2015-04-27 17:20:03 +00:00
Paul Mohr
d4b1247640 Improved Zurb Foundation compatibility
The input fields have a slight box shadow which we want to remove here.
2015-04-27 16:40:41 +02:00
Paul Mohr
6a551dfe74 Improved Zurb Foundation compatibility
The input fields have a slight box shadow which we want to remove here.
2015-04-27 16:38:43 +02:00
nath
e416e47356 Added back dropdownAutoWidth option
This adds back the `dropdownAutoWidth` option, so the dropdown can
have a width that is automatically determined by the browser. This
works best for smaller dropdowns that contain options with large
amounts of text.

This closes https://github.com/select2/select2/issues/3103.
This closes https://github.com/select2/select2/pull/3113.

Signed-off-by: Kevin Brown <kevin@kevin-brown.com>
2015-04-26 16:55:22 -04:00
Andrew Ognistyi
d6886fe6dd added translation for errorLoading 2015-04-22 19:32:45 +03:00
Kevin Brown
f3f1b31958 Add back *css* options through an adapter
The old functionality where classes were directly copied to the
container can be done by setting `dropdownCssClass: ':all:'` when
initializing Select2.

This closes https://github.com/select2/select2/issues/2879.
2015-04-05 21:58:02 -04:00
Kevin Brown
4fc874a3ae Improve jQuery performance issues
This improves a regression added in b9b55cec44
that reduced performance for large number of options when using a
jQuery collection object to append multiple options instead of
using a bare array containing the jQuery elements.

As `$.fn.add` is only required for jQuery 1.7.x, we can use a
utility function that only falls back to it for that specific
version of jQuery, and uses `$.fn.append` with an array for all
other versions.

This closes https://github.com/select2/select2/issues/3230.
2015-04-05 20:08:33 -04:00
penihel
c24293f2ba Render native select out of screen
This closes https://github.com/select2/select2/issues/3065.

Signed-off-by: Kevin Brown <kevin@kevinbrown.in>
2015-04-02 12:01:32 -04:00
Kevin Brown
a993ed9ca9 Warn when Select2 is called without being initalized
Since Select2 methods should not be called on an element where
Select2 has not yet been initialized, this raises an error when it
happens.  This does not silence the original error, but it does
provide the user with some more context about why they are seeing
a TypeError.

This closes https://github.com/select2/select2/issues/3173.
2015-04-02 11:41:18 -04:00
Kevin Brown
e7498987a5 Fix abort with JSONP
We now check that the `abort` method actually exists before aborting
the request, as JSONP does not include the `abort` method because
a JSONP request technically cannot be aborted.

This closes https://github.com/select2/select2/issues/3217.
2015-04-02 11:26:23 -04:00
Kevin Brown
a8e6cbc0c9 Add back keyboard support within allowClear
This adds back keyboard support, so you can now clear a selected
item using either the backspace or delete key.  This only work when
the container is closed, to prevent issues with the selection being
clear while a user is searching.

This was a regression in accessibility from 3.x.

This closes https://github.com/select2/select2/issues/3224.
2015-04-02 11:21:10 -04:00
Kevin Brown
00a78bdb1e Allow for a partial dictionary in language
This closes https://github.com/select2/select2/issues/3202.
2015-04-02 10:52:31 -04:00
Kevin Brown
01160f29d8 Allow chaining of .select2()
`.select2("open")`, `.select2("close")`, and `.select2("destroy")`
can now be safely chained.

This closes https://github.com/select2/select2/issues/3221.
2015-04-02 10:34:30 -04:00
jongwoo Yoo
da1ec4e028 fix error: "Uncaught ReferenceError: require is not defined"
Signed-off-by: Kevin Brown <kevin@kevinbrown.in>
2015-04-02 10:29:22 -04:00
Brankub
010cf29902 switched back to this instead of self 2015-03-25 10:07:55 +02:00
Brankub
2b9c8b00a7 remove evt 2015-03-24 15:14:32 +02:00
Brankub
e10f3b7dae fixes #3169 2015-03-24 14:44:23 +02:00
Kevin Brown
54154c3df6 Selected property of the element, not object
Slight revision to the changes made in
9d359c9b38.
2015-03-18 11:55:47 -04:00
Kevin Brown
0c573df402 Prevent IE from going back on backspace
This closes https://github.com/select2/select2/issues/3168.
2015-03-18 11:53:40 -04:00
Kevin Brown
14279a012b Handle special characters in object ids
Slight performance hit as we are no longer using `qurySelectorAll`,
but it handles the situation a bit more cleanly and prevent future
issues with special characters.

This closes https://github.com/select2/select2/issues/3157.
2015-03-18 10:56:10 -04:00
Kevin Brown
1f62eb67e8 Fix TypeError
This closes https://github.com/select2/select2/issues/3160.
2015-03-18 10:48:47 -04:00
Kevin Brown
9d359c9b38 Update the selected property on objects
This fixes the results display so they prefer the `selected`
property on objects over checking if the `id` matches the value of
the underlying select.

We only ignore the `selected` property if it is null, at that point
we compare against the `id` property.

This closes https://github.com/select2/select2/issues/3163.
2015-03-18 10:41:04 -04:00
Kevin Brown
a6999990b0 Fixed Hebrew translation
This should have been in he.js in the first place.
2015-03-18 09:44:04 -04:00
yonihbc
faed59cd42 he.js 2015-03-18 13:39:36 +02:00
Kevin Brown
a06379ce8d Normalize ids to string for remote data
This also fixes an issue where we were using the `full_name` for
the value instead of the `id` in the example, which technically
wasn't correct.

This closes https://github.com/select2/select2/issues/3148.
2015-03-14 20:36:06 -04:00
Kevin Brown
5a25c33fc5 Don't do a null check for tags
This closes https://github.com/select2/select2/issues/3155.
2015-03-14 20:11:38 -04:00
Kevin Brown
fc43f00b59 Only use aria-owns when the dropdown is open
This fixes part of https://github.com/select2/select2/issues/3144.
2015-03-14 19:39:28 -04:00
Kevin Brown
7e4e8bc9d6 Relative paths for require
Now we can use relative paths in the calls to `require`, so those
using relative builds don't have to worry about modules not being
imported properly. This also makes it considerably easier in the
future when we look to cut down the build sizes and have a custom
builder, as we don't have to worry as much about the paths being
incorrect.

This fixes https://github.com/select2/select2/issues/3014 finally.
2015-03-14 19:22:34 -04:00
Kevin Brown
d1e8a6fdad Overhaul of the AMD integration
Now we do not have separate AMD builds, instead we use a UMD wrapper
to support both AMD and CommonJS environments along with the browser.
This has been tested with RequireJS and it correctly imports Select2
and hooks into jQuery.

This means that all builds will include the Almond AMD loader, but
this isn't that much of an issue when you consider the file sizes.
The loader is namespaced so RequireJS and other AMD builders don't
complain about `require` and `define` existing. This is also done
so AMD loaders don't conflict, as Select2's AMD loader should
operate independently of others.

There are now two layers of wrappers that are applied to files,
only one of which is used for the translation files. This allows
us to only load in the internal Select2 modules once, and in
general makes most things cleaner. These have also been pulled out
into individual JS files instead of being stored in JSON files,
allowing us to add comments and make things look readable.

Because we use a few hacks, these files are heavily commented as well.

This closes https://github.com/select2/select2/issues/2945.
This closes https://github.com/select2/select2/issues/2946.
2015-03-14 19:05:24 -04:00
Kevin Brown
e8fd5a0352 Fix select2('data') again
This finally fixes and adds some integration tests to make sure
that `select2('data')` works as we are expecting. This also adds
tests for `select2('val')` and fixes undefined variable issues
that were spotted because of these tests.

We also no longer date stamp distribution builds.

This closes https://github.com/select2/select2/issues/3104.
2015-03-14 15:23:29 -04:00
Quentin Caron
a3e8cd8f9b Updated 15 of the translation files so 'maximumSelected' is used instead of 'maximumSelection' 2015-03-12 22:11:36 +01:00
Kevin Brown
e3d7cd2d69 Fixed allowClear on fixed width
This moves the clear icon to the top of the DOM from the bottom to
ensure that it is always visible on top of the selection.

This closes https://github.com/select2/select2/issues/3089.
2015-03-11 21:28:06 -04:00