1
0
mirror of synced 2024-11-22 21:16:10 +03:00

Templating for selections

This commit is contained in:
Kevin Brown 2014-11-01 22:11:35 -04:00
parent 98fb41b442
commit 8b7924fc72
10 changed files with 57 additions and 20 deletions

View File

@ -711,7 +711,9 @@ define('select2/selection/single',[
}; };
SingleSelection.prototype.display = function (data) { SingleSelection.prototype.display = function (data) {
return data.text; var template = this.options.get('templateSelection');
return template(data);
}; };
SingleSelection.prototype.selectionContainer = function () { SingleSelection.prototype.selectionContainer = function () {
@ -788,7 +790,9 @@ define('select2/selection/multiple',[
}; };
MultipleSelection.prototype.display = function (data) { MultipleSelection.prototype.display = function (data) {
return data.text; var template = this.options.get('templateSelection');
return template(data);
}; };
MultipleSelection.prototype.selectionContainer = function () { MultipleSelection.prototype.selectionContainer = function () {
@ -1625,6 +1629,9 @@ define('select2/defaults',[
language: ['select2/i18n/en'], language: ['select2/i18n/en'],
templateResult: function (result) { templateResult: function (result) {
return result.text; return result.text;
},
templateSelection: function (selection) {
return selection.text;
} }
}; };
}; };

View File

@ -711,7 +711,9 @@ define('select2/selection/single',[
}; };
SingleSelection.prototype.display = function (data) { SingleSelection.prototype.display = function (data) {
return data.text; var template = this.options.get('templateSelection');
return template(data);
}; };
SingleSelection.prototype.selectionContainer = function () { SingleSelection.prototype.selectionContainer = function () {
@ -788,7 +790,9 @@ define('select2/selection/multiple',[
}; };
MultipleSelection.prototype.display = function (data) { MultipleSelection.prototype.display = function (data) {
return data.text; var template = this.options.get('templateSelection');
return template(data);
}; };
MultipleSelection.prototype.selectionContainer = function () { MultipleSelection.prototype.selectionContainer = function () {
@ -1625,6 +1629,9 @@ define('select2/defaults',[
language: ['select2/i18n/en'], language: ['select2/i18n/en'],
templateResult: function (result) { templateResult: function (result) {
return result.text; return result.text;
},
templateSelection: function (selection) {
return selection.text;
} }
}; };
}; };

View File

@ -10246,7 +10246,9 @@ define('select2/selection/single',[
}; };
SingleSelection.prototype.display = function (data) { SingleSelection.prototype.display = function (data) {
return data.text; var template = this.options.get('templateSelection');
return template(data);
}; };
SingleSelection.prototype.selectionContainer = function () { SingleSelection.prototype.selectionContainer = function () {
@ -10323,7 +10325,9 @@ define('select2/selection/multiple',[
}; };
MultipleSelection.prototype.display = function (data) { MultipleSelection.prototype.display = function (data) {
return data.text; var template = this.options.get('templateSelection');
return template(data);
}; };
MultipleSelection.prototype.selectionContainer = function () { MultipleSelection.prototype.selectionContainer = function () {
@ -11160,6 +11164,9 @@ define('select2/defaults',[
language: ['select2/i18n/en'], language: ['select2/i18n/en'],
templateResult: function (result) { templateResult: function (result) {
return result.text; return result.text;
},
templateSelection: function (selection) {
return selection.text;
} }
}; };
}; };

File diff suppressed because one or more lines are too long

11
dist/js/select2.js vendored
View File

@ -1139,7 +1139,9 @@ define('select2/selection/single',[
}; };
SingleSelection.prototype.display = function (data) { SingleSelection.prototype.display = function (data) {
return data.text; var template = this.options.get('templateSelection');
return template(data);
}; };
SingleSelection.prototype.selectionContainer = function () { SingleSelection.prototype.selectionContainer = function () {
@ -1216,7 +1218,9 @@ define('select2/selection/multiple',[
}; };
MultipleSelection.prototype.display = function (data) { MultipleSelection.prototype.display = function (data) {
return data.text; var template = this.options.get('templateSelection');
return template(data);
}; };
MultipleSelection.prototype.selectionContainer = function () { MultipleSelection.prototype.selectionContainer = function () {
@ -2053,6 +2057,9 @@ define('select2/defaults',[
language: ['select2/i18n/en'], language: ['select2/i18n/en'],
templateResult: function (result) { templateResult: function (result) {
return result.text; return result.text;
},
templateSelection: function (selection) {
return selection.text;
} }
}; };
}; };

File diff suppressed because one or more lines are too long

View File

@ -465,13 +465,15 @@ $.fn.select2.amd.require(["select2/core", "select2/utils"], function (Select2, U
}, },
templateResult: function (repo) { templateResult: function (repo) {
var markup = '<div class="row">' + var markup = '<div class="row">' +
'<div class="col-sm-1"><img src="' + repo.owner.avatar_url + '" style="max-width: 100%" /></div>' + '<div class="col-sm-1">' +
'<div class="col-sm-11">' + '<img src="' + repo.owner.avatar_url + '" style="max-width: 100%" />' +
'<div class="row">' + '</div>' +
'<div class="col-sm-6">' + repo.full_name + '</div>' + '<div class="col-sm-11">' +
'<div class="col-sm-3"><i class="fa fa-code-fork"></i> ' + repo.forks_count + '</div>' + '<div class="row">' +
'<div class="col-sm-3"><i class="fa fa-star"></i> ' + repo.stargazers_count + '</div>' + '<div class="col-sm-6">' + repo.full_name + '</div>' +
'</div>'; '<div class="col-sm-3"><i class="fa fa-code-fork"></i> ' + repo.forks_count + '</div>' +
'<div class="col-sm-3"><i class="fa fa-star"></i> ' + repo.stargazers_count + '</div>' +
'</div>';
if (repo.description) { if (repo.description) {
markup += '<div>' + repo.description + '</div>'; markup += '<div>' + repo.description + '</div>';

View File

@ -116,6 +116,9 @@ define([
language: ['select2/i18n/en'], language: ['select2/i18n/en'],
templateResult: function (result) { templateResult: function (result) {
return result.text; return result.text;
},
templateSelection: function (selection) {
return selection.text;
} }
}; };
}; };

View File

@ -52,7 +52,9 @@ define([
}; };
MultipleSelection.prototype.display = function (data) { MultipleSelection.prototype.display = function (data) {
return data.text; var template = this.options.get('templateSelection');
return template(data);
}; };
MultipleSelection.prototype.selectionContainer = function () { MultipleSelection.prototype.selectionContainer = function () {

View File

@ -90,7 +90,9 @@ define([
}; };
SingleSelection.prototype.display = function (data) { SingleSelection.prototype.display = function (data) {
return data.text; var template = this.options.get('templateSelection');
return template(data);
}; };
SingleSelection.prototype.selectionContainer = function () { SingleSelection.prototype.selectionContainer = function () {