1
0
mirror of synced 2024-11-22 21:16:10 +03:00
Commit Graph

1666 Commits

Author SHA1 Message Date
Lenon Marcel
862f4b5113 Add Brazilian Portuguese translation. 2015-02-04 05:16:42 -02:00
Kevin Brown
4c563a3d06 Add back ajax.transport support
This adds back the `ajax.transport` option, which allows anyone to
use their own AJAX backend. By default, `jQuery.ajax` is used as the
default transport backend.

**Breaking change:** Instead of taking `params` that contains a
`success` and `error` keys for the callback, two new callback
parameters are passed alongside of `params` that should be called
when the request succeeds or fails.

This closes https://github.com/select2/select2/issues/2987.
2015-01-29 09:15:02 -05:00
Kevin Brown
5a0f7f5518 Added back escapeMarkup
This is needed to escape any bad markup that is passed through
user-entered data. Users can prevent their markup from being
escaped by using a no-op `escapeMarkup` function.

This closes https://github.com/select2/select2/issues/2990.
2015-01-29 09:15:02 -05:00
Kevin Brown
01461813d8 Fixed missing jQuery import
Now we are using `jQuery.noConflict()` in tests, so it should be
slightly easier to detect when this happens next time. Tests just
need to be written for the component.

This closes https://github.com/select2/select2/issues/2985.
2015-01-29 09:15:02 -05:00
Kevin Brown
36cfc26cc1 Merge pull request #2982 from adrianpietka/select2-ng
Added polish translation
2015-01-28 12:43:43 -05:00
Adrian Piętka
a6b5c7df49 Break long lines 2015-01-28 11:06:03 +01:00
Adrian Piętka
2f4737cc86 Added polish translation 2015-01-28 10:50:34 +01:00
Kevin Brown
a4448d3d00 Preparing for the 4.0.0-beta.3 release 2015-01-27 20:11:38 -05:00
Kevin Brown
15c827b60f Added documentation for matcher
This adds documentation for the revised `matcher` function, as well
as the compatibility `oldMatcher` function for those who are
upgrading.

This closes https://github.com/select2/select2/issues/2971.
2015-01-27 19:36:54 -05:00
Kevin Brown
695123a1d2 Remove jQuery from the bower and component files
Users are expected to be using jQuery in their web applications
already, it's up to them to determine how it is loaded in.

This closes https://github.com/select2/select2/issues/2941.
2015-01-27 18:31:52 -05:00
Kevin Brown
003d6053a9 Prevent scrolling in scrollable containers
This prevents scrolling within scrollable containers (excluding the
dropdown) when the dropdown is open. This fixes an issue where the
dropdown would go out of sync with the parent container when the
parent container was scrolled.

We did not have this issue in past versions of Select2 because the
mask prevented any scrolling. Now that we have removed the mask, we
have to deal with scrolling from different areas of the page.

We initially tried to hook into the `scroll` events of the parent
containers, but because of a list of issues we decided against it.
If the container scrolled out of view, the dropdown would still be
left open and above everything else, even though the container
wasn't visually connected to it.

The `scroll` event does not bubble, so we need to attach the `scroll`
handler to every parent element that is scrollable. Since it is
surprisingly difficult to determine if an element is scrollable,
we modified some CC-BY-SA code and use that to determine if the
element has a scrollbar. The original `hasScroll` function can be
found at http://codereview.stackexchange.com/q/13338, the same link
left within the code, and was originally designed to be a sizzle
selector. As Select2 does not require a sizzle-compatible version of
jQuery, we converted it into a function that could be used with
`.filter` to filter down the elements.

This closes https://github.com/select2/select2/issues/2975.
2015-01-27 16:06:27 -05:00
Kevin Brown
000653498f Fix z-index for modals
Select2 did not previously have a high enough `z-index` for it to
be displayed over modals. The `z-index` has been raised to 1051,
so now it should appear over the jQuery UI and Bootstrap modals.

This closes https://github.com/select2/select2/issues/2958.
2015-01-27 14:27:18 -05:00
Kevin Brown
65ff76c543 Fix dropdown search sizing
When Select2 is not used with a design that universally sets
`box-sizing: border-box` to elements, the search box previously
would take up more space than expected. This fixed the issue by
adding the `box-sizing` rule to the search box.

This closes https://github.com/select2/select2/issues/2978.
2015-01-27 14:09:52 -05:00
Kevin Brown
9906b2f434 Fixed dropdown for responsive widths
When we re-implemented support for responsive widths, through the
use of percentages, we never moved the support over to the dropdowns.
So the dropdowns generally were not large enough, and when resized
they never re-adjusted, and they didn't fully work as intended.

This fixes the issue by automatically resizing the dropdown whenever
it is repositioned, mainly to handle new scrollbars, which will
ensure that it is always the same width as the container.

This also adds a section to the examples for responsive design,
just like in the old documentation.

This closes https://github.com/select2/select2/issues/2949.
2015-01-27 14:07:44 -05:00
Kevin Brown
52513f3290 Merge pull request #2968 from loic/typo
Fixed typo in error message.
2015-01-26 08:51:38 -05:00
Loic Bistuer
285d173536 Fixed typo in error message. 2015-01-26 17:18:06 +07:00
Kevin Brown
6488551374 Reverted changes to the scroll detection
This reverts the changes (from 3.5.x) to the scroll detection, so
Select2 will still reposition itself every time the window is
scrolled or resized. This has the benefit of fixing the issue when
the screen jumps if the dropdown is too high, which would previously
close the dropdown.

Select2 will also correctly set the positioning if it is pushed out
of the top of the viewport. Due to an unexpected bug, Select2 would
previously still display above the container, but would be styled
as if it were below it.

This closes https://github.com/select2/select2/issues/2961.
This closes https://github.com/select2/select2/issues/2956.
2015-01-22 17:35:08 -05:00
Kevin Brown
981c4065af Only trigger unselect for multiple
This fixes an issue where an `unselect` event would be incorrectly
triggered when the selected option was selected again in a single
select. This has been fixed now, so the even will only be triggered
for multiple selects. The `close` event will still be triggered
though, so the functionality will still remain the same to the user.

This closes https://github.com/select2/select2/issues/2959.
2015-01-22 17:16:12 -05:00
Kevin Brown
bca4e1f6d8 Add information about build types 2015-01-22 17:01:50 -05:00
Kevin Brown
80bda0ad55 Fixed the selectOnClose option
The `selectOnClose` option did not work in production because we
were decorating the `dropdownAdapter` instead of the `resultsAdpater`
when automatically generating the adapters. This has now been fixed,
and the option should work without errors in production.

This also adds documentation for the `selectOnClose` option.

This closes https://github.com/select2/select2/issues/2953.
2015-01-22 15:19:45 -05:00
Kevin Brown
686f846fa5 Changed how the builds are done
This adds a check that triggers an error if Select2 was not able
to detect a copy of jQuery on the page. This should help users when
they are setting up Select2.

**Breaking change:** The full build no longer includes jQuery.
Previously, the full build included all requirements for Select2,
including jQuery, which meant that anyone looking for the optional
requirements had to possibly include multiple versions of jQuery
on their page. This means that anyone requiring Select2 to also
bundle jQuery will now need to include jQuery on their pages
alongside Select2. A copy of jQuery is included in the repository.

**Breaking change:** The AMD build of Select2 will now correctly
wrap the code in a `define` block. It will still create the named
blocks inside of the code, which should be valid in most AMD build
systems, so now Select2 is compatible with cases where the file
does not have the same name as the Select2 module name.

**Breaking change:** Select2 will re-use the AMD methods if they
are available on the page, but it will not longer leak the included
AMD loader to the global scope. The AMD methods will still be
available on the `jQuery.fn.select2.amd` namespace.

The `mock.js` test file has been renamed to `helpers.js` and will
handle the escalation of the `require` and `define` variables to
the global scope. It should be included in all test files, or the
tests will fail.

This closes https://github.com/select2/select2/issues/2946.
2015-01-22 14:49:39 -05:00
Kevin Brown
53c9d53166 Fix jQuery.noConflict compatibility
When `jQuery.noConflict` is called, the global `$` variable is not
defined. We cannot assume in the code that the variable is defined,
and instead should always make sure to import the `jquery` module
when we need jQuery.

This fixes all of the issues where we are assuming that `$` is
defined globally when we are not importing the module. This also
fixes the issues when defining the `jQuery.fn.select2.amd` modules
where we were always attaching to the `$` object instead of the
`jQuery` object.

This closes https://github.com/select2/select2/issues/2947.
2015-01-21 19:56:06 -05:00
Kevin Brown
d81886e5de Trigger the unselect event when clearing placeholder
In the past, Select2 triggered the `select2-clearing` event when
clearing the placeholder. This has been switched to the `unselect`
event which is now triggered whenever the placeholder is cleared.
The placeholder can also be prevented if the `unselecting` event
is prevented.

This will also trigger the event when deleting every option from
the multiple select, so it is possible for the `unselecting` event
to be triggered multiple times when clearing a multiple select.

This adds tests to ensure that the `allowClear` option always works.

This closes https://github.com/select2/select2/issues/2954.
2015-01-21 19:11:07 -05:00
Kevin Brown
5b4e1eab42 Added a check for the results key in AJAX responses
This should prevent users from running into unexpected errors when
they do not return an object with the `results` key containing an
array.

This closes https://github.com/select2/select2/issues/2950.
2015-01-21 16:36:23 -05:00
Kevin Brown
850816ee77 Update docs links for the CDN
Now that cdnjs is mirroring the beta files, we know what the final
locations are going to be. These identifiers will need to be updated
during the release process, just like all of the others.

This closes https://github.com/select2/select2/issues/2955.
2015-01-21 16:20:15 -05:00
fallenby
0fe54b6d3b Hide element if template returns a false-like value
This allows you to hide elements when using the template% formatting functions.

Signed-off-by: Kevin Brown <kevin@kevinbrown.in>
2015-01-17 22:14:12 -05:00
Tim
c318cde916 Added dutch translations
nl.js

Signed-off-by: Kevin Brown <kevin@kevinbrown.in>
2015-01-17 22:11:17 -05:00
Kevin Brown
ffb58a1be8 Fixed Russian translation
This fixes a mistake made when migrating the translation.
This closes https://github.com/select2/select2/issues/2933.
2015-01-17 22:05:48 -05:00
Kevin Brown
1b46e8ab3e Improve the default language chain
If the language that is passed in through the options is just a
string, like "en-US" or "pt-BR", Select2 will now try to load the
base language along with the requested language and "en". So
requesting "pt-BR" will try to load "pt-BR", "pt", and "en".

This also catches errors and triggers a warning about not being
able to load the file. This should be a more user friendly error,
and it fixes the problem where Select2 would completely fail to
initialize if a language could not be found.

This closes https://github.com/select2/select2/issues/2934.
2015-01-17 21:56:58 -05:00
Kevin Brown
2f4cc19cd9 If a named style can't be determined, return null
Previously this would return `style` if it couldn't be resolved and
the `style` attribute on the element is set for some reason. Now it
will return `null`, because it tried to resolve the width but was
not able to. This will allow it to fall back to `element` by default,
or not set the width at all.

This closes https://github.com/select2/select2/issues/2935.
2015-01-17 21:43:38 -05:00
Kevin Brown
f427451853 Expose the defaults
This exposes the default options for Select2 as
`$.fn.select2.defaults`. A default option can be set using the
`set(key, val)` option which is available. The key should use the
same formatting as the HTML data attributes.

This also adds some documentation about it.
2015-01-17 21:27:53 -05:00
Kevin Brown
c5a3f34012 Added notes on the AMD-specific options 2015-01-17 20:59:05 -05:00
Kevin Brown
d6a83ea026 Pull query and initSelection out to compat modules
This also adds more documentation and corrects the release notes
for these breaking changes. These modules will now only be included
in the full builds of Select2, which has been noted in a few places.
2015-01-17 20:47:52 -05:00
Kevin Brown
061b432485 Merge pull request #2931 from dlion/ItalianTranslation
Added italian translation
2015-01-16 08:05:30 -05:00
Domenico Leone Luciani
ae564f6219 added italian translation 2015-01-16 11:03:57 +01:00
Kevin Brown
b43656c13c Added basic accessibility tests
This adds basic tests to ensure that the selection is accessible by
all users. This checks for common attributes, ensuring that the
container is always keyboard accessible and follows ARIA guidelines.

This also changes the base selection to create a common element so
we don't need to repeat attributes and such across multiple selection
containers.
2015-01-14 22:54:19 -05:00
Kevin Brown
2a7ae0ea9c Add backwards compatibility with query option
This adds backwards compatibility with the `query` option so it
automatically patches the `DataAdapter.query` function. The only
major difference between the methods is the call signature, which
has now moved the callback out of the parameters and into the second
argument.

This also adds tests that verify that the old query functions should
work as expected.
2015-01-14 21:24:09 -05:00
Kevin Brown
e04188c85a Added backwards compatibility for initSelection
Now if the old `initSelection` method is used, a warning will be
triggered in the console informing the user that it has now been
changed to `DataAdapter.current`, and they should create a custom
data adapter instead. We will still only call `initSelection` once,
and then default back to the old data adapter for calls after that.
This allows for mostly transparent support between versions.

This adds tests to ensure that `initSelection` operates the same as
it previously did, but now patches the `current` method of the
default data adapter.
2015-01-14 21:24:08 -05:00
Kevin Brown
286b83898f Documented the removal of initSelection and query
This adds detailed docs explaining how you can convert the old
implementations of `query` and `initSelection` into a custom data
adapter using the `current` and `query` methods provided there.
Examples are included that should make it considerably easier to
handle.
2015-01-14 21:24:08 -05:00
Kevin Brown
7f2cb23e78 Merge pull request #2917 from solcik/cs-trans
Added czech translations
2015-01-14 19:41:32 -05:00
Kevin Brown
911966be78 Update version identifiers for 4.0.0-beta.2 2015-01-13 19:18:33 -05:00
Kevin Brown
8d35d5e416 Fixed opening issue
This fixes an issue where the data set would not be queried when
the dropdown was opened.
2015-01-13 19:09:04 -05:00
Kevin Brown
28f9cae5d7 Added some more jQuery events
This adds the `select` and `unselect` events so users can still
hook into them from their jQuery plugins.

This also modifies the core `trigger` to fire pre-events that can
be canceled for the `open`, `close`, `select`, and `unselect`
events. Users implementing these events who need to handle cases
where the event has been prevented should check `args.prevented`,
where `args` is the object that was included for arguments when
triggering the internal event.
2015-01-13 18:28:21 -05:00
Kevin Brown
dc0ebd35d5 Merge pull request #2914 from smzchaudary/select2-ng
add maximum selection length option
2015-01-13 14:01:00 -05:00
Zubair
bc71ad4880 fix spacing of examples. 2015-01-13 13:49:27 -05:00
Zubair
160abdc54e cleanup example and move examle based on PR comments. 2015-01-13 13:00:17 -05:00
Zubair
7515fa7f46 only verify when maximumSelectionCount is greater than 0 and add tests 2015-01-13 13:00:16 -05:00
Zubair
25dade52e5 rebuild dist. Fixed space 2015-01-13 13:00:16 -05:00
Zubair
e18fa1b5b8 fix callback using this.current.
add example.
2015-01-13 13:00:16 -05:00
Zubair
1c8846079b replace this.$element.val() with this.current() 2015-01-13 13:00:16 -05:00