1
0
mirror of synced 2024-11-22 13:06:08 +03:00
Commit Graph

1803 Commits

Author SHA1 Message Date
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
878de20d44 Fix typo in documentation
This closes https://github.com/select2/select2/issues/3213.
2015-04-02 11:29:44 -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
Kevin Brown
cc1eefb78f Merge pull request #3188 from Brankub/master
Fixes #3169 issue with selectOnClose errors
2015-03-25 10:31:48 -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
9318980651 Merge pull request #3178 from tylerpearson/master
Fix misspelling
2015-03-20 09:16:35 -04:00
Tyler Pearson
c0dadf44a1 Fix misspelling 2015-03-19 20:58:57 -07: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
Kevin Brown
607fdf4b4c Merge pull request #3170 from yonihbc/patch-1
he.js
2015-03-18 09:15:31 -04:00
yonihbc
faed59cd42 he.js 2015-03-18 13:39:36 +02:00
Kevin Brown
69e2d73c42 Bump version numbers for rc.2 2015-03-14 20:51:32 -04: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
e5d97e0de0 Fixed the emphasis in the release announcement 2015-03-14 20:06:26 -04:00
Kevin Brown
d146313256 More about initSelection
In the past, `initSelection` was used for loading in data objects
for the pre-selected options. Now that Select2 is using a `<select>`
element, there is no need for doing this because the `<option>`
elements should provide the relevant information. So you can now
just pull this information from the remote data source
(or static array, in some cases) and build out the `<option>`
elements manually.

In most cases you don't need to go the full length with a custom
data adapter, but instead are just looking to pre-load elements on
the initial page load.

This improves https://github.com/select2/select2/issues/3116.
2015-03-14 19:58:50 -04:00
Kevin Brown
aa8978e551 Rip out the old AMD docs 2015-03-14 19:49:47 -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
Kevin Brown
7a1791d5f3 Merge pull request #3147 from justanotheranonymoususer/patch-1
Fixed a link in README.md
2015-03-13 10:35:33 -04:00
Kevin Brown
7d19b97aa0 Merge pull request #3145 from qcaron/master
Updated 15 of the translation files so 'maximumSelected' is used instead of 'maximumSelection'
2015-03-13 10:33:50 -04:00
justanotheranonymoususer
5acd96ee1e Update README.md 2015-03-13 12:35:19 +02: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
Kevin Brown
78c301f4fb Added debug option
Now most of the warning messages will only be displayed if the
`debug` option is set when initializing Select2.

This closes https://github.com/select2/select2/issues/3100.
2015-03-11 20:41:10 -04:00
Kevin Brown
7feb90f256 Modified banner for translations
We don't need to update the dates on these every time that grunt
is called. This gives it a much more basic banner that is similar
to the minified version.
2015-03-11 20:40:08 -04:00
Kevin Brown
6c0dd6684b Add an actual banner to the JS file
This adds an actual banner that contains the version number and a
link to the license to the top of the files.

This closes https://github.com/select2/select2/issues/3118.
2015-03-11 20:26:48 -04:00
Kevin Brown
55d3c636cc Skip the nested data test on unsupposed browsers
The nested data attributes are only supported on jQuery 2.x or
browsers which support the `dataset` attributes on DOM elements.
In order to prevent test failures, and because tests cannot yet
be skipped conditionally, we just cut the test early.
2015-03-11 19:46:48 -04:00
Kevin Brown
992652bbd2 Expand IE testing
Now that our tests are using jQuery 1.7.2 we can run our tests on
IE8 automatically.
2015-03-11 19:26:30 -04:00
Kevin Brown
b9b55cec44 Tests use jQuery 1.7.2
As jQuery 1.7.2 is the lowest version of jQuery supported by Select2,
it makes sense to run the tests on it. For the most part, we can
assume that the newer versions of Select2 are backwards compatible
enough such that this isn't an issue.

The recommended version of jQuery to use is the latest though, which
is why the jQuery file is only included in the tests.

This revealed a few issues with our data fallbacks and `.append`
functionality that was introduced in jQuery 1.8.
2015-03-11 19:20:41 -04:00
Kevin Brown
4fb079b34f Combine tests into a single file
This combines all of the tests into a single HTML file. This reduces
the number of Sauce Labs sessions and should improve test times.
2015-03-11 18:51:55 -04:00
Kevin Brown
30974e2422 Only test Opera 12 once
Looks like Sauce Labs is not going to have tests running on later
versions of Opera, probably because it switched to Chromium/Blink.
Removing it from the builds so we reduce the time it takes.
2015-03-11 18:30:38 -04:00
Kevin Brown
610381be4a Strip whitespace by default for tags
This strips whitespace in tags by default, so multiple tags cannot
be created with only whitespace as the difference in the id.

A test has been added to ensure that this remains fixed in the future.

This closes https://github.com/select2/select2/issues/3076.
2015-03-11 18:23:10 -04:00
Kevin Brown
95be140760 Fixed select2('data')
This fixes an issue with `select2('data')` that caused it to not
work as intended. Because we were using `Select2.data` for the
data adapter, it was overriding the `Select2.data()` method which
was supposed to be used.

This just renames the `Select2.data` property to
`Select2.dataAdapter` to prevent the naming collision.

This closes https://github.com/select2/select2/issues/3104.
2015-03-11 18:16:21 -04:00
Kevin Brown
0da15aa586 Fixed option text encoding
This fixes an issue when using a `<select>` where the elements were
created with XHTML-encoded characters to prevent any injection, as
they would be double-encoded and display incorrectly.

When using a `<select>`, we can assume that the data has already
been encoded because any XSS will have already run before we get to
it.  Because of this, we can just use `.text()` instead of `.html()`
to avoid any issues.

This also includes a test to ensure that this does not become an
issue in the future.

This closes https://github.com/select2/select2/issues/3115.
2015-03-11 18:12:14 -04:00