handle language for multiselect

This commit is contained in:
Nicolas Le Goff
2013-06-11 18:02:30 +02:00
parent 5fe2f4d554
commit 5e7a570a0f
2 changed files with 21 additions and 2 deletions

View File

@@ -10,10 +10,11 @@
define([
"jquery",
"underscore",
"i18n",
"backbone",
"bootstrap",
"multiselect"
], function($, _, Backbone, bootstrap, multiselect) {
], function($, _, i18n, Backbone, bootstrap, multiselect) {
var initialize = function() {
// close alerts
$(document).on("click", ".alert .alert-block-close a", function(e){
@@ -24,7 +25,22 @@ define([
$("select[multiple='multiple']").multiselect({
buttonWidth : "100%",
buttonClass: 'btn btn-inverse'
buttonClass: 'btn btn-inverse',
buttonText: function(options, select) {
if (options.length === 0) {
return i18n.t("none_selected") + '<b class="caret"></b>';
}
else if (options.length > 4) {
return options.length + (options.length > 1 ? i18n.t("collections") : i18n.t("collection")) + ' <b class="caret"></b>';
}
else {
var selected = '';
options.each(function() {
selected += $(this).text() + ', ';
});
return selected.substr(0, selected.length -2) + ' <b class="caret"></b>';
}
}
});
};