|
@@ -9844,17 +9844,46 @@ define('select2/results',[
|
|
return Results;
|
|
return Results;
|
|
});
|
|
});
|
|
|
|
|
|
-define('select2/selection/single',[
|
|
|
|
|
|
+define('select2/selection/base',[
|
|
'../utils'
|
|
'../utils'
|
|
], function (Utils) {
|
|
], function (Utils) {
|
|
- function SingleSelection ($element, options) {
|
|
|
|
|
|
+ function BaseSelection ($element, options) {
|
|
this.$element = $element;
|
|
this.$element = $element;
|
|
this.options = options;
|
|
this.options = options;
|
|
|
|
|
|
- SingleSelection.__super__.constructor.call(this);
|
|
|
|
|
|
+ BaseSelection.__super__.constructor.call(this);
|
|
}
|
|
}
|
|
|
|
|
|
- Utils.Extend(SingleSelection, Utils.Observable);
|
|
|
|
|
|
+ Utils.Extend(BaseSelection, Utils.Observable);
|
|
|
|
+
|
|
|
|
+ BaseSelection.prototype.render = function () {
|
|
|
|
+ throw new Error('The `render` method must be defined in child classes.');
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ BaseSelection.prototype.bind = function (container, $container) {
|
|
|
|
+ var self = this;
|
|
|
|
+
|
|
|
|
+ container.on('selection:update', function (params) {
|
|
|
|
+ self.update(params.data);
|
|
|
|
+ });
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ BaseSelection.prototype.update = function (data) {
|
|
|
|
+ throw new Error('The `update` method must be defined in child classes.');
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ return BaseSelection;
|
|
|
|
+});
|
|
|
|
+
|
|
|
|
+define('select2/selection/single',[
|
|
|
|
+ './base',
|
|
|
|
+ '../utils'
|
|
|
|
+], function (BaseSelection, Utils) {
|
|
|
|
+ function SingleSelection () {
|
|
|
|
+ SingleSelection.__super__.constructor.apply(this, arguments);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Utils.Extend(SingleSelection, BaseSelection);
|
|
|
|
|
|
SingleSelection.prototype.render = function () {
|
|
SingleSelection.prototype.render = function () {
|
|
var $selection = $(
|
|
var $selection = $(
|
|
@@ -9871,6 +9900,8 @@ define('select2/selection/single',[
|
|
SingleSelection.prototype.bind = function (container, $container) {
|
|
SingleSelection.prototype.bind = function (container, $container) {
|
|
var self = this;
|
|
var self = this;
|
|
|
|
|
|
|
|
+ SingleSelection.__super__.bind.apply(this, arguments);
|
|
|
|
+
|
|
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) {
|
|
@@ -9916,8 +9947,9 @@ define('select2/selection/single',[
|
|
});
|
|
});
|
|
|
|
|
|
define('select2/selection/multiple',[
|
|
define('select2/selection/multiple',[
|
|
|
|
+ './base',
|
|
'../utils'
|
|
'../utils'
|
|
-], function (Utils) {
|
|
|
|
|
|
+], function (BaseSelection, Utils) {
|
|
function MultipleSelection ($element, options) {
|
|
function MultipleSelection ($element, options) {
|
|
this.$element = $element;
|
|
this.$element = $element;
|
|
this.options = options;
|
|
this.options = options;
|
|
@@ -9925,7 +9957,7 @@ define('select2/selection/multiple',[
|
|
MultipleSelection.__super__.constructor.call(this);
|
|
MultipleSelection.__super__.constructor.call(this);
|
|
}
|
|
}
|
|
|
|
|
|
- Utils.Extend(MultipleSelection, Utils.Observable);
|
|
|
|
|
|
+ Utils.Extend(MultipleSelection, BaseSelection);
|
|
|
|
|
|
MultipleSelection.prototype.render = function () {
|
|
MultipleSelection.prototype.render = function () {
|
|
var $selection = $(
|
|
var $selection = $(
|
|
@@ -9942,6 +9974,8 @@ define('select2/selection/multiple',[
|
|
MultipleSelection.prototype.bind = function (container, $container) {
|
|
MultipleSelection.prototype.bind = function (container, $container) {
|
|
var self = this;
|
|
var self = this;
|
|
|
|
|
|
|
|
+ MultipleSelection.__super__.bind.apply(this, arguments);
|
|
|
|
+
|
|
this.$selection.on('click', function (evt) {
|
|
this.$selection.on('click', function (evt) {
|
|
self.trigger('toggle', {
|
|
self.trigger('toggle', {
|
|
originalEvent: evt
|
|
originalEvent: evt
|
|
@@ -9959,10 +9993,6 @@ define('select2/selection/multiple',[
|
|
data: data
|
|
data: data
|
|
});
|
|
});
|
|
});
|
|
});
|
|
-
|
|
|
|
- container.on('selection:update', function (params) {
|
|
|
|
- self.update(params.data);
|
|
|
|
- });
|
|
|
|
};
|
|
};
|
|
|
|
|
|
MultipleSelection.prototype.clear = function () {
|
|
MultipleSelection.prototype.clear = function () {
|
|
@@ -10070,6 +10100,10 @@ define('select2/data/base',[
|
|
throw new Error('The `query` method must be defined in child classes.');
|
|
throw new Error('The `query` method must be defined in child classes.');
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ BaseAdapter.prototype.bind = function (container, $container) {
|
|
|
|
+ // Can be implemented in subclasses
|
|
|
|
+ };
|
|
|
|
+
|
|
return BaseAdapter;
|
|
return BaseAdapter;
|
|
});
|
|
});
|
|
|
|
|