1
0
mirror of synced 2024-11-23 21:36:09 +03:00
Commit Graph

2066 Commits

Author SHA1 Message Date
Kevin Brown
d6bc96d7de Expand upon the core section of the docs
This adds more code examples where they might be useful, and adds some
more description where it was needed. This clarifies a couple of the
questions that have come up about the AMD support and links to the bug
that Select2 was involved with that some people reported when 4.0.0 was
released.
2016-01-14 18:40:37 -05:00
Kevin Brown
69ef214c92 Display error message on AJAX errors
This display the `errorLoading` translation when there is an error
during the AJAX cycle. Previously we were just throwing these errors
out, now we are actually displaying an error message.

This closes https://github.com/select2/select2/issues/3501
2016-01-04 20:07:37 -05:00
Kevin Brown
db5e947664 Added test for new insertTag option
This adds a basic test that ensures that the `insertTag` option works as
expected.
2016-01-03 19:09:45 -05:00
Stretch
e842797aaf Added insertTag to control the tag position
This adds an option called `insertTag` that controls the location within
the results where the tag is inserted. The function should take in the
results array and the tag, and should modify the array in-place to add
the tag to the results.

This closes https://github.com/select2/select2/issues/3420
This closes https://github.com/select2/select2/pull/4008
2016-01-03 19:08:59 -05:00
Kevin Brown
63d531a9c0 Fixed responsive example in documentation
This fixes the documentation so the responsive example actually works.
Everything was working properly, the example just wasn't updated when
the default for the width was changed to `100%` in
5fd72d2052.
This is a change from the old `resolve` width setting, which is
responsible for parsing the style attribute and getting the width that
was set.

This closes https://github.com/select2/select2/issues/4050
2016-01-03 18:57:49 -05:00
Kevin Brown
f3b9693ad9 Fixed existing selections not being respected with array data
This fixes an edge case that occurred pretty much whenever anyone would
use array data with existing selections along with a placeholder. This
caused the existing selections to be discarded, because the `selected`
property was not being transferred over to the new option. This was
based the new data was being preferred over the data that could be
inferred from the option, and the new data typically did not include the
selected state. As a result, the option was assumed to not be selected.

This was not cause by existing tests because all of the existing tests
only covered cases where the selected option was the first option, and
that was not affected by this bug.
2016-01-03 18:34:59 -05:00
Kevin Brown
d1ed0a513a Add failing test for existing array selections
This adds a broken test that demonstrates the issue seen in
https://github.com/select2/select2/issues/3990 where existing selected
options are being reset once Select2 is initialized. This issue cannot
be reproduced on the options page [1] because the issue only appear to
happen if the selected option is not the first one in the list of
possible options.

[1]: https://select2.github.io/examples.html#data-array
2016-01-03 18:21:09 -05:00
Kevin Brown
f58c1efc11 Fixed failing tests in IE9/FX
This fixes the two failing assertions that only triggered in IE 9 (no
other versions) and Firefox. Both of them were caused by the offset for
the dropdown including a constant extra amount, what appeared to be
related to the size of the container if it actually had content. This
was not consistent in browsers, so now we are forcing there to be a
small amount of content within the container and then calculating the
expected offset based on that height.
2016-01-03 17:46:01 -05:00
Kevin Brown
09ecd3cdb9 Remove dead code
This call to `$.fn.position` was causing an error in IE 8 because the
`offsetParent` was null on the container for some reason. It's not
needed, so this line of code has been removed.

This should fix the test failures in IE 8.
2016-01-01 18:16:51 -05:00
Kevin Brown
e260860789 Correct positioning issues for statically positioned elements
There was a commit that landed in 4.0.1 that fixed positioning for
non-static elements, which are commonly used for the custom
`dropdownParent` option, but broke positioning for statically positioned
elements, commonly used in almost every other case. That commit was
c9216b4b96

This fixes the positioning issues caused by that commit by properly
calculating the offsets for statically positioned parents. Statically
positioned parents are unique, because the offset for the dropdown must
be calculated based on the closest element that is non-statically
positioned. Otherwise, the offset for any statically positioned parent
other than the body will be considerably higher than it should be,
resulting in the dropdown being offset by a large amount.

The offset parent for the body element is the html element, which is why
this works for both the body element and any custom parents for the
dropdown. This would not be needed if the parent wasn't customizable (as
seen in Select2 3.x) because you will never need to offset the body
element if it is statically positioned, because the html element almost
never has an offset.

This also fixes JSHint issues within the tests added in the last commit.

This closes https://github.com/select2/select2/issues/3970
This closes https://github.com/select2/select2/issues/3639
2016-01-01 17:15:00 -05:00
Kevin Brown
b5a4698250 Add regression tests for the positioning issues
This adds a regression test that verifies the problem with positioning
the dropdown when the parent is a statically positioned element that
still has an offset. This could typically be seen if the body element
has an offset, which unfortunately it almost always does because of the
default user stylesheet in browsers. This was not caught during
pre-release testing because all of the test pages reset the margins and
padding on the body element.

This regression test verifies that the offsets that should be set for
the dropdown are calculated correctly. These were surprisingly difficult
to do because of how the offset is calculated using different
positioning techniques.

These tests are for https://github.com/select2/select2/issues/3970
2016-01-01 16:47:49 -05:00
Kevin Brown
9c35475c6c Added test for attachBody
This is just a basic test that ensures that the dropdown is appended to
the end of the dropdown parent when `dropdownParent` is defined.
2015-12-31 13:04:38 -05:00
Kevin Brown
bc19964170 Update version identifiers to 4.0.1 2015-11-27 18:26:20 -05:00
Kevin Brown
c9216b4b96 Fixed positioning with non-static parents
This fixes an issue with non-static parents (ones that were relatively
or absolutely positioned) where the dropdown would be offset by the
offset of the parent, so it would almost never line up. This fixes the
problem by removing the offset when the parent is not statically
positioned, which is what we used to do in older versions of Select2.

This closes https://github.com/select2/select2/issues/3303.
This closes https://github.com/select2/select2/issues/3614.
This closes https://github.com/select2/select2/issues/3672.
2015-11-27 17:58:08 -05:00
Kevin Brown
393ca4cf7f Fix selectOnBlur and closeOnSelect combination
This fixes an infinite loop that used to be caused when both
`closeOnSelect` and `selectOnClose` used to be combined, because they
both were listening to events triggered by the other one. The problem
was that `selectOnClose` was triggering `select` events for data objects
which had already been selected. This problem was solved by checking if
the data object was already selected before trying to select it again.

This closes https://github.com/select2/select2/pull/3751.
This closes https://github.com/select2/select2/issues/3169.
2015-11-27 17:32:54 -05:00
Kevin Brown
d504700c53 Recompile dist with newer dependencies 2015-11-27 16:07:10 -05:00
Kevin Brown
af97cc9996 Use NPM versions in builds
This changes the Grunt script to automatically pull the locations of the
NPM versions of the Almond loader and jQuery mousewheel plugin. This
means we no longer need to include these vendor files in our repository,
as the builds will automatically pull from the existing NPM files.
2015-11-27 16:07:08 -05:00
Kevin Brown
32b6eae54b Explicitly require jquery-mousewheel now
This fixes the implicit requirement of jquery-mousewheel that previously
existed. This was not allowed, as pointed out in
https://github.com/select2/select2/issues/3287#issuecomment-120408092

Now the requirement is more explicit, so everything should work as it
was before.
2015-11-27 16:07:07 -05:00
Kevin Brown
8edf3c6408 Add dependencies on Almond and jQuery Mousewheel
These are technically only required when building the final versions,
but if someone is pulling from NPM they may want to deal with building
it as well. Almond is used for loading in packages and jQuery Mousewheel
is used to prevent the results from scrolling the page.
2015-11-27 16:07:05 -05:00
Kevin Brown
5ca76fda61 Merge pull request #3782 from nopash/patch-1
Correct Typo in noResults
2015-11-27 15:42:51 -05:00
Kevin Brown
23743a785c Merge pull request #3933 from Decagon/patch-1
Fix #3932
2015-11-27 14:56:40 -05:00
Kevin Brown
3c8366e876 Fixed deep cloning options
In
f1e86470ca
we tried to fix the issue where multiple instances created in a single
call would share the same options, and this worked for the most common
cases. Unfortunately it did not work for the case where data attributes
were also used with an options object, and as a result data attributes
would be copied to all instances. Data attributes are supposed to be
specific to a single instance.

This was fixed by moving the `true` for the deep copy to the start of
the `$.extend` call, as this is where jQuery looks for the deep copy
flag.

This closes https://github.com/select2/select2/issues/3485
2015-11-23 18:55:31 -05:00
Kevin Brown
e2b745ea3e Recompiled dist 2015-11-23 18:44:35 -05:00
Kevin Brown
dc516e7073 Add container to templateResult
This closes https://github.com/select2/select2/issues/3222.
2015-11-23 18:40:50 -05:00
Jono Mingard
7e3d4fb697 Add tests for accessible search results 2015-11-23 18:35:36 -05:00
Jono Mingard
9fae3d74e3 Speak results on selection
This closes https://github.com/select2/select2/issues/3735
This closes https://github.com/select2/select2/pull/3821
2015-11-23 18:34:37 -05:00
Kevin Brown
e08222ef15 Tests for the inline search box
This adds tests for the following commits

5f80c5d9f8

395e06aff5
2015-11-23 18:25:09 -05:00
Kevin Brown
5f80c5d9f8 Resize search after removing a choice
This fixes a previous bug with the backspace handler on the multiple
select search box where unselecting a choice through the keyboard would
not properly size the search box. As a result, most of the text would be
cut off and it was very clear that there was an issue.

In addition, a blank space was automatically being added to the end of
the search query. This blank space would not be removed at all, so the
user had to manually remove it.

Additionally, a query would be triggered for the last used search term
instead of the new search term that would be loaded in. This caused
incorrect results to be displayed most of the time.

All of these issues have been fixed by triggering a new search query
after an option has been removed through the keyboard. This will resize
the search box automatically, which fixes the main issue, and it will
trigger a search with the correct query.

This closes https://github.com/select2/select2/issues/3297
This closes https://github.com/select2/select2/pull/3398
2015-11-23 18:22:33 -05:00
Kevin Brown
8763a87779 Merge pull request #3946 from manuel-alvarez-alvarez/master
Add the decorator parameter to the handlers for the attach and detach of the dropdown
2015-11-23 16:49:59 -05:00
Kevin Brown
f94b462b15 Merge pull request #3943 from limonte/sr-Cyrl
Add sr-Cyrl language.
2015-11-23 15:43:03 -05:00
Limon Monte
410916510d Add errorLoading error message to sr, sr-Latin and hr languages. 2015-11-20 11:39:35 +01:00
Limon Monte
1c8d1f8e0d Add sr-Cyrl language. 2015-11-20 11:38:13 +01:00
Manuel Alvarez Alvarez
a06a08a028 Fixed jshint errors due to too long lines on the attachBody adapter 2015-11-19 15:49:52 +01:00
Manuel Alvarez Alvarez
eae4d01158 Add the decorator parameter to the handlers for the attach and detach the dropdown (otherwise the container is undefined) 2015-11-19 15:39:28 +01:00
Decagon
6dbe2d9164 Fix #3932 2015-11-15 16:11:29 -04:00
Kevin Brown
7e2ade0965 Merge pull request #3926 from stahor/patch-1
Update component.json
2015-11-12 11:17:37 -05:00
stahor
7eaee2be9e Update component.json 2015-11-12 14:28:40 +03:00
Kevin Brown
87b182fe2a Update version identifiers to 4.0.1-rc.1 2015-11-09 20:23:20 -05:00
KahWee Teng
31a329eb6d Fix inline search in Safari
This closes https://github.com/select2/select2/issues/3459
This closes https://github.com/select2/select2/pull/3476
2015-11-09 19:28:58 -05:00
Quentin Pradet
878bb3ab07 Fix select2('') calls on multiple elements
This fixes an issue when any of Select2's special options are called on
multiple elements, it would only affect the first option in the group.
This was because Select2 was only applying any changes to the first
element in the group (as chosen by jQuery) instead of applying changes
on each and every element within the list.

This has the new side effect of special options like `select2('data')`
returning the results for the last element in the list instead of the
first element. Because the previous functionality was considered
unspecified behaviour, this is not being treated as a breaking change.

This closes https://github.com/select2/select2/issues/3413
This closes https://github.com/select2/select2/pull/3495
2015-11-09 19:03:22 -05:00
Kevin Brown
7c47912b73 Set all AJAX parameters as query string parameters
This will now pass all of the AJAX parameters into the AJAX request as
query string parameters, so now the page number (and other variables)
will be set automatically. This can still be overridden in `ajax.data`
to pass anything else, but this should make it easier for the most
common case.

This closes https://github.com/select2/select2/issues/3548
This closes https://github.com/select2/select2/pull/3552
2015-11-09 18:49:40 -05:00
Lars Holm Jensen
ef508db161 Corrected Danish translation for results errors
This closes https://github.com/select2/select2/pull/3870
2015-11-09 18:28:59 -05:00
Kevin Brown
d0ce218c0b Merge pull request #3544 from fk/3306-clear-button-appears-under-long-text
#3306: Position clear button before the inline content of `.select2-selection__rendered`
2015-11-09 18:15:12 -05:00
Kevin Brown
c53b2dcf11 Fixed incorrect classes on "Loading more results" message
This fixes an issue where the old `option` and `load-more` classes were
not switched over to the newer BEM style of class names. Unfortunately
this is a breaking change, but this is also a bug given that it doesn't
follow the proper prefixing and is likely to conflict with larger
applications.

https://github.com/select2/select2/issues/3889
2015-11-09 18:13:02 -05:00
Kevin Brown
6d91da7e63 Recompile dist 2015-11-09 18:03:35 -05:00
SilverFire - Dima Naumenko
3037b933e2 Correct reference for this in AJAX callbacks
Previously `this` would point to the AjaxAdapter that was being used to
process the AJAX, or sometimes the JS object holding the AJAX options,
instead of the jQuery element that Select2 was attached to. This fixes
the issue so `this` will consistently point to the jQuery element, just
like in past versions of Select2.

This closes https://github.com/select2/select2/issues/3361
This closes https://github.com/select2/select2/pull/3410
2015-11-09 18:00:39 -05:00
Kevin Brown
71cc891b83 Merge pull request #3859 from ahmadhussain/master
Added arabic language
2015-11-09 17:49:22 -05:00
Meir Cohen
7974fd1662 Corrected a few Hebrew translations
About  `errorLoading`:
Before the correction, the translation was: "התוצאות לא נטענו בהלכה".
The word "בהלכה" is wrong and should be spelled "כהלכה", but besides that, this translations means "The results were loaded improperly", while my corrected translation means "Error while loading results", which is what needed.

About `inputTooLong`, `inputTooShort`, `maximumSelected`:
In Hebrew, it's not acceptable to have the digit 1 for representing a single object. You should use the actual word "one", which is "אחד" in Hebrew together with the singular noun (e.g. "one item" / "one character", instead of "1 item" / "1 character").
**These 3 parts needed a critical fix anyway**, because they were addind the English letter 's' to the end of the Hebrew string.

About `loadingMore`:
The translation was "טען תוצאות נוספות" which means "Load more results", as an instruction, probably a typo.
I changed "טען" to "טוען" so now it means "loading more results", which is the correct form.

This closes https://github.com/select2/select2/pull/3911
2015-11-09 17:43:53 -05:00
Kevin Brown
ca0fd7c195 Properly disable input handlers in IE
Previously we were only disabling the `input` handler when it was
triggered, which caused a race condition within the `keyup` handlers
which also was triggered by the `input` event. This fixes the issue by
also unbinding the `input` handlers within the `keyup` handler, to avoid
running into the race condition.

Thanks to @Eckankar for pointing out the race condition that still
existed in
66ae2ad1d5

This closes https://github.com/select2/select2/issues/3300
2015-11-09 17:33:30 -05:00
Ahmad Hussain
09d825dd31 added arabic language 2015-10-22 12:01:26 +03:00