1
0
mirror of synced 2024-11-22 13:06:08 +03:00

Allow for custom sorting functions

This adds the `sorter` function, which works in the same way as the
old `sortResults` function.
This commit is contained in:
Kevin Brown 2014-12-10 18:22:25 -05:00
parent ec1bd3387b
commit caf4ad73d7
9 changed files with 44 additions and 21 deletions

View File

@ -236,7 +236,9 @@ define('select2/results',[
};
Results.prototype.sort = function (data) {
return data;
var sorter = this.options.get('sorter');
return sorter(data);
};
Results.prototype.setClasses = function () {
@ -3268,6 +3270,9 @@ define('select2/defaults',[
this.defaults = {
language: EnglishTranslation,
matcher: matcher,
sorter: function (data) {
return data;
},
minimumInputLength: 0,
maximumInputLength: 0,
theme: 'default',

View File

@ -236,7 +236,9 @@ define('select2/results',[
};
Results.prototype.sort = function (data) {
return data;
var sorter = this.options.get('sorter');
return sorter(data);
};
Results.prototype.setClasses = function () {
@ -3268,6 +3270,9 @@ define('select2/defaults',[
this.defaults = {
language: EnglishTranslation,
matcher: matcher,
sorter: function (data) {
return data;
},
minimumInputLength: 0,
maximumInputLength: 0,
theme: 'default',

View File

@ -9771,7 +9771,9 @@ define('select2/results',[
};
Results.prototype.sort = function (data) {
return data;
var sorter = this.options.get('sorter');
return sorter(data);
};
Results.prototype.setClasses = function () {
@ -12803,6 +12805,9 @@ define('select2/defaults',[
this.defaults = {
language: EnglishTranslation,
matcher: matcher,
sorter: function (data) {
return data;
},
minimumInputLength: 0,
maximumInputLength: 0,
theme: 'default',

File diff suppressed because one or more lines are too long

7
dist/js/select2.js vendored
View File

@ -664,7 +664,9 @@ define('select2/results',[
};
Results.prototype.sort = function (data) {
return data;
var sorter = this.options.get('sorter');
return sorter(data);
};
Results.prototype.setClasses = function () {
@ -3696,6 +3698,9 @@ define('select2/defaults',[
this.defaults = {
language: EnglishTranslation,
matcher: matcher,
sorter: function (data) {
return data;
},
minimumInputLength: 0,
maximumInputLength: 0,
theme: 'default',

File diff suppressed because one or more lines are too long

View File

@ -502,7 +502,15 @@ $(".js-example-language").select2({
<pre data-fill-from=".js-code-theme"></pre>
<!-- Code is further down the page -->
<script type="text/javascript" class="js-code-theme">
$(".js-example-theme-single").select2({
theme: "classic"
});
$(".js-example-theme-multiple").select2({
theme: "classic"
});
</script>
</div>
</section>
</div>
@ -698,13 +706,3 @@ $.fn.select2.amd.require(
});
});
</script>
<script type="text/javascript" class="js-code-theme">
$(".js-example-theme-single").select2({
theme: "classic"
});
$(".js-example-theme-multiple").select2({
theme: "classic"
});
</script>

View File

@ -231,6 +231,9 @@ define([
this.defaults = {
language: EnglishTranslation,
matcher: matcher,
sorter: function (data) {
return data;
},
minimumInputLength: 0,
maximumInputLength: 0,
theme: 'default',

View File

@ -78,7 +78,9 @@ define([
};
Results.prototype.sort = function (data) {
return data;
var sorter = this.options.get('sorter');
return sorter(data);
};
Results.prototype.setClasses = function () {