1
0
mirror of synced 2024-11-25 22:36:03 +03:00
Commit Graph

1761 Commits

Author SHA1 Message Date
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
Kevin Brown
b917754e55 Merge pull request #3122 from cristi-badila/master
Fixes issues with inputData module. When unselecting an item it would previously unselect all items
2015-03-10 13:21:09 -04:00
Cristi Badila
24f3c4777d Fixes issues with inputData module. When unselecting an item it would previously unselect all items 2015-03-10 19:16:17 +02:00
Kevin Brown
fff04c3f0c Merge pull request #3099 from yoonsy/master
added Korean translation.
2015-03-06 20:01:09 -05:00
Kevin Brown
2df4f5385c Merge pull request #3117 from krautcomputing/fix_typo
fix typos (lanugage -> language)
2015-03-06 20:00:40 -05:00
Kevin Brown
9006e88047 Merge pull request #3111 from ahmadazimi/master
Add Farsi (Persian) language support.
2015-03-06 19:57:57 -05:00
Manuel Meurer
43480954a4 fix typos (lanugage -> language) 2015-03-06 22:18:09 +01:00
Ahmad Azimi
36431d5718 move ignores to user-level .gitignore file 2015-03-05 23:59:32 +03:30
Ahmad Azimi
be9168bc5a Remove unneeded 's' for plural forms 2015-03-05 22:05:15 +03:30
Ahmad Azimi
a6b5b40eb5 Add Farsi (Persian) language support.
Editor config folder and .DS_Stroe files added to .gitignore
2015-03-05 21:56:12 +03:30
yoonsy
45c815da50 remove unneeded 's' for plural and fix comment. 2015-03-03 22:32:22 +09:00
yoonsy
c1bc88eccd added Korean translation. 2015-03-03 22:20:22 +09:00
Kevin Brown
d3c887286d Update CDN version numbers 2015-03-01 22:09:37 -05:00
Kevin Brown
9d6752e3ea Bumping version numbers for rc.1 release 2015-03-01 21:30:37 -05:00
Kevin Brown
94875679f8 Automatically open search when typing
This fixes an issue where the dropdown would not automatically
open when something was typed in the search box on a multiple
select.  This was most noticeable when the dropdown closed and
the search box was focused and the user started to type, as the
text would appear in the search box, queries would be sent out to
retrieve results, but the dropdown would not be opened to display
the results.

This also fixes an issue introduced in a recent commit where search
queries would be sent out twice on modern browsers that supported
both the `keyup` and `input` event.  The `keyup` event is now
properly debounced for these browsers and the queries are only
going out once.

This closes https://github.com/select2/select2/issues/3036.
2015-03-01 21:01:11 -05:00
Kevin Brown
017c201094 More intuitive handling of the enter key
Previously, when in results the enter key would select items that
were highlighted if they were not already selected.  In the case of
a select where multiple items could be selected, pressing enter
when highlighting a selected item would also allow it to be
unselected.  While this seems intuitive for accessibility purposes,
the enter button essentially working as a toggle, it caused some
really strange behavior.

- If the enter button was held down, all previously selected items
  would be unselected.
- The enter button did not work the same across both single and
  multiple selects.

After listening to user feedback, I have decided to remove the
"enter as toggle" functionality from Select2 and have gone back to
just having the enter button select items.  This means that instead
of unselected items that are already selected and highlighted,
Select2 will just close the dropdown.  This is the same as what
Select2 would previously do for single selects, so the keyboard
functionality is now the same across both.

Because this removed the only easy way to unselect items in the
dropdown using the keyboard, we had to maintain the toggle
functionality.  We decided to implement the toggle functionality
on the CTRL + Space keybinding, which is in line with other
applications.  Now when pressing CTRL + Space at the same time in
the dropdown, the highlighted result will behave the same as if the
mouse selected it, which will toggle the current item in multiple
select mode and close the dropdown in single select mode.

This is the same keybinding that Windows Explorer [1] and GTK [2]
use for toggling the current selection, which was why it was picked.

This also fixes an issue where keyboard focus would be lost once an
item was unselected from the results.  This was due to a bug in the
CloseOnSelect module that would only automatically close the
dropdown when an item was selected, but not when an item was
unselected.  Now the dropdown will be closed automatically when an
item is unselected, which will also cause the selection (and
eventually the search) to be focused.

This fixes two issues described in
https://github.com/select2/select2/issues/3036#issuecomment-76321411.

[1]: http://superuser.com/q/78891/72528
[2]: https://developer.gnome.org/gtk3/stable/GtkIconView.html#GtkIconView-toggle-cursor-item
2015-03-01 20:30:43 -05:00
Kevin Brown
c0839b4f93 Fix searching in Firefox for Android
This fixes an issue where most keys would not trigger the search
in Firefox for Android.  There were only a few keys which would
trigger `keyup`, such as space and enter (the search icon), but
they were not consistent.  We know that they were being triggered
though, as you could type "new " (note the space) and it would
trigger a search, giving us all states that started with "new".

The problem is that Firefox for Android does not consistently
trigger `keyup` and `keydown` events when a keyboard is used.  To
work around the issue, we are now using the `input` event in
replacement of the `keyup` event, which was used to trigger the
search.  While this is not an actual `KeyboardEvent` in Chrome, and
lacks some of the important metadata such as `which`/`key` in
Firefox, it works for our implementation.

As the `input` event is not supported in older browsers, such as
those before Internet Explorer 9, we have to listen for both the
old `keyup` event and the new `input` event.  As the `input` event
is always triggered before the `keyup` event, we unbind the `keyup`
event automatically to prevent searches from being triggered twice.
This solution was discovered in a blog post by Mathias Bynens at
https://mathiasbynens.be/notes/oninput.

**Note:** The ability to backspace in a blank text field on multiple
selects in order to remove the last selected item does not work in
Firefox for Android because the `keydown` event does not trigger
when the text field is empty.  Users can still use the "x" icon
provided at the start of every selected option to achieve the same
effect.

This closes https://github.com/select2/select2/issues/2997.
2015-03-01 19:41:27 -05:00
Kevin Brown
61916b2cfb Build latest commits 2015-03-01 19:03:30 -05:00
Kevin Brown
4eaa8c5488 Merge pull request #3074 from loic/title_when_multiple
Fixed the title attribute for choices on "multiple" widgets.
2015-02-27 20:41:04 -05:00
Kevin Brown
5c9dc0e509 Added example for hiding search
This also fixes a possible issue where the `< 0` fallback would
not be used because the `minimumResultsForSearch` check would
always return false and never load in the module.

This closes https://github.com/select2/select2/pull/3077.
2015-02-27 20:37:48 -05:00
Kevin Brown
55f995ea21 Fixed data-ajax-url fallback
This fixes the fallback path for the `data-ajax-url` attribute on
elements.  As this attribute was previously supported in Select2,
the attribute has been migrated to the new, nested format of the
url and triggers a deprecation warning when it is used.  Because
of a fix to the `data-*` attribute parsing made in a9f6d64 that
allowed for nested attributes to be parsed correctly in modern
browsers under jQuery 1.x, the deprecation warning would be
triggered but the attribute would no longer actually be used.

This also fixes some of the `.data` calls to use the camel cased
version of the key instead of the dashed version, which is the
preferred key and will be enforced in future versions of jQuery
as the only way to access data attributes.

Now in situations where the `dataset` attribute is used by Select2,
it combines the results of both `$e.data()` and `e.dataset` when
generating the object containing all of the options.  This will
the `dataset` fix to still be used, while also still relying on
jQuery to do additional parsing on any options that it can.

The `dataset` fix is now only used on jQuery 1.x, as that is the
only version of jQuery affected by the dash issue.  This is done
using version number parsing on the `$.fn.jquery` property that is
defined by jQuery.  As this property is not defined in Zepto and
many other jQuery compatible checks, we only include the fallback
if the property is available.  This assumes that any jQuery
compatible libraries that are in use will not include the same dash
issue, which we believe is a safe assumption given that it did not
match the HTML `dataset` specification.

This also adds a few tests to ensure that the deprecated attributes
still continue to function.

This closes https://github.com/select2/select2/issues/3086.
2015-02-27 20:11:13 -05:00
Kevin Brown
3630385cf7 Merge pull request #3051 from select2/issue_3022
Added compatibility with `<input type="text" />` tags
2015-02-27 18:47:13 -05:00
Kevin Brown
5ec852e18c Added documentation for <input type="text" />
This adds basic documentation explaining that there are compatibility
decorators for `<input type="text" />` support. This is not fully
compatible with all features and requires the use of an external
adapter like the `ArrayAdapter` or `AjaxAdapter` to provide a
reasonable way to query results.

This also triggers a warning if the adapter is used with a hidden
input, as the degraded functionality when there is no JavaScript
support should be discouraged.
2015-02-27 18:38:16 -05:00
Kevin Brown
e9bfa72966 Added tests for the <input /> element 2015-02-27 18:37:06 -05:00
Kevin Brown
956ac46dab Added compatibility with <input /> tags
This adds backwards compatibility back into Select2 for `<input />`
tags.  The compatibility modules are only available in the full
version and will trigger a warning if a hidden input is being used.

With the new decorator, Select2 should support the basic operations
that it previously did, with the exception of completely overriding
the internal objects. As we no longer expose `data` as a writable
method, it is no longer possible to completely override the selected
data. The state is still managed internally, but in order to prevent
data corruption issues in the past, it is not exposed to the public.

Some small changes needed to be made to how Select2 was dynamically
generating new `<option>` tags, so now a method is called that can
be overridden. In the case of the new decorator, this method is
intercepted and handled without having to actually place the
`<option>` tags into the DOM.

The decorator is applied after all of the other defaults, as the
defaults are not given the current element.

There has only been limited testing with this decorator, primarily
using the `data` and `placeholder` options.

This closes https://github.com/select2/select2/issues/3022.
2015-02-27 18:36:34 -05:00
Loic Bistuer
170ca5f57b Fixed the title attribute for choices on "multiple" widgets. 2015-02-26 11:22:05 +07:00
Kevin Brown
a954bae228 Compile Swedish translations 2015-02-24 19:36:44 -05:00
Kevin Brown
5b95c0e834 Clarified the documentation README [ci skip]
The documentation README was previously intended to be read from
the documentation repository, not from the source repository.
This had the potential to give off the impression that documentation
pull requests were not allowed, when exactly the opposite is the
case.  The README has been improved to make it more clear how to
contribute pull requests to update the documentation.

Thanks to Brent Connor [1] for pointing out this issue over at
Stack Overflow [2].

[1]: https://stackoverflow.com/users/3954106/brent-connor
[2]: http://stackoverflow.com/q/28705192/359284
2015-02-24 17:27:16 -05:00
Kevin Brown
9ad1ed8b43 Merge pull request #3067 from stozze/i18n_sv
Swedish i18n
2015-02-24 17:26:57 -05:00
Stozze
1b707960de Swedish i18n 2015-02-24 23:38:21 +02:00
Kevin Brown
a9f6d64b72 Added .dataset fallback for jQuery 1.x
As we have established already, jQuery 1.x does not correctly handle
`data-*` attributes where there are multiple dashes.  This makes it
so we can still handle nested options when working with jQuery 1.x
by using the `.dataset` option that is supported by all major
browsers as well as IE 11+.

Browser support tables for the `.dataset` attributes can be found at
http://caniuse.com/dataset

A notice was already added to the documentation about this in
caeb0ec9b7.

The related ticket in the jQuery repository about this issue is
https://github.com/jquery/jquery/issues/2070.

This closes https://github.com/select2/select2/issues/2969.
2015-02-24 14:42:27 -05:00
Kevin Brown
dc2f6d451a Fix example code for the old matcher 2015-02-24 14:18:07 -05:00
Kevin Brown
f367185a8a Merge pull request #3056 from harshadsabne/select2-ng
Create hi.js
2015-02-24 09:02:23 -05:00
Harshad Sabne
e88440cab3 Create hi.js
Added i18n for Hindi language.
2015-02-20 12:02:25 +05:30
Kevin Brown
e6f249f66d Fixed Array.indexOf in i18n/uk.js 2015-02-17 12:47:48 -05:00
th3byrdm4n
07c4db1de2 replaced usages of [].indexOf with $.inArray()
X-Browser Compatibility (and performance) reasons.

Signed-off-by: Kevin Brown <kevin@kevinbrown.in>
2015-02-17 12:41:36 -05:00
th3byrdm4n
e75cd78c51 word-wrap: nowrap styling
Added `word-wrap: nowrap` to places it wasn’t explicit.

Signed-off-by: Kevin Brown <kevin@kevinbrown.in>
2015-02-17 12:41:25 -05:00
Kevin Brown
2988cc2bee Pull requests are marked as 'false', not missing 2015-02-14 19:08:23 -05:00
Kevin Brown
e8a12133f8 Don't run Sauce Labs tests on pull requests
Due to security restrictions within Travis CI, we cannot use secure
environment variables in pull requests.  This means that the tests
cannot be run in the Sauce Labs environment.

http://docs.travis-ci.com/user/pull-requests/#Security-Restrictions-when-testing-Pull-Requests
2015-02-14 19:05:05 -05:00
Kevin Brown
4271b10531 Add docs for three more options
This adds documentation for the follow options

- `minimumInputLength`
- `maximumInputLength`
- `minimumResultsForSearch`

This closes https://github.com/select2/select2/issues/3035.
2015-02-14 16:53:17 -05:00
Flávio
86c23c0f5c Create pt.js
European Portuguese Translation
2015-02-14 12:16:18 -05:00
Kevin Brown
8572299a2e Added IE 10 and Opera testing
We are special casing Opera 12 as well as the latest Opera version
because Opera 12 was the last release because Opera switched to the
Webkit rendering engine.
2015-02-14 00:42:59 -05:00
Kevin Brown
3d013020ae Improved focus detection and key handling
Now the focus of the selection container is correctly monitored so
there is a consistent 1px black border on the default theme whenever
it is focused.  This requires `focusin`/`focusout` support, which is
supported by all major browsers except for Firefox.  In Firefox, the
old focus appearance is still consistent and has not been broken
by this update.

The key handling has also been improved such that some of the logic
detection that was previously done within the search handlers for
multiple select searches is now pushed back to the base selection.

This closes https://github.com/select2/select2/issues/2995.
2015-02-14 00:37:51 -05:00