|
@@ -9672,6 +9672,17 @@ define('select2/utils',[], function () {
|
|
|
|
|
|
Utils.Observable = Observable;
|
|
Utils.Observable = Observable;
|
|
|
|
|
|
|
|
+ Utils.generateChars = function (length) {
|
|
|
|
+ var chars = '';
|
|
|
|
+
|
|
|
|
+ for (var i = 0; i < length; i++) {
|
|
|
|
+ var randomChar = Math.floor(Math.random() * 36);
|
|
|
|
+ chars += randomChar.toString(36);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return chars;
|
|
|
|
+ };
|
|
|
|
+
|
|
return Utils;
|
|
return Utils;
|
|
});
|
|
});
|
|
|
|
|
|
@@ -10053,16 +10064,6 @@ define('select2/selection/single',[
|
|
|
|
|
|
$selection.attr('title', this.$element.attr('title'));
|
|
$selection.attr('title', this.$element.attr('title'));
|
|
|
|
|
|
- var id = 'select2-container-';
|
|
|
|
-
|
|
|
|
- for (var i = 0; i < 4; i++) {
|
|
|
|
- var r = Math.floor(Math.random() * 16);
|
|
|
|
- id += r.toString(16);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- $selection.find('.rendered-selection').attr('id', id);
|
|
|
|
- $selection.attr('aria-labelledby', id);
|
|
|
|
-
|
|
|
|
this.$selection = $selection;
|
|
this.$selection = $selection;
|
|
|
|
|
|
return $selection;
|
|
return $selection;
|
|
@@ -10073,6 +10074,11 @@ define('select2/selection/single',[
|
|
|
|
|
|
SingleSelection.__super__.bind.apply(this, arguments);
|
|
SingleSelection.__super__.bind.apply(this, arguments);
|
|
|
|
|
|
|
|
+ var id = container.id + '-container';
|
|
|
|
+
|
|
|
|
+ this.$selection.find('.rendered-selection').attr('id', id);
|
|
|
|
+ this.$selection.attr('aria-labelledby', id);
|
|
|
|
+
|
|
this.$selection.on('mousedown', function (evt) {
|
|
this.$selection.on('mousedown', function (evt) {
|
|
// Only respond to left clicks
|
|
// Only respond to left clicks
|
|
if (evt.which !== 1) {
|
|
if (evt.which !== 1) {
|
|
@@ -10319,21 +10325,15 @@ define('select2/data/base',[
|
|
// Can be implemented in subclasses
|
|
// Can be implemented in subclasses
|
|
};
|
|
};
|
|
|
|
|
|
- BaseAdapter.prototype.generateResultId = function (data) {
|
|
|
|
- var id = 'select2-result-';
|
|
|
|
|
|
+ BaseAdapter.prototype.generateResultId = function (container, data) {
|
|
|
|
+ var id = container.id + '-result-';
|
|
|
|
|
|
- for (var i = 0; i < 4; i++) {
|
|
|
|
- var r = Math.floor(Math.random() * 16);
|
|
|
|
- id += r.toString(16);
|
|
|
|
- }
|
|
|
|
|
|
+ id += Utils.generateChars(4);
|
|
|
|
|
|
if (data.id != null) {
|
|
if (data.id != null) {
|
|
id += '-' + data.id.toString();
|
|
id += '-' + data.id.toString();
|
|
} else {
|
|
} else {
|
|
- for (var s = 0; s < 4; s++) {
|
|
|
|
- var idChar = Math.floor(Math.random() * 16);
|
|
|
|
- id += idChar.toString(16);
|
|
|
|
- }
|
|
|
|
|
|
+ id += '-' + Utils.generateChars(4);
|
|
}
|
|
}
|
|
return id;
|
|
return id;
|
|
};
|
|
};
|
|
@@ -10424,6 +10424,8 @@ define('select2/data/select',[
|
|
SelectAdapter.prototype.bind = function (container, $container) {
|
|
SelectAdapter.prototype.bind = function (container, $container) {
|
|
var self = this;
|
|
var self = this;
|
|
|
|
|
|
|
|
+ this.container = container;
|
|
|
|
+
|
|
container.on('select', function (params) {
|
|
container.on('select', function (params) {
|
|
self.select(params.data);
|
|
self.select(params.data);
|
|
});
|
|
});
|
|
@@ -10490,7 +10492,7 @@ define('select2/data/select',[
|
|
}
|
|
}
|
|
|
|
|
|
if (data.id) {
|
|
if (data.id) {
|
|
- data._resultId = this.generateResultId(data);
|
|
|
|
|
|
+ data._resultId = this.generateResultId(this.container, data);
|
|
}
|
|
}
|
|
|
|
|
|
$option.data('data', data);
|
|
$option.data('data', data);
|
|
@@ -10830,6 +10832,16 @@ define('select2/core',[
|
|
var Select2 = function ($element, options) {
|
|
var Select2 = function ($element, options) {
|
|
this.$element = $element;
|
|
this.$element = $element;
|
|
|
|
|
|
|
|
+ if ($element.attr('id') != null) {
|
|
|
|
+ this.id = $element.attr('id');
|
|
|
|
+ } else if ($element.attr('name') != null) {
|
|
|
|
+ this.id = $element.attr('name') + '-' + Utils.generateChars(2);
|
|
|
|
+ } else {
|
|
|
|
+ this.id = Utils.generateChars(4);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.id = 'select2-' + this.id;
|
|
|
|
+
|
|
options = options || {};
|
|
options = options || {};
|
|
|
|
|
|
options.multiple = options.multiple || $element.prop('multiple');
|
|
options.multiple = options.multiple || $element.prop('multiple');
|