vendor/assets/javascripts/select2-full.js in select2-rails-4.0.7 vs vendor/assets/javascripts/select2-full.js in select2-rails-4.0.8
- old
+ new
@@ -1,7 +1,7 @@
/*!
- * Select2 4.0.7
+ * Select2 4.0.8
* https://select2.github.io
*
* Released under the MIT license
* https://github.com/select2/select2/blob/master/LICENSE.md
*/
@@ -1012,11 +1012,16 @@
var attrs = {
'role': 'treeitem',
'aria-selected': 'false'
};
- if (data.disabled) {
+ var matches = window.Element.prototype.matches ||
+ window.Element.prototype.msMatchesSelector ||
+ window.Element.prototype.webkitMatchesSelector;
+
+ if ((data.element != null && matches.call(data.element, ':disabled')) ||
+ (data.element == null && data.disabled)) {
delete attrs['aria-selected'];
attrs['aria-disabled'] = 'true';
}
if (data.id == null) {
@@ -1475,14 +1480,12 @@
// When the dropdown is closed, aria-expanded="false"
self.$selection.attr('aria-expanded', 'false');
self.$selection.removeAttr('aria-activedescendant');
self.$selection.removeAttr('aria-owns');
- window.setTimeout(function () {
- self.$selection.focus();
- }, 0);
-
+ self.$selection.trigger('focus');
+
self._detachCloseHandler(container);
});
container.on('enable', function () {
self.$selection.attr('tabindex', self._tabindex);
@@ -1614,11 +1617,11 @@
// User exits the container
});
container.on('focus', function (evt) {
if (!container.isOpen()) {
- self.$selection.focus();
+ self.$selection.trigger('focus');
}
});
};
SingleSelection.prototype.clear = function () {
@@ -2107,17 +2110,11 @@
this.$selection.find('.select2-selection__rendered')
.append(this.$searchContainer);
this.resizeSearch();
if (searchHadFocus) {
- var isTagInput = this.$element.find('[data-select2-tag]').length;
- if (isTagInput) {
- // fix IE11 bug where tag input lost focus
- this.$element.focus();
- } else {
- this.$search.focus();
- }
+ this.$search.trigger('focus');
}
};
Search.prototype.handleSearch = function () {
this.resizeSearch();
@@ -3803,11 +3800,11 @@
if (tokenData.term !== params.term) {
// Replace the search term if we have the search box
if (this.$search.length) {
this.$search.val(tokenData.term);
- this.$search.focus();
+ this.$search.trigger('focus');
}
params.term = tokenData.term;
}
@@ -4049,27 +4046,27 @@
});
container.on('open', function () {
self.$search.attr('tabindex', 0);
- self.$search.focus();
+ self.$search.trigger('focus');
window.setTimeout(function () {
- self.$search.focus();
+ self.$search.trigger('focus');
}, 0);
});
container.on('close', function () {
self.$search.attr('tabindex', -1);
self.$search.val('');
- self.$search.blur();
+ self.$search.trigger('blur');
});
container.on('focus', function () {
if (!container.isOpen()) {
- self.$search.focus();
+ self.$search.trigger('focus');
}
});
container.on('results:all', function (params) {
if (params.query.term == null || params.query.term === '') {
@@ -4164,10 +4161,11 @@
decorated.call(this, data);
if (this.showLoadingMore(data)) {
this.$results.append(this.$loadingMore);
+ this.loadMoreIfNeeded();
}
};
InfiniteScroll.prototype.bind = function (decorated, container, $container) {
var self = this;
@@ -4182,29 +4180,31 @@
container.on('query:append', function (params) {
self.lastParams = params;
self.loading = true;
});
- this.$results.on('scroll', function () {
- var isLoadMoreVisible = $.contains(
- document.documentElement,
- self.$loadingMore[0]
- );
+ this.$results.on('scroll', this.loadMoreIfNeeded.bind(this));
+ };
- if (self.loading || !isLoadMoreVisible) {
- return;
- }
+ InfiniteScroll.prototype.loadMoreIfNeeded = function () {
+ var isLoadMoreVisible = $.contains(
+ document.documentElement,
+ this.$loadingMore[0]
+ );
- var currentOffset = self.$results.offset().top +
- self.$results.outerHeight(false);
- var loadingMoreOffset = self.$loadingMore.offset().top +
- self.$loadingMore.outerHeight(false);
+ if (this.loading || !isLoadMoreVisible) {
+ return;
+ }
- if (currentOffset + 50 >= loadingMoreOffset) {
- self.loadMore();
- }
- });
+ var currentOffset = this.$results.offset().top +
+ this.$results.outerHeight(false);
+ var loadingMoreOffset = this.$loadingMore.offset().top +
+ this.$loadingMore.outerHeight(false);
+
+ if (currentOffset + 50 >= loadingMoreOffset) {
+ this.loadMore();
+ }
};
InfiniteScroll.prototype.loadMore = function () {
this.loading = true;
@@ -5339,9 +5339,15 @@
return matches[1];
}
}
return null;
+ }
+
+ if (method == 'computedstyle') {
+ var computedStyle = window.getComputedStyle($element[0]);
+
+ return computedStyle.width;
}
return method;
};