Added a base class for the selection container
This commit is contained in:
parent
a07fc21815
commit
e601e33ff3
54
dist/js/select2.amd.full.js
vendored
54
dist/js/select2.amd.full.js
vendored
@ -306,17 +306,46 @@ define('select2/results',[
|
||||
return Results;
|
||||
});
|
||||
|
||||
define('select2/selection/single',[
|
||||
define('select2/selection/base',[
|
||||
'../utils'
|
||||
], function (Utils) {
|
||||
function SingleSelection ($element, options) {
|
||||
function BaseSelection ($element, options) {
|
||||
this.$element = $element;
|
||||
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 () {
|
||||
var $selection = $(
|
||||
@ -333,6 +362,8 @@ define('select2/selection/single',[
|
||||
SingleSelection.prototype.bind = function (container, $container) {
|
||||
var self = this;
|
||||
|
||||
SingleSelection.__super__.bind.apply(this, arguments);
|
||||
|
||||
this.$selection.on('mousedown', function (evt) {
|
||||
// Only respond to left clicks
|
||||
if (evt.which !== 1) {
|
||||
@ -378,8 +409,9 @@ define('select2/selection/single',[
|
||||
});
|
||||
|
||||
define('select2/selection/multiple',[
|
||||
'./base',
|
||||
'../utils'
|
||||
], function (Utils) {
|
||||
], function (BaseSelection, Utils) {
|
||||
function MultipleSelection ($element, options) {
|
||||
this.$element = $element;
|
||||
this.options = options;
|
||||
@ -387,7 +419,7 @@ define('select2/selection/multiple',[
|
||||
MultipleSelection.__super__.constructor.call(this);
|
||||
}
|
||||
|
||||
Utils.Extend(MultipleSelection, Utils.Observable);
|
||||
Utils.Extend(MultipleSelection, BaseSelection);
|
||||
|
||||
MultipleSelection.prototype.render = function () {
|
||||
var $selection = $(
|
||||
@ -404,6 +436,8 @@ define('select2/selection/multiple',[
|
||||
MultipleSelection.prototype.bind = function (container, $container) {
|
||||
var self = this;
|
||||
|
||||
MultipleSelection.__super__.bind.apply(this, arguments);
|
||||
|
||||
this.$selection.on('click', function (evt) {
|
||||
self.trigger('toggle', {
|
||||
originalEvent: evt
|
||||
@ -421,10 +455,6 @@ define('select2/selection/multiple',[
|
||||
data: data
|
||||
});
|
||||
});
|
||||
|
||||
container.on('selection:update', function (params) {
|
||||
self.update(params.data);
|
||||
});
|
||||
};
|
||||
|
||||
MultipleSelection.prototype.clear = function () {
|
||||
@ -532,6 +562,10 @@ define('select2/data/base',[
|
||||
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;
|
||||
});
|
||||
|
||||
|
54
dist/js/select2.amd.js
vendored
54
dist/js/select2.amd.js
vendored
@ -306,17 +306,46 @@ define('select2/results',[
|
||||
return Results;
|
||||
});
|
||||
|
||||
define('select2/selection/single',[
|
||||
define('select2/selection/base',[
|
||||
'../utils'
|
||||
], function (Utils) {
|
||||
function SingleSelection ($element, options) {
|
||||
function BaseSelection ($element, options) {
|
||||
this.$element = $element;
|
||||
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 () {
|
||||
var $selection = $(
|
||||
@ -333,6 +362,8 @@ define('select2/selection/single',[
|
||||
SingleSelection.prototype.bind = function (container, $container) {
|
||||
var self = this;
|
||||
|
||||
SingleSelection.__super__.bind.apply(this, arguments);
|
||||
|
||||
this.$selection.on('mousedown', function (evt) {
|
||||
// Only respond to left clicks
|
||||
if (evt.which !== 1) {
|
||||
@ -378,8 +409,9 @@ define('select2/selection/single',[
|
||||
});
|
||||
|
||||
define('select2/selection/multiple',[
|
||||
'./base',
|
||||
'../utils'
|
||||
], function (Utils) {
|
||||
], function (BaseSelection, Utils) {
|
||||
function MultipleSelection ($element, options) {
|
||||
this.$element = $element;
|
||||
this.options = options;
|
||||
@ -387,7 +419,7 @@ define('select2/selection/multiple',[
|
||||
MultipleSelection.__super__.constructor.call(this);
|
||||
}
|
||||
|
||||
Utils.Extend(MultipleSelection, Utils.Observable);
|
||||
Utils.Extend(MultipleSelection, BaseSelection);
|
||||
|
||||
MultipleSelection.prototype.render = function () {
|
||||
var $selection = $(
|
||||
@ -404,6 +436,8 @@ define('select2/selection/multiple',[
|
||||
MultipleSelection.prototype.bind = function (container, $container) {
|
||||
var self = this;
|
||||
|
||||
MultipleSelection.__super__.bind.apply(this, arguments);
|
||||
|
||||
this.$selection.on('click', function (evt) {
|
||||
self.trigger('toggle', {
|
||||
originalEvent: evt
|
||||
@ -421,10 +455,6 @@ define('select2/selection/multiple',[
|
||||
data: data
|
||||
});
|
||||
});
|
||||
|
||||
container.on('selection:update', function (params) {
|
||||
self.update(params.data);
|
||||
});
|
||||
};
|
||||
|
||||
MultipleSelection.prototype.clear = function () {
|
||||
@ -532,6 +562,10 @@ define('select2/data/base',[
|
||||
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;
|
||||
});
|
||||
|
||||
|
54
dist/js/select2.full.js
vendored
54
dist/js/select2.full.js
vendored
@ -9844,17 +9844,46 @@ define('select2/results',[
|
||||
return Results;
|
||||
});
|
||||
|
||||
define('select2/selection/single',[
|
||||
define('select2/selection/base',[
|
||||
'../utils'
|
||||
], function (Utils) {
|
||||
function SingleSelection ($element, options) {
|
||||
function BaseSelection ($element, options) {
|
||||
this.$element = $element;
|
||||
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 () {
|
||||
var $selection = $(
|
||||
@ -9871,6 +9900,8 @@ define('select2/selection/single',[
|
||||
SingleSelection.prototype.bind = function (container, $container) {
|
||||
var self = this;
|
||||
|
||||
SingleSelection.__super__.bind.apply(this, arguments);
|
||||
|
||||
this.$selection.on('mousedown', function (evt) {
|
||||
// Only respond to left clicks
|
||||
if (evt.which !== 1) {
|
||||
@ -9916,8 +9947,9 @@ define('select2/selection/single',[
|
||||
});
|
||||
|
||||
define('select2/selection/multiple',[
|
||||
'./base',
|
||||
'../utils'
|
||||
], function (Utils) {
|
||||
], function (BaseSelection, Utils) {
|
||||
function MultipleSelection ($element, options) {
|
||||
this.$element = $element;
|
||||
this.options = options;
|
||||
@ -9925,7 +9957,7 @@ define('select2/selection/multiple',[
|
||||
MultipleSelection.__super__.constructor.call(this);
|
||||
}
|
||||
|
||||
Utils.Extend(MultipleSelection, Utils.Observable);
|
||||
Utils.Extend(MultipleSelection, BaseSelection);
|
||||
|
||||
MultipleSelection.prototype.render = function () {
|
||||
var $selection = $(
|
||||
@ -9942,6 +9974,8 @@ define('select2/selection/multiple',[
|
||||
MultipleSelection.prototype.bind = function (container, $container) {
|
||||
var self = this;
|
||||
|
||||
MultipleSelection.__super__.bind.apply(this, arguments);
|
||||
|
||||
this.$selection.on('click', function (evt) {
|
||||
self.trigger('toggle', {
|
||||
originalEvent: evt
|
||||
@ -9959,10 +9993,6 @@ define('select2/selection/multiple',[
|
||||
data: data
|
||||
});
|
||||
});
|
||||
|
||||
container.on('selection:update', function (params) {
|
||||
self.update(params.data);
|
||||
});
|
||||
};
|
||||
|
||||
MultipleSelection.prototype.clear = function () {
|
||||
@ -10070,6 +10100,10 @@ define('select2/data/base',[
|
||||
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;
|
||||
});
|
||||
|
||||
|
4
dist/js/select2.full.min.js
vendored
4
dist/js/select2.full.min.js
vendored
File diff suppressed because one or more lines are too long
54
dist/js/select2.js
vendored
54
dist/js/select2.js
vendored
@ -735,17 +735,46 @@ define('select2/results',[
|
||||
return Results;
|
||||
});
|
||||
|
||||
define('select2/selection/single',[
|
||||
define('select2/selection/base',[
|
||||
'../utils'
|
||||
], function (Utils) {
|
||||
function SingleSelection ($element, options) {
|
||||
function BaseSelection ($element, options) {
|
||||
this.$element = $element;
|
||||
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 () {
|
||||
var $selection = $(
|
||||
@ -762,6 +791,8 @@ define('select2/selection/single',[
|
||||
SingleSelection.prototype.bind = function (container, $container) {
|
||||
var self = this;
|
||||
|
||||
SingleSelection.__super__.bind.apply(this, arguments);
|
||||
|
||||
this.$selection.on('mousedown', function (evt) {
|
||||
// Only respond to left clicks
|
||||
if (evt.which !== 1) {
|
||||
@ -807,8 +838,9 @@ define('select2/selection/single',[
|
||||
});
|
||||
|
||||
define('select2/selection/multiple',[
|
||||
'./base',
|
||||
'../utils'
|
||||
], function (Utils) {
|
||||
], function (BaseSelection, Utils) {
|
||||
function MultipleSelection ($element, options) {
|
||||
this.$element = $element;
|
||||
this.options = options;
|
||||
@ -816,7 +848,7 @@ define('select2/selection/multiple',[
|
||||
MultipleSelection.__super__.constructor.call(this);
|
||||
}
|
||||
|
||||
Utils.Extend(MultipleSelection, Utils.Observable);
|
||||
Utils.Extend(MultipleSelection, BaseSelection);
|
||||
|
||||
MultipleSelection.prototype.render = function () {
|
||||
var $selection = $(
|
||||
@ -833,6 +865,8 @@ define('select2/selection/multiple',[
|
||||
MultipleSelection.prototype.bind = function (container, $container) {
|
||||
var self = this;
|
||||
|
||||
MultipleSelection.__super__.bind.apply(this, arguments);
|
||||
|
||||
this.$selection.on('click', function (evt) {
|
||||
self.trigger('toggle', {
|
||||
originalEvent: evt
|
||||
@ -850,10 +884,6 @@ define('select2/selection/multiple',[
|
||||
data: data
|
||||
});
|
||||
});
|
||||
|
||||
container.on('selection:update', function (params) {
|
||||
self.update(params.data);
|
||||
});
|
||||
};
|
||||
|
||||
MultipleSelection.prototype.clear = function () {
|
||||
@ -961,6 +991,10 @@ define('select2/data/base',[
|
||||
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;
|
||||
});
|
||||
|
||||
|
2
dist/js/select2.min.js
vendored
2
dist/js/select2.min.js
vendored
File diff suppressed because one or more lines are too long
4
src/js/select2/data/base.js
vendored
4
src/js/select2/data/base.js
vendored
@ -15,5 +15,9 @@ define([
|
||||
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;
|
||||
});
|
||||
|
30
src/js/select2/selection/base.js
vendored
Normal file
30
src/js/select2/selection/base.js
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
define([
|
||||
'../utils'
|
||||
], function (Utils) {
|
||||
function BaseSelection ($element, options) {
|
||||
this.$element = $element;
|
||||
this.options = options;
|
||||
|
||||
BaseSelection.__super__.constructor.call(this);
|
||||
}
|
||||
|
||||
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;
|
||||
});
|
11
src/js/select2/selection/multiple.js
vendored
11
src/js/select2/selection/multiple.js
vendored
@ -1,6 +1,7 @@
|
||||
define([
|
||||
'./base',
|
||||
'../utils'
|
||||
], function (Utils) {
|
||||
], function (BaseSelection, Utils) {
|
||||
function MultipleSelection ($element, options) {
|
||||
this.$element = $element;
|
||||
this.options = options;
|
||||
@ -8,7 +9,7 @@ define([
|
||||
MultipleSelection.__super__.constructor.call(this);
|
||||
}
|
||||
|
||||
Utils.Extend(MultipleSelection, Utils.Observable);
|
||||
Utils.Extend(MultipleSelection, BaseSelection);
|
||||
|
||||
MultipleSelection.prototype.render = function () {
|
||||
var $selection = $(
|
||||
@ -25,6 +26,8 @@ define([
|
||||
MultipleSelection.prototype.bind = function (container, $container) {
|
||||
var self = this;
|
||||
|
||||
MultipleSelection.__super__.bind.apply(this, arguments);
|
||||
|
||||
this.$selection.on('click', function (evt) {
|
||||
self.trigger('toggle', {
|
||||
originalEvent: evt
|
||||
@ -42,10 +45,6 @@ define([
|
||||
data: data
|
||||
});
|
||||
});
|
||||
|
||||
container.on('selection:update', function (params) {
|
||||
self.update(params.data);
|
||||
});
|
||||
};
|
||||
|
||||
MultipleSelection.prototype.clear = function () {
|
||||
|
14
src/js/select2/selection/single.js
vendored
14
src/js/select2/selection/single.js
vendored
@ -1,14 +1,12 @@
|
||||
define([
|
||||
'./base',
|
||||
'../utils'
|
||||
], function (Utils) {
|
||||
function SingleSelection ($element, options) {
|
||||
this.$element = $element;
|
||||
this.options = options;
|
||||
|
||||
SingleSelection.__super__.constructor.call(this);
|
||||
], function (BaseSelection, Utils) {
|
||||
function SingleSelection () {
|
||||
SingleSelection.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
Utils.Extend(SingleSelection, Utils.Observable);
|
||||
Utils.Extend(SingleSelection, BaseSelection);
|
||||
|
||||
SingleSelection.prototype.render = function () {
|
||||
var $selection = $(
|
||||
@ -25,6 +23,8 @@ define([
|
||||
SingleSelection.prototype.bind = function (container, $container) {
|
||||
var self = this;
|
||||
|
||||
SingleSelection.__super__.bind.apply(this, arguments);
|
||||
|
||||
this.$selection.on('mousedown', function (evt) {
|
||||
// Only respond to left clicks
|
||||
if (evt.which !== 1) {
|
||||
|
Loading…
Reference in New Issue
Block a user