Skip to content

Commit

Permalink
version 4.0.13
Browse files Browse the repository at this point in the history
  • Loading branch information
OpenCoderX committed Jun 28, 2020
1 parent c4d02d7 commit da64247
Show file tree
Hide file tree
Showing 62 changed files with 223 additions and 101 deletions.
2 changes: 1 addition & 1 deletion lib/select2-rails/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Select2
module Rails
VERSION = '4.0.12'
VERSION = '4.0.13'
end
end
105 changes: 83 additions & 22 deletions vendor/assets/javascripts/select2-full.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Select2 4.0.12
* Select2 4.0.13
* https://select2.github.io
*
* Released under the MIT license
Expand Down Expand Up @@ -1556,6 +1556,27 @@ S2.define('select2/selection/base',[
throw new Error('The `update` method must be defined in child classes.');
};

/**
* Helper method to abstract the "enabled" (not "disabled") state of this
* object.
*
* @return {true} if the instance is not disabled.
* @return {false} if the instance is disabled.
*/
BaseSelection.prototype.isEnabled = function () {
return !this.isDisabled();
};

/**
* Helper method to abstract the "disabled" state of this object.
*
* @return {true} if the disabled option is true.
* @return {false} if the disabled option is false.
*/
BaseSelection.prototype.isDisabled = function () {
return this.options.get('disabled');
};

return BaseSelection;
});

Expand Down Expand Up @@ -1706,7 +1727,7 @@ S2.define('select2/selection/multiple',[
'.select2-selection__choice__remove',
function (evt) {
// Ignore the event if it is disabled
if (self.options.get('disabled')) {
if (self.isDisabled()) {
return;
}

Expand Down Expand Up @@ -1867,7 +1888,7 @@ S2.define('select2/selection/allowClear',[

AllowClear.prototype._handleClear = function (_, evt) {
// Ignore the event if it is disabled
if (this.options.get('disabled')) {
if (this.isDisabled()) {
return;
}

Expand Down Expand Up @@ -1910,7 +1931,7 @@ S2.define('select2/selection/allowClear',[
}
}

this.$element.trigger('change');
this.$element.trigger('input').trigger('change');

this.trigger('toggle', {});
};
Expand All @@ -1933,7 +1954,7 @@ S2.define('select2/selection/allowClear',[
return;
}

var removeAll = this.options.get('translations').get('removeAllItems');
var removeAll = this.options.get('translations').get('removeAllItems');

var $remove = $(
'<span class="select2-selection__clear" title="' + removeAll() +'">' +
Expand Down Expand Up @@ -3201,7 +3222,7 @@ S2.define('select2/data/select',[
if ($(data.element).is('option')) {
data.element.selected = true;

this.$element.trigger('change');
this.$element.trigger('input').trigger('change');

return;
}
Expand All @@ -3222,13 +3243,13 @@ S2.define('select2/data/select',[
}

self.$element.val(val);
self.$element.trigger('change');
self.$element.trigger('input').trigger('change');
});
} else {
var val = data.id;

this.$element.val(val);
this.$element.trigger('change');
this.$element.trigger('input').trigger('change');
}
};

Expand All @@ -3244,7 +3265,7 @@ S2.define('select2/data/select',[
if ($(data.element).is('option')) {
data.element.selected = false;

this.$element.trigger('change');
this.$element.trigger('input').trigger('change');

return;
}
Expand All @@ -3262,7 +3283,7 @@ S2.define('select2/data/select',[

self.$element.val(val);

self.$element.trigger('change');
self.$element.trigger('input').trigger('change');
});
};

Expand Down Expand Up @@ -5545,8 +5566,8 @@ S2.define('select2/core',[

if (observer != null) {
this._observer = new observer(function (mutations) {
$.each(mutations, self._syncA);
$.each(mutations, self._syncS);
self._syncA();
self._syncS(null, mutations);
});
this._observer.observe(this.$element[0], {
attributes: true,
Expand Down Expand Up @@ -5668,7 +5689,7 @@ S2.define('select2/core',[
if (self.isOpen()) {
if (key === KEYS.ESC || key === KEYS.TAB ||
(key === KEYS.UP && evt.altKey)) {
self.close();
self.close(evt);

evt.preventDefault();
} else if (key === KEYS.ENTER) {
Expand Down Expand Up @@ -5702,7 +5723,7 @@ S2.define('select2/core',[
Select2.prototype._syncAttributes = function () {
this.options.set('disabled', this.$element.prop('disabled'));

if (this.options.get('disabled')) {
if (this.isDisabled()) {
if (this.isOpen()) {
this.close();
}
Expand All @@ -5713,7 +5734,7 @@ S2.define('select2/core',[
}
};

Select2.prototype._syncSubtree = function (evt, mutations) {
Select2.prototype._isChangeMutation = function (evt, mutations) {
var changed = false;
var self = this;

Expand Down Expand Up @@ -5741,7 +5762,22 @@ S2.define('select2/core',[
}
} else if (mutations.removedNodes && mutations.removedNodes.length > 0) {
changed = true;
} else if ($.isArray(mutations)) {
$.each(mutations, function(evt, mutation) {
if (self._isChangeMutation(evt, mutation)) {
// We've found a change mutation.
// Let's escape from the loop and continue
changed = true;
return false;
}
});
}
return changed;
};

Select2.prototype._syncSubtree = function (evt, mutations) {
var changed = this._isChangeMutation(evt, mutations);
var self = this;

// Only re-pull the data if we think there is a change
if (changed) {
Expand Down Expand Up @@ -5792,7 +5828,7 @@ S2.define('select2/core',[
};

Select2.prototype.toggleDropdown = function () {
if (this.options.get('disabled')) {
if (this.isDisabled()) {
return;
}

Expand All @@ -5808,15 +5844,40 @@ S2.define('select2/core',[
return;
}

if (this.isDisabled()) {
return;
}

this.trigger('query', {});
};

Select2.prototype.close = function () {
Select2.prototype.close = function (evt) {
if (!this.isOpen()) {
return;
}

this.trigger('close', {});
this.trigger('close', { originalEvent : evt });
};

/**
* Helper method to abstract the "enabled" (not "disabled") state of this
* object.
*
* @return {true} if the instance is not disabled.
* @return {false} if the instance is disabled.
*/
Select2.prototype.isEnabled = function () {
return !this.isDisabled();
};

/**
* Helper method to abstract the "disabled" state of this object.
*
* @return {true} if the disabled option is true.
* @return {false} if the disabled option is false.
*/
Select2.prototype.isDisabled = function () {
return this.options.get('disabled');
};

Select2.prototype.isOpen = function () {
Expand Down Expand Up @@ -5893,7 +5954,7 @@ S2.define('select2/core',[
});
}

this.$element.val(newVal).trigger('change');
this.$element.val(newVal).trigger('input').trigger('change');
};

Select2.prototype.destroy = function () {
Expand Down Expand Up @@ -6228,13 +6289,13 @@ S2.define('select2/compat/inputData',[
});

this.$element.val(data.id);
this.$element.trigger('change');
this.$element.trigger('input').trigger('change');
} else {
var value = this.$element.val();
value += this._valueSeparator + data.id;

this.$element.val(value);
this.$element.trigger('change');
this.$element.trigger('input').trigger('change');
}
};

Expand All @@ -6257,7 +6318,7 @@ S2.define('select2/compat/inputData',[
}

self.$element.val(values.join(self._valueSeparator));
self.$element.trigger('change');
self.$element.trigger('input').trigger('change');
});
};

Expand Down
Loading

0 comments on commit da64247

Please sign in to comment.