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

33 Commits

Author SHA1 Message Date
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
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
992652bbd2 Expand IE testing
Now that our tests are using jQuery 1.7.2 we can run our tests on
IE8 automatically.
2015-03-11 19:26:30 -04:00
Kevin Brown
30974e2422 Only test Opera 12 once
Looks like Sauce Labs is not going to have tests running on later
versions of Opera, probably because it switched to Chromium/Blink.
Removing it from the builds so we reduce the time it takes.
2015-03-11 18:30:38 -04:00
Kevin Brown
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
Kevin Brown
2988cc2bee Pull requests are marked as 'false', not missing 2015-02-14 19:08:23 -05:00
Kevin Brown
e8a12133f8 Don't run Sauce Labs tests on pull requests
Due to security restrictions within Travis CI, we cannot use secure
environment variables in pull requests.  This means that the tests
cannot be run in the Sauce Labs environment.

http://docs.travis-ci.com/user/pull-requests/#Security-Restrictions-when-testing-Pull-Requests
2015-02-14 19:05:05 -05:00
Kevin Brown
8572299a2e Added IE 10 and Opera testing
We are special casing Opera 12 as well as the latest Opera version
because Opera 12 was the last release because Opera switched to the
Webkit rendering engine.
2015-02-14 00:42:59 -05:00
Kevin Brown
081580bcd8 Fix undefined variables
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.
2015-02-13 22:49:54 -05:00
Kevin Brown
08014add7c Fixed local server not starting for Travis 2015-02-13 22:22:14 -05:00
Kevin Brown
a0c26e1114 Hook up with SauceLabs
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.
2015-02-13 21:59:09 -05:00
Kevin Brown
8f8140e3b0 Added modules for stopping event propagation
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.
2015-02-09 20:04:01 -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
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
766d9f05e0 Automatically set up docs symlink
This also adds some docs about building the documentation.
[ci skip]
2015-01-12 19:56:25 -05:00
Kevin Brown
ed24a51ea3 Updated docs to use the Select2 GitHub organization
Documentation will now be at https://select2.github.io
2015-01-02 21:12:41 -05:00
Kevin Brown
ad94b6faba Added jQuery.mousewheel support
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
2015-01-02 20:32:14 -05:00
Kevin Brown
593a357886 Automatically push docs updates 2014-11-25 16:23:53 -05:00
Kevin Brown
81db43fa99 Extracted the original positioning out
With this change, any instances overriding the dropdown is
required to decorate it with the positioning module.
2014-11-25 15:59:35 -05:00
Kevin Brown
12de3c2b5e Set up the GitHub Pages command
Now we can synchronize GitHub Pages with the docs in the master
branch quickly and easily.
2014-11-25 08:36:01 -05:00
Kevin Brown
c7e8f81595 Added Spanish translation and fixed the example 2014-11-05 11:25:41 -05:00
Kevin Brown
78bcd6e831 Added docs build for grunt 2014-11-03 19:09:38 -05:00
Kevin Brown
20fcaa4449 Start working on translations
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.
2014-10-31 22:24:59 -04:00
Kevin Brown
afbf30d09a Wrap JS
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.
2014-10-31 20:15:17 -04:00
Kevin Brown
8e70642b87 Lint the Gruntfile 2014-10-31 19:12:27 -04:00
Kevin Brown
27ac50a854 Fixed problems with non-string ids
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.
2014-10-21 21:43:59 -04:00
Kevin Brown
d386849c1f Started building out the examples
This also adds the `select2` function back to jQuery, so you can
still initialize Select2 using the old syntax.
2014-10-21 21:43:58 -04:00
Kevin Brown
c74aeeb5c8 Start working on docs 2014-10-21 21:43:58 -04:00
Kevin Brown
aebc7ce0d2 Added very basic jshint config 2014-10-21 21:43:57 -04:00
Kevin Brown
792133ce5c Added Utils.Decorate and tests
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.
2014-10-21 21:43:56 -04:00
Kevin Brown
06e195b025 Work on the AMD scaffolding
This will make it far easier to ensure that components are in their
own modules as well as make it possible to have custom builds of
Select2.
2014-10-21 21:43:56 -04:00