|
@@ -1,5 +1,5 @@
|
|
/*!
|
|
/*!
|
|
- * Select2 4.1.0-beta.1
|
|
|
|
|
|
+ * Select2 4.1.0-rc.0
|
|
* https://select2.github.io
|
|
* https://select2.github.io
|
|
*
|
|
*
|
|
* Released under the MIT license
|
|
* Released under the MIT license
|
|
@@ -1085,7 +1085,8 @@ S2.define('select2/results',[
|
|
}
|
|
}
|
|
|
|
|
|
var $childrenContainer = $('<ul></ul>', {
|
|
var $childrenContainer = $('<ul></ul>', {
|
|
- 'class': 'select2-results__options select2-results__options--nested'
|
|
|
|
|
|
+ 'class': 'select2-results__options select2-results__options--nested',
|
|
|
|
+ 'role': 'none'
|
|
});
|
|
});
|
|
|
|
|
|
$childrenContainer.append($children);
|
|
$childrenContainer.append($children);
|
|
@@ -1636,6 +1637,7 @@ S2.define('select2/selection/single',[
|
|
.attr('role', 'textbox')
|
|
.attr('role', 'textbox')
|
|
.attr('aria-readonly', 'true');
|
|
.attr('aria-readonly', 'true');
|
|
this.$selection.attr('aria-labelledby', id);
|
|
this.$selection.attr('aria-labelledby', id);
|
|
|
|
+ this.$selection.attr('aria-controls', id);
|
|
|
|
|
|
this.$selection.on('mousedown', function (evt) {
|
|
this.$selection.on('mousedown', function (evt) {
|
|
// Only respond to left clicks
|
|
// Only respond to left clicks
|
|
@@ -1888,6 +1890,15 @@ S2.define('select2/selection/placeholder',[
|
|
$placeholder[0].classList.add('select2-selection__placeholder');
|
|
$placeholder[0].classList.add('select2-selection__placeholder');
|
|
$placeholder[0].classList.remove('select2-selection__choice');
|
|
$placeholder[0].classList.remove('select2-selection__choice');
|
|
|
|
|
|
|
|
+ var placeholderTitle = placeholder.title ||
|
|
|
|
+ placeholder.text ||
|
|
|
|
+ $placeholder.text();
|
|
|
|
+
|
|
|
|
+ this.$selection.find('.select2-selection__rendered').attr(
|
|
|
|
+ 'title',
|
|
|
|
+ placeholderTitle
|
|
|
|
+ );
|
|
|
|
+
|
|
return $placeholder;
|
|
return $placeholder;
|
|
};
|
|
};
|
|
|
|
|
|
@@ -2006,6 +2017,7 @@ S2.define('select2/selection/allowClear',[
|
|
decorated.call(this, data);
|
|
decorated.call(this, data);
|
|
|
|
|
|
this.$selection.find('.select2-selection__clear').remove();
|
|
this.$selection.find('.select2-selection__clear').remove();
|
|
|
|
+ this.$selection[0].classList.remove('select2-selection--clearable');
|
|
|
|
|
|
if (this.$selection.find('.select2-selection__placeholder').length > 0 ||
|
|
if (this.$selection.find('.select2-selection__placeholder').length > 0 ||
|
|
data.length === 0) {
|
|
data.length === 0) {
|
|
@@ -2028,6 +2040,7 @@ S2.define('select2/selection/allowClear',[
|
|
Utils.StoreData($remove[0], 'data', data);
|
|
Utils.StoreData($remove[0], 'data', data);
|
|
|
|
|
|
this.$selection.prepend($remove);
|
|
this.$selection.prepend($remove);
|
|
|
|
+ this.$selection[0].classList.add('select2-selection--clearable');
|
|
};
|
|
};
|
|
|
|
|
|
return AllowClear;
|
|
return AllowClear;
|
|
@@ -2043,18 +2056,22 @@ S2.define('select2/selection/search',[
|
|
}
|
|
}
|
|
|
|
|
|
Search.prototype.render = function (decorated) {
|
|
Search.prototype.render = function (decorated) {
|
|
|
|
+ var searchLabel = this.options.get('translations').get('search');
|
|
var $search = $(
|
|
var $search = $(
|
|
'<span class="select2-search select2-search--inline">' +
|
|
'<span class="select2-search select2-search--inline">' +
|
|
- '<input class="select2-search__field" type="search" tabindex="-1"' +
|
|
|
|
|
|
+ '<textarea class="select2-search__field"'+
|
|
|
|
+ ' type="search" tabindex="-1"' +
|
|
' autocorrect="off" autocapitalize="none"' +
|
|
' autocorrect="off" autocapitalize="none"' +
|
|
- ' spellcheck="false" role="searchbox" aria-autocomplete="list" />' +
|
|
|
|
|
|
+ ' spellcheck="false" role="searchbox" aria-autocomplete="list" >' +
|
|
|
|
+ '</textarea>' +
|
|
'</span>'
|
|
'</span>'
|
|
);
|
|
);
|
|
|
|
|
|
this.$searchContainer = $search;
|
|
this.$searchContainer = $search;
|
|
- this.$search = $search.find('input');
|
|
|
|
|
|
+ this.$search = $search.find('textarea');
|
|
|
|
|
|
this.$search.prop('autocomplete', this.options.get('autocomplete'));
|
|
this.$search.prop('autocomplete', this.options.get('autocomplete'));
|
|
|
|
+ this.$search.attr('aria-label', searchLabel());
|
|
|
|
|
|
var $rendered = decorated.call(this);
|
|
var $rendered = decorated.call(this);
|
|
|
|
|
|
@@ -3697,7 +3714,7 @@ S2.define('select2/data/ajax',[
|
|
|
|
|
|
if (this._request != null) {
|
|
if (this._request != null) {
|
|
// JSONP requests cannot always be aborted
|
|
// JSONP requests cannot always be aborted
|
|
- if ($.isFunction(this._request.abort)) {
|
|
|
|
|
|
+ if (typeof this._request.abort === 'function') {
|
|
this._request.abort();
|
|
this._request.abort();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -3841,7 +3858,7 @@ S2.define('select2/data/tags',[
|
|
|
|
|
|
if (tag != null) {
|
|
if (tag != null) {
|
|
var $option = self.option(tag);
|
|
var $option = self.option(tag);
|
|
- $option.attr('data-select2-tag', true);
|
|
|
|
|
|
+ $option.attr('data-select2-tag', 'true');
|
|
|
|
|
|
self.addOptions([$option]);
|
|
self.addOptions([$option]);
|
|
|
|
|
|
@@ -4177,6 +4194,7 @@ S2.define('select2/dropdown/search',[
|
|
|
|
|
|
Search.prototype.render = function (decorated) {
|
|
Search.prototype.render = function (decorated) {
|
|
var $rendered = decorated.call(this);
|
|
var $rendered = decorated.call(this);
|
|
|
|
+ var searchLabel = this.options.get('translations').get('search');
|
|
|
|
|
|
var $search = $(
|
|
var $search = $(
|
|
'<span class="select2-search select2-search--dropdown">' +
|
|
'<span class="select2-search select2-search--dropdown">' +
|
|
@@ -4190,6 +4208,7 @@ S2.define('select2/dropdown/search',[
|
|
this.$search = $search.find('input');
|
|
this.$search = $search.find('input');
|
|
|
|
|
|
this.$search.prop('autocomplete', this.options.get('autocomplete'));
|
|
this.$search.prop('autocomplete', this.options.get('autocomplete'));
|
|
|
|
+ this.$search.attr('aria-label', searchLabel());
|
|
|
|
|
|
$rendered.prepend($search);
|
|
$rendered.prepend($search);
|
|
|
|
|
|
@@ -4835,6 +4854,38 @@ S2.define('select2/dropdown/dropdownCss',[
|
|
return DropdownCSS;
|
|
return DropdownCSS;
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+S2.define('select2/dropdown/tagsSearchHighlight',[
|
|
|
|
+ '../utils'
|
|
|
|
+], function (Utils) {
|
|
|
|
+ function TagsSearchHighlight () { }
|
|
|
|
+
|
|
|
|
+ TagsSearchHighlight.prototype.highlightFirstItem = function (decorated) {
|
|
|
|
+ var $options = this.$results
|
|
|
|
+ .find(
|
|
|
|
+ '.select2-results__option--selectable' +
|
|
|
|
+ ':not(.select2-results__option--selected)'
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ if ($options.length > 0) {
|
|
|
|
+ var $firstOption = $options.first();
|
|
|
|
+ var data = Utils.GetData($firstOption[0], 'data');
|
|
|
|
+ var firstElement = data.element;
|
|
|
|
+
|
|
|
|
+ if (firstElement && firstElement.getAttribute) {
|
|
|
|
+ if (firstElement.getAttribute('data-select2-tag') === 'true') {
|
|
|
|
+ $firstOption.trigger('mouseenter');
|
|
|
|
+
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ decorated.call(this);
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ return TagsSearchHighlight;
|
|
|
|
+});
|
|
|
|
+
|
|
S2.define('select2/i18n/en',[],function () {
|
|
S2.define('select2/i18n/en',[],function () {
|
|
// English
|
|
// English
|
|
return {
|
|
return {
|
|
@@ -4882,6 +4933,9 @@ S2.define('select2/i18n/en',[],function () {
|
|
},
|
|
},
|
|
removeItem: function () {
|
|
removeItem: function () {
|
|
return 'Remove item';
|
|
return 'Remove item';
|
|
|
|
+ },
|
|
|
|
+ search: function() {
|
|
|
|
+ return 'Search';
|
|
}
|
|
}
|
|
};
|
|
};
|
|
});
|
|
});
|
|
@@ -4921,6 +4975,7 @@ S2.define('select2/defaults',[
|
|
'./dropdown/selectOnClose',
|
|
'./dropdown/selectOnClose',
|
|
'./dropdown/closeOnSelect',
|
|
'./dropdown/closeOnSelect',
|
|
'./dropdown/dropdownCss',
|
|
'./dropdown/dropdownCss',
|
|
|
|
+ './dropdown/tagsSearchHighlight',
|
|
|
|
|
|
'./i18n/en'
|
|
'./i18n/en'
|
|
], function ($,
|
|
], function ($,
|
|
@@ -4937,7 +4992,7 @@ S2.define('select2/defaults',[
|
|
|
|
|
|
Dropdown, DropdownSearch, HidePlaceholder, InfiniteScroll,
|
|
Dropdown, DropdownSearch, HidePlaceholder, InfiniteScroll,
|
|
AttachBody, MinimumResultsForSearch, SelectOnClose, CloseOnSelect,
|
|
AttachBody, MinimumResultsForSearch, SelectOnClose, CloseOnSelect,
|
|
- DropdownCSS,
|
|
|
|
|
|
+ DropdownCSS, TagsSearchHighlight,
|
|
|
|
|
|
EnglishTranslation) {
|
|
EnglishTranslation) {
|
|
function Defaults () {
|
|
function Defaults () {
|
|
@@ -5012,6 +5067,13 @@ S2.define('select2/defaults',[
|
|
SelectOnClose
|
|
SelectOnClose
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if (options.tags) {
|
|
|
|
+ options.resultsAdapter = Utils.Decorate(
|
|
|
|
+ options.resultsAdapter,
|
|
|
|
+ TagsSearchHighlight
|
|
|
|
+ );
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
if (options.dropdownAdapter == null) {
|
|
if (options.dropdownAdapter == null) {
|
|
@@ -5757,12 +5819,11 @@ S2.define('select2/core',[
|
|
var key = evt.which;
|
|
var key = evt.which;
|
|
|
|
|
|
if (self.isOpen()) {
|
|
if (self.isOpen()) {
|
|
- if (key === KEYS.ESC || key === KEYS.TAB ||
|
|
|
|
- (key === KEYS.UP && evt.altKey)) {
|
|
|
|
|
|
+ if (key === KEYS.ESC || (key === KEYS.UP && evt.altKey)) {
|
|
self.close(evt);
|
|
self.close(evt);
|
|
|
|
|
|
evt.preventDefault();
|
|
evt.preventDefault();
|
|
- } else if (key === KEYS.ENTER) {
|
|
|
|
|
|
+ } else if (key === KEYS.ENTER || key === KEYS.TAB) {
|
|
self.trigger('results:select', {});
|
|
self.trigger('results:select', {});
|
|
|
|
|
|
evt.preventDefault();
|
|
evt.preventDefault();
|
|
@@ -6009,6 +6070,7 @@ S2.define('select2/core',[
|
|
};
|
|
};
|
|
|
|
|
|
Select2.prototype.destroy = function () {
|
|
Select2.prototype.destroy = function () {
|
|
|
|
+ Utils.RemoveData(this.$container[0]);
|
|
this.$container.remove();
|
|
this.$container.remove();
|
|
|
|
|
|
this._observer.disconnect();
|
|
this._observer.disconnect();
|