Skip to content

Commit 5137e45

Browse files
committed
version 4.0.8
1 parent f9b2de0 commit 5137e45

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+203
-195
lines changed

lib/select2-rails/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Select2
22
module Rails
3-
VERSION = '4.0.7'
3+
VERSION = '4.0.8'
44
end
55
end

vendor/assets/javascripts/select2-full.js

+41-35
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* Select2 4.0.7
2+
* Select2 4.0.8
33
* https://select2.github.io
44
*
55
* Released under the MIT license
@@ -1014,7 +1014,12 @@ S2.define('select2/results',[
10141014
'aria-selected': 'false'
10151015
};
10161016

1017-
if (data.disabled) {
1017+
var matches = window.Element.prototype.matches ||
1018+
window.Element.prototype.msMatchesSelector ||
1019+
window.Element.prototype.webkitMatchesSelector;
1020+
1021+
if ((data.element != null && matches.call(data.element, ':disabled')) ||
1022+
(data.element == null && data.disabled)) {
10181023
delete attrs['aria-selected'];
10191024
attrs['aria-disabled'] = 'true';
10201025
}
@@ -1477,10 +1482,8 @@ S2.define('select2/selection/base',[
14771482
self.$selection.removeAttr('aria-activedescendant');
14781483
self.$selection.removeAttr('aria-owns');
14791484

1480-
window.setTimeout(function () {
1481-
self.$selection.focus();
1482-
}, 0);
1483-
1485+
self.$selection.trigger('focus');
1486+
14841487
self._detachCloseHandler(container);
14851488
});
14861489

@@ -1616,7 +1619,7 @@ S2.define('select2/selection/single',[
16161619

16171620
container.on('focus', function (evt) {
16181621
if (!container.isOpen()) {
1619-
self.$selection.focus();
1622+
self.$selection.trigger('focus');
16201623
}
16211624
});
16221625
};
@@ -2109,13 +2112,7 @@ S2.define('select2/selection/search',[
21092112

21102113
this.resizeSearch();
21112114
if (searchHadFocus) {
2112-
var isTagInput = this.$element.find('[data-select2-tag]').length;
2113-
if (isTagInput) {
2114-
// fix IE11 bug where tag input lost focus
2115-
this.$element.focus();
2116-
} else {
2117-
this.$search.focus();
2118-
}
2115+
this.$search.trigger('focus');
21192116
}
21202117
};
21212118

@@ -3805,7 +3802,7 @@ S2.define('select2/data/tokenizer',[
38053802
// Replace the search term if we have the search box
38063803
if (this.$search.length) {
38073804
this.$search.val(tokenData.term);
3808-
this.$search.focus();
3805+
this.$search.trigger('focus');
38093806
}
38103807

38113808
params.term = tokenData.term;
@@ -4051,23 +4048,23 @@ S2.define('select2/dropdown/search',[
40514048
container.on('open', function () {
40524049
self.$search.attr('tabindex', 0);
40534050

4054-
self.$search.focus();
4051+
self.$search.trigger('focus');
40554052

40564053
window.setTimeout(function () {
4057-
self.$search.focus();
4054+
self.$search.trigger('focus');
40584055
}, 0);
40594056
});
40604057

40614058
container.on('close', function () {
40624059
self.$search.attr('tabindex', -1);
40634060

40644061
self.$search.val('');
4065-
self.$search.blur();
4062+
self.$search.trigger('blur');
40664063
});
40674064

40684065
container.on('focus', function () {
40694066
if (!container.isOpen()) {
4070-
self.$search.focus();
4067+
self.$search.trigger('focus');
40714068
}
40724069
});
40734070

@@ -4166,6 +4163,7 @@ S2.define('select2/dropdown/infiniteScroll',[
41664163

41674164
if (this.showLoadingMore(data)) {
41684165
this.$results.append(this.$loadingMore);
4166+
this.loadMoreIfNeeded();
41694167
}
41704168
};
41714169

@@ -4184,25 +4182,27 @@ S2.define('select2/dropdown/infiniteScroll',[
41844182
self.loading = true;
41854183
});
41864184

4187-
this.$results.on('scroll', function () {
4188-
var isLoadMoreVisible = $.contains(
4189-
document.documentElement,
4190-
self.$loadingMore[0]
4191-
);
4185+
this.$results.on('scroll', this.loadMoreIfNeeded.bind(this));
4186+
};
41924187

4193-
if (self.loading || !isLoadMoreVisible) {
4194-
return;
4195-
}
4188+
InfiniteScroll.prototype.loadMoreIfNeeded = function () {
4189+
var isLoadMoreVisible = $.contains(
4190+
document.documentElement,
4191+
this.$loadingMore[0]
4192+
);
41964193

4197-
var currentOffset = self.$results.offset().top +
4198-
self.$results.outerHeight(false);
4199-
var loadingMoreOffset = self.$loadingMore.offset().top +
4200-
self.$loadingMore.outerHeight(false);
4194+
if (this.loading || !isLoadMoreVisible) {
4195+
return;
4196+
}
42014197

4202-
if (currentOffset + 50 >= loadingMoreOffset) {
4203-
self.loadMore();
4204-
}
4205-
});
4198+
var currentOffset = this.$results.offset().top +
4199+
this.$results.outerHeight(false);
4200+
var loadingMoreOffset = this.$loadingMore.offset().top +
4201+
this.$loadingMore.outerHeight(false);
4202+
4203+
if (currentOffset + 50 >= loadingMoreOffset) {
4204+
this.loadMore();
4205+
}
42064206
};
42074207

42084208
InfiniteScroll.prototype.loadMore = function () {
@@ -5343,6 +5343,12 @@ S2.define('select2/core',[
53435343
return null;
53445344
}
53455345

5346+
if (method == 'computedstyle') {
5347+
var computedStyle = window.getComputedStyle($element[0]);
5348+
5349+
return computedStyle.width;
5350+
}
5351+
53465352
return method;
53475353
};
53485354

vendor/assets/javascripts/select2.js

+41-35
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* Select2 4.0.7
2+
* Select2 4.0.8
33
* https://select2.github.io
44
*
55
* Released under the MIT license
@@ -1014,7 +1014,12 @@ S2.define('select2/results',[
10141014
'aria-selected': 'false'
10151015
};
10161016

1017-
if (data.disabled) {
1017+
var matches = window.Element.prototype.matches ||
1018+
window.Element.prototype.msMatchesSelector ||
1019+
window.Element.prototype.webkitMatchesSelector;
1020+
1021+
if ((data.element != null && matches.call(data.element, ':disabled')) ||
1022+
(data.element == null && data.disabled)) {
10181023
delete attrs['aria-selected'];
10191024
attrs['aria-disabled'] = 'true';
10201025
}
@@ -1477,10 +1482,8 @@ S2.define('select2/selection/base',[
14771482
self.$selection.removeAttr('aria-activedescendant');
14781483
self.$selection.removeAttr('aria-owns');
14791484

1480-
window.setTimeout(function () {
1481-
self.$selection.focus();
1482-
}, 0);
1483-
1485+
self.$selection.trigger('focus');
1486+
14841487
self._detachCloseHandler(container);
14851488
});
14861489

@@ -1616,7 +1619,7 @@ S2.define('select2/selection/single',[
16161619

16171620
container.on('focus', function (evt) {
16181621
if (!container.isOpen()) {
1619-
self.$selection.focus();
1622+
self.$selection.trigger('focus');
16201623
}
16211624
});
16221625
};
@@ -2109,13 +2112,7 @@ S2.define('select2/selection/search',[
21092112

21102113
this.resizeSearch();
21112114
if (searchHadFocus) {
2112-
var isTagInput = this.$element.find('[data-select2-tag]').length;
2113-
if (isTagInput) {
2114-
// fix IE11 bug where tag input lost focus
2115-
this.$element.focus();
2116-
} else {
2117-
this.$search.focus();
2118-
}
2115+
this.$search.trigger('focus');
21192116
}
21202117
};
21212118

@@ -3805,7 +3802,7 @@ S2.define('select2/data/tokenizer',[
38053802
// Replace the search term if we have the search box
38063803
if (this.$search.length) {
38073804
this.$search.val(tokenData.term);
3808-
this.$search.focus();
3805+
this.$search.trigger('focus');
38093806
}
38103807

38113808
params.term = tokenData.term;
@@ -4051,23 +4048,23 @@ S2.define('select2/dropdown/search',[
40514048
container.on('open', function () {
40524049
self.$search.attr('tabindex', 0);
40534050

4054-
self.$search.focus();
4051+
self.$search.trigger('focus');
40554052

40564053
window.setTimeout(function () {
4057-
self.$search.focus();
4054+
self.$search.trigger('focus');
40584055
}, 0);
40594056
});
40604057

40614058
container.on('close', function () {
40624059
self.$search.attr('tabindex', -1);
40634060

40644061
self.$search.val('');
4065-
self.$search.blur();
4062+
self.$search.trigger('blur');
40664063
});
40674064

40684065
container.on('focus', function () {
40694066
if (!container.isOpen()) {
4070-
self.$search.focus();
4067+
self.$search.trigger('focus');
40714068
}
40724069
});
40734070

@@ -4166,6 +4163,7 @@ S2.define('select2/dropdown/infiniteScroll',[
41664163

41674164
if (this.showLoadingMore(data)) {
41684165
this.$results.append(this.$loadingMore);
4166+
this.loadMoreIfNeeded();
41694167
}
41704168
};
41714169

@@ -4184,25 +4182,27 @@ S2.define('select2/dropdown/infiniteScroll',[
41844182
self.loading = true;
41854183
});
41864184

4187-
this.$results.on('scroll', function () {
4188-
var isLoadMoreVisible = $.contains(
4189-
document.documentElement,
4190-
self.$loadingMore[0]
4191-
);
4185+
this.$results.on('scroll', this.loadMoreIfNeeded.bind(this));
4186+
};
41924187

4193-
if (self.loading || !isLoadMoreVisible) {
4194-
return;
4195-
}
4188+
InfiniteScroll.prototype.loadMoreIfNeeded = function () {
4189+
var isLoadMoreVisible = $.contains(
4190+
document.documentElement,
4191+
this.$loadingMore[0]
4192+
);
41964193

4197-
var currentOffset = self.$results.offset().top +
4198-
self.$results.outerHeight(false);
4199-
var loadingMoreOffset = self.$loadingMore.offset().top +
4200-
self.$loadingMore.outerHeight(false);
4194+
if (this.loading || !isLoadMoreVisible) {
4195+
return;
4196+
}
42014197

4202-
if (currentOffset + 50 >= loadingMoreOffset) {
4203-
self.loadMore();
4204-
}
4205-
});
4198+
var currentOffset = this.$results.offset().top +
4199+
this.$results.outerHeight(false);
4200+
var loadingMoreOffset = this.$loadingMore.offset().top +
4201+
this.$loadingMore.outerHeight(false);
4202+
4203+
if (currentOffset + 50 >= loadingMoreOffset) {
4204+
this.loadMore();
4205+
}
42064206
};
42074207

42084208
InfiniteScroll.prototype.loadMore = function () {
@@ -5343,6 +5343,12 @@ S2.define('select2/core',[
53435343
return null;
53445344
}
53455345

5346+
if (method == 'computedstyle') {
5347+
var computedStyle = window.getComputedStyle($element[0]);
5348+
5349+
return computedStyle.width;
5350+
}
5351+
53465352
return method;
53475353
};
53485354

vendor/assets/javascripts/select2_locale_af.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/assets/javascripts/select2_locale_ar.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/assets/javascripts/select2_locale_az.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/assets/javascripts/select2_locale_bg.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/assets/javascripts/select2_locale_bn.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)