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

1724 Commits

Author SHA1 Message Date
Kevin Brown
a9f6d64b72 Added .dataset fallback for jQuery 1.x
As we have established already, jQuery 1.x does not correctly handle
`data-*` attributes where there are multiple dashes.  This makes it
so we can still handle nested options when working with jQuery 1.x
by using the `.dataset` option that is supported by all major
browsers as well as IE 11+.

Browser support tables for the `.dataset` attributes can be found at
http://caniuse.com/dataset

A notice was already added to the documentation about this in
caeb0ec9b7.

The related ticket in the jQuery repository about this issue is
https://github.com/jquery/jquery/issues/2070.

This closes https://github.com/select2/select2/issues/2969.
2015-02-24 14:42:27 -05:00
Kevin Brown
dc2f6d451a Fix example code for the old matcher 2015-02-24 14:18:07 -05:00
Kevin Brown
f367185a8a Merge pull request #3056 from harshadsabne/select2-ng
Create hi.js
2015-02-24 09:02:23 -05:00
Harshad Sabne
e88440cab3 Create hi.js
Added i18n for Hindi language.
2015-02-20 12:02:25 +05:30
Kevin Brown
e6f249f66d Fixed Array.indexOf in i18n/uk.js 2015-02-17 12:47:48 -05:00
th3byrdm4n
07c4db1de2 replaced usages of [].indexOf with $.inArray()
X-Browser Compatibility (and performance) reasons.

Signed-off-by: Kevin Brown <kevin@kevinbrown.in>
2015-02-17 12:41:36 -05:00
th3byrdm4n
e75cd78c51 word-wrap: nowrap styling
Added `word-wrap: nowrap` to places it wasn’t explicit.

Signed-off-by: Kevin Brown <kevin@kevinbrown.in>
2015-02-17 12:41:25 -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
4271b10531 Add docs for three more options
This adds documentation for the follow options

- `minimumInputLength`
- `maximumInputLength`
- `minimumResultsForSearch`

This closes https://github.com/select2/select2/issues/3035.
2015-02-14 16:53:17 -05:00
Flávio
86c23c0f5c Create pt.js
European Portuguese Translation
2015-02-14 12:16:18 -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
3d013020ae Improved focus detection and key handling
Now the focus of the selection container is correctly monitored so
there is a consistent 1px black border on the default theme whenever
it is focused.  This requires `focusin`/`focusout` support, which is
supported by all major browsers except for Firefox.  In Firefox, the
old focus appearance is still consistent and has not been broken
by this update.

The key handling has also been improved such that some of the logic
detection that was previously done within the search handlers for
multiple select searches is now pushed back to the base selection.

This closes https://github.com/select2/select2/issues/2995.
2015-02-14 00:37:51 -05:00
Kevin Brown
b382fdca9c Clone the tabindex from the original select
Previously Select2 would assume that the tab index for the
`<select>` was `0`, which is the browser default.  Now Select2 will
clone the tab index from the original element, and correctly restore
it when it is destroyed or disabled/enabled.

This closes https://github.com/select2/select2/issues/3031.
2015-02-13 23:57:18 -05:00
Kevin Brown
ef5c88a6f6 Add box-sizing to another area
This closes https://github.com/select2/select2/issues/3029.
2015-02-13 23:37:29 -05:00
Kevin Brown
72e5c2a50d Combine tests into common files
This groups tests into common HTML files so they can be run more
quickly. This also reduces the number of Sauce Labs instances that
have to be run, as one instance was previously spun up for each
file.
2015-02-13 23:29:56 -05:00
Kevin Brown
a2a99e64ba Merge pull request #3012 from burnb/select2-ng
fix - add event listener for opera 12
2015-02-13 22:58:41 -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
e383cb573c Build zh-CN 2015-02-13 22:25:45 -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
d51570e1fe Merge pull request #3041 from minddust/fix-typos
Fix typos
2015-02-13 09:21:16 -05:00
Kevin Brown
05f5a1b4b5 Merge pull request #3042 from fantasticfears/patch-1
Create zh-CN.js
2015-02-13 09:18:23 -05:00
Erick Guan
c3c5f360fc Create zh-CN.js 2015-02-13 19:56:40 +08:00
Stephan Groß
a5532ee8a8 Fix typos 2015-02-13 11:36:21 +01:00
Kevin Brown
c2326209c2 Copy option title to results and selection
This copies the `title` attribute of `<option>` and `<optgroup>`
tags to the `title` attribute of the options within the results
list and the selection when it is rendered.

For single selections, the `text` property on the data objects will
be used if the `title` attribute is not present, which will allow
for long names to still be viewable if they overflow the selection
container.

This also fixes a potential issue in browsers that did not support
the non-standard `innerText` property on DOM nodes.  As the
`textContent` property is the standard, and it is supported on
IE 9+, we try to set that before falling back to `innerText`.

This closes https://github.com/select2/select2/issues/2530.
This closes https://github.com/select2/select2/pull/2889.
2015-02-09 20:55:35 -05:00
Kevin Brown
61a231d868 Added back select2("data")
In the past, `select2("data")` allowed you to retrieve the currently
selected data objects.  Read-only support has been added back for
this, which maps to the `current` method of the data adapter.  This
will only work for data adapters which allow for the synchronous
retrieval of the current data, which is the case for all of the
default data adapters.

You could also previously overwrite the currently selected data
objects by passing in an argument to `select2("data")`.  As this
dealt directly with the internals, and required a considerable
amount of work to synchronize it, it has been removed.  A warning
will now be triggered if the method is called with additional
elements, and the `val` method should be used instead.

This closes https://github.com/select2/select2/issues/2938.
2015-02-09 20:27:43 -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
9d4ec4f85b Add templating documentation
This adds documentation for the `templateResult` and
`templateSelection` options.  The fact that placeholders and
custom messages are templated was noted, although most people
should be using the standard `text` property that they provide
anyway.  This fixes the templating link provided in the release
announcement to link to the correct location in the documentation.

This also adds support for the `templateSelection` function to
return a DocumentFragment or jQuery compatible object to be
passed back and rendered.

This closes https://github.com/select2/select2/issues/3005.
This closes https://github.com/select2/select2/issues/3019.
2015-02-09 19:27:10 -05:00
Kevin Brown
c9a8508a39 Add back closeOnSelect option
The `closeOnSelect` option was previously used to control whether
or not the dropdown was closed when an option was selected.  This
could be simulated by triggering the `open` event after the `close`
event was received, but it makes sense to abstract it out into a
decorator.

This also adds support for not closing the dropdown when the control
key is being held.  This is useful when multiple options need to be
selected in quick succession, so the dropdown does not have to be
reopened.

This also adds documentation that covers both changes.

This closes https://github.com/select2/select2/pull/2735.
This closes https://github.com/select2/select2/issues/3017.
2015-02-09 18:54:19 -05:00
Kevin Brown
caeb0ec9b7 Add jQuery 1.x data attribute note
This adds a note about how nested data attributes do not work in
jQuery 1.x due to a bug with the `$.fn.data` method.

This is for https://github.com/select2/select2/issues/2969.
2015-02-09 17:43:16 -05:00
Kevin Brown
8aca7a4085 Added templating example
This also fixes the case where `templateResult` does not return a
string, where it will fall back to jQuery to set the value of the
option.  This allows for the `templateResult` function to return a
jQuery or DOM element that contains the templated data.

Just like with the translation methods, only strings returned from
`templateResult` will be escaped.

The old flag icons have been transferred from the old repository to
the documentation, for use in the templates.  Unfortunately I cannot
find a license for them, but I suspect a license isn't actually
needed considering the state flags are public.

This closes https://github.com/select2/select2/issues/3005.
This closes https://github.com/select2/select2/issues/818.
2015-02-09 17:35:40 -05:00
Kevin Brown
473267404a Fix CSS text wrapping for single selects
Select2 previously had an issue displaying the text of long values
as it was not correctly wrapping the text.  This was because the
browser did not know that it couldn't wrap at whitespace, which
has been fixed.

Now Select2 should properly display an ellipsis for large text
values instead of overflowing.

This closes https://github.com/select2/select2/issues/2984.
2015-02-09 15:58:16 -05:00
Kevin Brown
0c0e2527fa Autofocus search field in multiple select
In a single select, the search field is automatically focused when
the select is opened. This also applied to multiple selects, but
this was causing issues because the container was automatically
focused when the dropdown was closed.

This makes a change such that the search field is automatically
focused when the dropdown is closed.

This closes https://github.com/select2/select2/issues/2995.
2015-02-09 15:43:46 -05:00
Kevin Brown
4dda5e7a74 Hide the search clear icon in webkit
The search box previously displayed a clear icon on the far right
side in webkit-based browsers, specifically Chrome and Safari. This
hides the clear icon in those browsers, and also fixes a slight
sizing issue, so it should no longer be displayed.

This also disables autocorrect, autocompleted, as well as a few
other automatic search corrections on the field, so mobile devices
should have a better experience.

This closes https://github.com/select2/select2/issues/3018.
2015-02-09 15:29:28 -05:00
Kevin Brown
b1c016584b Merge pull request #3024 from th3byrdm4n/select2-ng
IE7/8 Compatability fixes
2015-02-08 13:32:46 -05:00
th3byrdm4n
5a825e0cb3 IE7/8 Compatability fixes
[].indexOf() isn’t supported in old IE. Utilizing jQuery’s $.inArray()
allows for Select2 to work in IE compatibility mode.
2015-02-08 07:29:52 -10:00
Kevin Brown
a08179f481 Merge pull request #3021 from jordigg/select2-ng
Added Catalan language
2015-02-07 13:50:14 -05:00
Jordi Garcia
dfbac71c39 Updated language name on comments 2015-02-07 19:07:21 +01:00
Jordi Garcia
0b9fdded01 Added Catalan language 2015-02-07 18:54:02 +01:00
Kevin Brown
bcc43139fd Merge pull request #3006 from WouterSioen/patch-1
Add rel=stylesheet to the cdn link.

Closes https://github.com/select2/select2/issues/3020.
2015-02-07 12:51:43 -05:00
burnb
e3b5f39695 fix long line for ci check 2015-02-07 19:33:48 +04:00
burnb
557f655c86 remove event listener on destroy 2015-02-07 19:16:34 +04:00
Kevin Brown
7155adc718 Split out formatRepo and formatRepoSelection
This splits out the two templating functions that are referenced in
the documentation. The two functions were previously available in
the source code, but they were not named with the method names that
the documentation referred to.

This closes https://github.com/select2/select2/issues/2993.
2015-02-06 20:08:28 -05:00
Kevin Brown
1349579192 Respect -1 with minimumResultsForSearch
In past versions of Select2, supplying a value less than zero to
`minimumResultsForSearch` acted the same as providing a high value,
such as `Infinity`.  This corrects the regression by mapping anything
less than zero to the value `Infinity`.

This closes https://github.com/select2/select2/issues/2994.
2015-02-06 19:54:36 -05:00
Kevin Brown
0f7a37b2d6 Pass through non-strings in escapeMarkup
It is assumed that DOM elements or related objects will have been
escaped before they are passed back from templating functions. As
strings are typically blinding concatenated, like in our defaults,
it makes sense to escape the markup within them.

This is related to https://github.com/select2/select2/issues/3005.
2015-02-06 19:45:10 -05:00
Kevin Brown
631ae06c8d Fix broken Placeholder.js links
It appears as though GitHub has stopped serving the Placeholder.js
GitHub Pages site.  This broke placeholder support on older versions
of IE in the documentation and broke the link we had to the
polyfill.  Since the repository is still online, and the
documentation should work without an internet connection, the
JavaScript files have been pulled into the documentation folder.
2015-02-06 19:34:48 -05:00
Kevin Brown
1766e31447 Handle translations like template options
Translations will now be passed through `escapeMarkup` and injected
into the results messages as HTML just like the templating options
for the the results and selections.  This fixes the regression from
3.x where the old formatters always supported HTML.

This closes https://github.com/select2/select2/issues/3008.
2015-02-06 19:29:18 -05:00
Kevin Brown
78b6faf13e Check that allowClear is used with placeholder
The `allowClear` option may not work as intended if a placeholder
is not used. This is becaise the placeholder holds the value that
the `<select>` should be reset to when the `x` is hit.

An error is now properly raised in the console when Select2 detects
that the `allowClear` option is used without the `placeholder`
option.

This closes https://github.com/select2/select2/issues/3016.
2015-02-06 19:20:18 -05:00
Kevin Brown
7a8500f198 Merge pull request #3010 from yanickrochon/select2-ng
Fixing errors in FR locale. Added missing pl/pt-BR locales in dist.
2015-02-06 09:44:18 -05:00