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.
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.
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.
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.
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.
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.
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.
There were a few undefined variables being referenced within the
Select2 code. The JSHint configuration has been modified to fail
if there are undefined variables being referenced, including any
global variables.
There is an exception that is being made for the jQuery shim, as it
must try to find the global jQuery references.
An exception is made for the test helpers, as the SauceLabs reporting
variables are not camelCase, and would normally trigger warnings.
This closes https://github.com/select2/select2/pull/3028.
This sets up Select2 to be able to run tests on the SauceLabs
environment. This will allow us to run the tests on different
browsers in the future, though at the moment we need to start
combining test files.
This required adding a snippet of code for reporting QUnit test
results to SauceLabs within the global test helper file.
The tests currently cannot be run on IE 8 because all of the tests
are using jQuery 2.x, which is not compatible.
This adds `StopPropagation` modules that will stop the propagation
of the most common events from the selection and dropdown containers.
These modules work from a list of 21 common events, most of which
were stopped by default in past versions, and call `stopPropagation`
on them when they are detected at the container level.
These modules are only available in full builds of Select2.
This closes https://github.com/select2/select2/issues/2033.
This closes https://github.com/select2/select2/issues/2974.
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.
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.
jQuery.mousewheel will allow us to prevent the dropdown from
automatically closing when the user scrolls to the end of the list.
It is automatically bundled in the full versions of Select2 and
we don't require that it is included in order for Select2 to work.
jQuery.mousewheel was taken directly from the source repository
using the commit at
cc2c5d73ae
This adds a custom r.js build for i18n, which processes each JS
file in the `select2/i18n` directory and builds it.
So far only the "No results found" translation has been added.
This will prevent leaking variables, and will remove the possibility
of Select2 not working well with other plugins which support
AMD loaders. The `define` and `require` methods are now aliased
under `$.Select2.amd` for use inside additional files, such as
translations.
We have to enforce ids being strings as the values of options within
a select will always be an id. This fixes an issue that we had with
array selections not being highlighted in the results.
This adds decorator support in a very basic way, but enough that
it doesn't take a lot of effort to get it implemented.
This also starts work on splitting things out for theming.