vendor/select2/src/js/select2/selection/allowClear.js in card-mod-bootstrap-0.14.2 vs vendor/select2/src/js/select2/selection/allowClear.js in card-mod-bootstrap-0.15.0

- old
+ new

@@ -29,11 +29,11 @@ }); }; AllowClear.prototype._handleClear = function (_, evt) { // Ignore the event if it is disabled - if (this.options.get('disabled')) { + if (this.isDisabled()) { return; } var $clear = this.$selection.find('.select2-selection__clear'); @@ -72,11 +72,11 @@ this.$element.val(previousVal); return; } } - this.$element.trigger('change'); + this.$element.trigger('input').trigger('change'); this.trigger('toggle', {}); }; AllowClear.prototype._handleKeyboardClear = function (_, evt, container) { @@ -90,22 +90,34 @@ }; AllowClear.prototype.update = function (decorated, data) { decorated.call(this, data); + this.$selection.find('.select2-selection__clear').remove(); + this.$selection[0].classList.remove('select2-selection--clearable'); + if (this.$selection.find('.select2-selection__placeholder').length > 0 || data.length === 0) { return; } + var selectionId = this.$selection.find('.select2-selection__rendered') + .attr('id'); + + var removeAll = this.options.get('translations').get('removeAllItems'); + var $remove = $( - '<span class="select2-selection__clear">' + - '&times;' + - '</span>' + '<button type="button" class="select2-selection__clear" tabindex="-1">' + + '<span aria-hidden="true">&times;</span>' + + '</button>' ); + $remove.attr('title', removeAll()); + $remove.attr('aria-label', removeAll()); + $remove.attr('aria-describedby', selectionId); Utils.StoreData($remove[0], 'data', data); - this.$selection.find('.select2-selection__rendered').prepend($remove); + this.$selection.prepend($remove); + this.$selection[0].classList.add('select2-selection--clearable'); }; return AllowClear; });