/*!
- * Select2 4.0.2
+ * Select2 4.0.1
* https://select2.github.io
*
* Released under the MIT license
this.$results.on('mousewheel', function (e) {
var top = self.$results.scrollTop();
- var bottom = self.$results.get(0).scrollHeight - top + e.deltaY;
+ var bottom = (
+ self.$results.get(0).scrollHeight -
+ self.$results.scrollTop() +
+ e.deltaY
+ );
var isAtTop = e.deltaY > 0 && top - e.deltaY <= 0;
var isAtBottom = e.deltaY < 0 && bottom <= self.$results.height();
var $existingOption = $existing.filter(onlyItem(item));
var existingData = this.item($existingOption);
- var newData = $.extend(true, {}, item, existingData);
+ var newData = $.extend(true, {}, existingData, item);
var $newOption = this.option(newData);
callback(results);
}, function () {
- self.trigger('results:message', {
- message: 'errorLoading'
- });
+ // TODO: Handle AJAX errors
});
self._request = $request;
this.createTag = createTag;
}
- var insertTag = options.get('insertTag');
-
- if (insertTag !== undefined) {
- this.insertTag = insertTag;
- }
-
decorated.call(this, $element, options);
if ($.isArray(tags)) {
var newDirection = null;
+ var position = this.$container.position();
var offset = this.$container.offset();
offset.bottom = offset.top + this.$container.outerHeight(false);
top: container.bottom
};
- // Determine what the parent element is to use for calciulating the offset
- var $offsetParent = this.$dropdownParent;
+ // Fix positioning with static parents
+ if (this.$dropdownParent[0].style.position !== 'static') {
+ var parentOffset = this.$dropdownParent.offset();
- // For statically positoned elements, we need to get the element
- // that is determining the offset
- if ($offsetParent.css('position') === 'static') {
- $offsetParent = $offsetParent.offsetParent();
+ css.top -= parentOffset.top;
+ css.left -= parentOffset.left;
}
- var parentOffset = $offsetParent.offset();
-
- css.top -= parentOffset.top;
- css.left -= parentOffset.left;
-
if (!isCurrentlyAbove && !isCurrentlyBelow) {
newDirection = 'below';
}
}
Defaults.prototype.apply = function (options) {
- options = $.extend(true, {}, this.defaults, options);
+ options = $.extend({}, this.defaults, options);
if (options.dataAdapter == null) {
if (options.ajax != null) {
id = Utils.generateChars(4);
}
- id = id.replace(/(:|\.|\[|\]|,)/g, '');
id = 'select2-' + id;
return id;