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

481 Commits

Author SHA1 Message Date
Damien Finck
b1ea28bb7d Add missing French translation 2016-05-04 19:55:01 +02:00
Maarten Brouwers
89dcfef94b linting fix for lt i18n file 2016-05-03 00:08:06 +02:00
Aurelijus Rožėnas
5b5eddd183 Fixed broken lithuanian translation
This closes https://github.com/select2/select2/issues/4301.

Signed-off-by: Kevin Brown <kevin@kevin-brown.com>
2016-04-23 22:33:22 -04:00
Kevin Brown
31e7a1d4c5 Support the focus event on the <select> element
This adds basic support for focusing the Select2 element by triggering
the `focus` event on the underlying <select> element.  This implicitly
adds support for <label> elements, which will trigger the `focus` event
on the `<select>` if it is clicked.

This also fixes the focus issue that previously existed if Select2 was
opened while in a <label>. The focus would be transferred to the search
dropdown, and then immediately pulled away to the <select> element. This
happened because the <label> element triggers the `focus` event when a
`click` event propagates its way up, and we do not stop the propagation
of the `click` event when it is triggered on the selection.

This closes https://github.com/select2/select2/issues/2311.
This closes https://github.com/select2/select2/issues/4203.
This closes https://github.com/select2/select2/pull/4235.
2016-04-23 19:58:04 -04:00
Ryan Cousart
ecdc416635 Fixing bug with non-static parents for dropdowns
The offset of the parent was only being subtracted if the dropdown was
facing down, this now subtracts it if the dropdown is facing up as well.
This more or less applies the same fix as
e260860789,
but when calculating the position of the dropdown when it is facing up.

This closes https://github.com/select2/select2/issues/3303
This closes https://github.com/select2/select2/pull/4267
2016-04-17 16:58:01 -04:00
Kevin Brown
c099755012 Merge pull request #4246 from somethvictory/master
add Khmer translation
2016-04-14 17:54:48 -04:00
Kevin Brown
3b8cd2e369 Create an option when tokenizing if needed
Previously the tokenizer only worked when creating multiple options
at once if all of the options existed. It always worked when creating
a single option, because all of the special cases were handled by the
tagging module. When working with multiple options, the tagging
module does not kick in until after the query has been run, which
is when the tokenizer does its magic.

This fixes the issue by automatically creating the option tags that
the tagging module would normally create. It only does this if the
options do not already exist, so we don't need to worry about the
tokenizer creating duplicates of existing options.

This closes https://github.com/select2/select2/issues/3458
2016-03-27 18:29:01 -04:00
Kevin Brown
cfb66f5e4f Attempt to detect aborted requests
The error handler should not be raised if a request is aborted while
another one is sent out. This attempts to detect those cases by
handling the case where the error was raised and the request has a
status code of 0, which should either mean we're in offline mode or
the request was aborted.

This closes https://github.com/select2/select2/issues/4205
2016-03-27 15:44:40 -04:00
Kevin Brown
fe26b083eb Fix dropdownAutoWidth so it actually works
Previously the `dropdownAutoWidth` option didn't work because the
dropdown was being absolutely positioned, so setting the width to
`auto` didn't actually have an effect. This cannot be solved by
just setting the width on the container, because that is also
absolutely positioned.

This closes https://github.com/select2/select2/issues/3101
2016-03-27 15:24:37 -04:00
Kevin Brown
c2c1aeef31 Fix calling select2('', args) on multiple elements
This fixes an issue that has existed since Select2 4.0.1 where the
arguments passed into each `<select>` were mutated. This no longer
mutates the arguments for each element, and instead only drops the
first argument once.

This closes https://github.com/select2/select2/issues/4245
2016-03-27 14:59:44 -04:00
jpic
8869b170b1 Set list-style further down the DOM
This closes https://github.com/select2/select2/issues/4225
This closes https://github.com/select2/select2/pull/4226
2016-03-27 14:55:21 -04:00
Sondre Eikanger Kvalø
0212edda95 Added missing Norwegian bokmaal label used for errors 2016-03-16 15:51:39 +01:00
Someth Victory
a7738c4517 fix jshint: Line is too long 2016-03-10 16:45:27 +07:00
Someth Victory
a797833e10 add Khmer translation 2016-03-10 16:35:09 +07:00
Radu Ungureanu
72d905f9e0 Romanian localization
- updated transaltions
- added translation for errorLoading
- issue fixes - compare characters length instead of message when adding terminal character

This closes https://github.com/select2/select2/pull/4208
2016-03-08 19:54:01 -05:00
Vasyl Zuzyak
e3f9466d8b Reuse result of previous calcualtion
This closes https://github.com/select2/select2/pull/4155.
2016-02-14 14:03:49 -05:00
Bruno Sampaio
983cd8e765 Recursively apply defaults
This closes https://github.com/select2/select2/pull/4130.
2016-02-14 13:58:14 -05:00
Ben
65179f16de Santize automatically generated ids
This closes https://github.com/select2/select2/issues/3618.
This closes https://github.com/select2/select2/pull/4123.
2016-02-14 13:48:19 -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
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
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
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
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
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
5ca76fda61 Merge pull request #3782 from nopash/patch-1
Correct Typo in noResults
2015-11-27 15:42:51 -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
dc516e7073 Add container to templateResult
This closes https://github.com/select2/select2/issues/3222.
2015-11-23 18:40:50 -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
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
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
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
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
Shawn
f3a29b87e1 Fixes and issue where If args are not present script terminates 2015-10-19 15:34:44 -07:00
Nopachat Kalayanapan
9b020edd80 Correct Typo in noResults 2015-09-18 17:57:43 +07:00
Chris Rodgers
441fbc2d73 Method called using apply to avoid translating multiple args into single arg. Fixes #3756 2015-09-10 12:05:25 +01:00
Kevin Brown
eb47f638d3 Merge pull request #3698 from jbrown/patch-1
Fix typo
2015-08-25 11:35:09 -04:00
Kevin Brown
89858c418d Implement Dropdown.bind
This closes https://github.com/select2/select2/issues/3239
2015-08-21 20:51:42 -04:00
Kevin Brown
73e50ae92c Hide messages when loading results
This closes https://github.com/select2/select2/issues/3343
2015-08-21 20:49:01 -04:00
Kevin Brown
49589611ee Handle null being returned from createTag
The `createTag` option does allow for `null` to be returned if a
tag should not be created. The tokenizer previously didn't support
this, so the tokenizer should be able to handle this case. Previously
it would trigger an exception, because the tokenizer would pass back
a null value to the select function.

This also fixes what would have been a potential bug where even if a
tag was not created, the term would still have been sliced at the
location of the token. This allows for tokenizers to have special
cases when tokenizing the term, such as not splittting a token
if it is in the middle of a quoted string.

This closes https://github.com/select2/select2/issues/3593
This closes https://github.com/select2/select2/pull/3591
2015-08-21 19:12:13 -04:00
Stretch
d08cb874f9 Trigger the select event in the tokenizer
This closes https://github.com/select2/select2/issues/3325.
This closes https://github.com/select2/select2/pull/3453.
2015-08-21 18:30:35 -04:00
Kevin Brown
7166935958 Always pass in a blank object for arguments
This fixes an issue where preventing the default behaviour on some
events would trigger an exception. This was bacause the event relay
was expecting there to always be an object passed in for arguments,
and this wasn't always the case.

This closes https://github.com/select2/select2/issues/3431.
2015-08-21 17:43:50 -04:00
Kevin Brown
66ae2ad1d5 Fix input event in IE
This closes https://github.com/select2/select2/issues/3300
This closes https://github.com/select2/select2/pull/3677
2015-08-21 14:46:50 -04:00
Justin Brown
dac09005ad Fix typo 2015-08-20 13:15:57 -04:00
Bart Pelle
eee70fd9af Fix improper grammar in Dutch i18n file
Grammar is incorrect when maximum is 1, 'kunnen' should be 'kan' in that case.
2015-08-20 09:21:52 +02:00
Kevin Brown
1587708826 Merge pull request #3507 from RyanDale/issue-3503
Fixes #3503: Removes redundant 'open' event trigger
2015-08-19 22:44:30 -04:00
Kevin Brown
ea538819c3 Merge pull request #3605 from molily/master
Multiple select, search field: Removes padding on mobile Safari.
2015-08-19 21:25:01 -04:00
Kevin Brown
68d068f1d2 Prevent selections from being removed when disabled
This prevents selections from being removed when the container is
disabled. This stops any click events that are triggered on the
remove button, so the remove handler won't be triggered at all.

This closes https://github.com/select2/select2/pull/3636.
2015-08-19 21:01:19 -04:00
Kevin Brown
671f5a2ce2 Fix memory leak in AttachBody
The `$dropdownContainer` variable wasn't being cleaned up when
Select2 was destroyed, which was causing a memory leak.

This closes https://github.com/select2/select2/issues/3559.
This closes https://github.com/select2/select2/pull/3603.
2015-08-19 20:07:51 -04:00
Kevin Brown
700f7908fc Merge pull request #3654 from wdietz/master
Fix IE 8-11 not showing Chinese characters
2015-08-19 10:26:10 -04:00
Kevin Brown
47895b1e45 Merge pull request #3565 from rockshandy/issue-3564
use merged data instead of existingData for ArrayAdapter
2015-08-11 18:22:40 -04:00
Wayne Dietz
d37d6d6cac Fix issue in IE 8-11 that prevents typing characters that require multiple key presses to produce a single glyph. 2015-08-06 10:17:03 -05:00
Salahuddin Hairai
fd9ab0665d Updated Indonesian translation 2015-08-01 15:36:45 +08:00
Salahuddin Hairai
00e98e8afc Add Malay translation 2015-08-01 15:34:36 +08:00
Mathias Schaefer (molily)
a1bcd3a7ac Multiple select, search field: Removes padding on iOS. 2015-07-23 13:11:43 +02:00
Michał Zalewski
74bb22939a Fixed typo in maximum selected message 2015-07-18 10:19:10 +02:00
Phil Eberhardt
f5593e12e4 use merged newData in case where an option already exists when using ArrayAdapter 2015-07-09 18:40:56 -04:00
Florian Kissling
80630c42ec Render .select2-selection__clear before the inline content of .select2-selection__rendered.
As suggested by @njakobsen in https://github.com/select2/select2/issues/3306#issuecomment-109372777, this uses `position: relative` to alter the stacking level of `.select2-selection__clear`.
See http://www.w3.org/TR/CSS2/zindex.html#painting-order and https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Understanding_z_index/Stacking_without_z-index.

Styles are added to the default Sass for `.select2-selection--single`.
Does not include the recompiled distribution CSS.

References https://github.com/select2/select2/issues/3306.
Tested in Google Chrome v43.0.2357.130 only.
2015-07-02 03:00:21 +02:00
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 Dale
c5a54ed706 Fixes #3503: Removes redundant 'open' event trigger 2015-06-21 16:30:20 -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
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
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
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
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
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
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
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
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
Stozze
1b707960de Swedish i18n 2015-02-24 23:38:21 +02:00