updating select2

This commit is contained in:
Marc Ducobu 2015-08-25 17:29:51 +02:00
parent d339b70f2d
commit 2457ff021a
6 changed files with 264 additions and 71 deletions

View File

@ -1,7 +1,7 @@
/* /*
Copyright 2012 Igor Vaynberg Copyright 2012 Igor Vaynberg
Version: 3.5.2 Timestamp: Sat Nov 1 14:43:36 EDT 2014 Version: 3.5.3 Timestamp: Wed Aug 19 21:55:46 EDT 2015
This software is licensed under the Apache License, Version 2.0 (the "Apache License") or the GNU This software is licensed under the Apache License, Version 2.0 (the "Apache License") or the GNU
General Public License version 2 (the "GPL License"). You may choose either license to govern your General Public License version 2 (the "GPL License"). You may choose either license to govern your
@ -814,7 +814,7 @@ the specific language governing permissions and limitations under the Apache Lic
// focusin can cause focus wars between modals and select2 since the dropdown is outside the modal. // focusin can cause focus wars between modals and select2 since the dropdown is outside the modal.
this.dropdown.on("click mouseup mousedown touchstart touchend focusin", function (e) { e.stopPropagation(); }); this.dropdown.on("click mouseup mousedown touchstart touchend focusin", function (e) { e.stopPropagation(); });
this.nextSearchTerm = undefined; this.lastSearchTerm = undefined;
if ($.isFunction(this.opts.initSelection)) { if ($.isFunction(this.opts.initSelection)) {
// initialize selection based on the current value of the source element // initialize selection based on the current value of the source element
@ -870,17 +870,21 @@ the specific language governing permissions and limitations under the Apache Lic
select2.container.remove(); select2.container.remove();
select2.liveRegion.remove(); select2.liveRegion.remove();
select2.dropdown.remove(); select2.dropdown.remove();
element element.removeData("select2")
.show() .off(".select2");
.removeData("select2") if (!element.is("input[type='hidden']")) {
.off(".select2") element
.prop("autofocus", this.autofocus || false); .show()
if (this.elementTabIndex) { .prop("autofocus", this.autofocus || false);
element.attr({tabindex: this.elementTabIndex}); if (this.elementTabIndex) {
element.attr({tabindex: this.elementTabIndex});
} else {
element.removeAttr("tabindex");
}
element.show();
} else { } else {
element.removeAttr("tabindex"); element.css("display", "");
} }
element.show();
} }
cleanupJQueryElements.call(this, cleanupJQueryElements.call(this,
@ -932,6 +936,155 @@ the specific language governing permissions and limitations under the Apache Lic
}); });
} }
opts.debug = opts.debug || $.fn.select2.defaults.debug;
// Warnings for options renamed/removed in Select2 4.0.0
// Only when it's enabled through debug mode
if (opts.debug && console && console.warn) {
// id was removed
if (opts.id != null) {
console.warn(
'Select2: The `id` option has been removed in Select2 4.0.0, ' +
'consider renaming your `id` property or mapping the property before your data makes it to Select2. ' +
'You can read more at https://select2.github.io/announcements-4.0.html#changed-id'
);
}
// text was removed
if (opts.text != null) {
console.warn(
'Select2: The `text` option has been removed in Select2 4.0.0, ' +
'consider renaming your `text` property or mapping the property before your data makes it to Select2. ' +
'You can read more at https://select2.github.io/announcements-4.0.html#changed-id'
);
}
// sortResults was renamed to results
if (opts.sortResults != null) {
console.warn(
'Select2: the `sortResults` option has been renamed to `sorter` in Select2 4.0.0. '
);
}
// selectOnBlur was renamed to selectOnClose
if (opts.selectOnBlur != null) {
console.warn(
'Select2: The `selectOnBlur` option has been renamed to `selectOnClose` in Select2 4.0.0.'
);
}
// ajax.results was renamed to ajax.processResults
if (opts.ajax != null && opts.ajax.results != null) {
console.warn(
'Select2: The `ajax.results` option has been renamed to `ajax.processResults` in Select2 4.0.0.'
);
}
// format* options were renamed to language.*
if (opts.formatNoResults != null) {
console.warn(
'Select2: The `formatNoResults` option has been renamed to `language.noResults` in Select2 4.0.0.'
);
}
if (opts.formatSearching != null) {
console.warn(
'Select2: The `formatSearching` option has been renamed to `language.searching` in Select2 4.0.0.'
);
}
if (opts.formatInputTooShort != null) {
console.warn(
'Select2: The `formatInputTooShort` option has been renamed to `language.inputTooShort` in Select2 4.0.0.'
);
}
if (opts.formatInputTooLong != null) {
console.warn(
'Select2: The `formatInputTooLong` option has been renamed to `language.inputTooLong` in Select2 4.0.0.'
);
}
if (opts.formatLoading != null) {
console.warn(
'Select2: The `formatLoading` option has been renamed to `language.loadingMore` in Select2 4.0.0.'
);
}
if (opts.formatSelectionTooBig != null) {
console.warn(
'Select2: The `formatSelectionTooBig` option has been renamed to `language.maximumSelected` in Select2 4.0.0.'
);
}
if (opts.element.data('select2Tags')) {
console.warn(
'Select2: The `data-select2-tags` attribute has been renamed to `data-tags` in Select2 4.0.0.'
);
}
}
// Aliasing options renamed in Select2 4.0.0
// data-select2-tags -> data-tags
if (opts.element.data('tags') != null) {
var tags = opts.element.data('tags');
// data-tags should actually be a boolean
if (!$.isArray(tags)) {
tags = [];
}
opts.element.data('select2Tags', tags);
}
// sortResults -> sorter
if (opts.sorter != null) {
opts.sortResults = opts.sorter;
}
// selectOnBlur -> selectOnClose
if (opts.selectOnClose != null) {
opts.selectOnBlur = opts.selectOnClose;
}
// ajax.results -> ajax.processResults
if (opts.ajax != null) {
if ($.isFunction(opts.ajax.processResults)) {
opts.ajax.results = opts.ajax.processResults;
}
}
// Formatters/language options
if (opts.language != null) {
var lang = opts.language;
// formatNoMatches -> language.noMatches
if ($.isFunction(lang.noMatches)) {
opts.formatNoMatches = lang.noMatches;
}
// formatSearching -> language.searching
if ($.isFunction(lang.searching)) {
opts.formatSearching = lang.searching;
}
// formatInputTooShort -> language.inputTooShort
if ($.isFunction(lang.inputTooShort)) {
opts.formatInputTooShort = lang.inputTooShort;
}
// formatInputTooLong -> language.inputTooLong
if ($.isFunction(lang.inputTooLong)) {
opts.formatInputTooLong = lang.inputTooLong;
}
// formatLoading -> language.loadingMore
if ($.isFunction(lang.loadingMore)) {
opts.formatLoading = lang.loadingMore;
}
// formatSelectionTooBig -> language.maximumSelected
if ($.isFunction(lang.maximumSelected)) {
opts.formatSelectionTooBig = lang.maximumSelected;
}
}
opts = $.extend({}, { opts = $.extend({}, {
populateResults: function(container, results, query) { populateResults: function(container, results, query) {
var populate, id=this.opts.id, liveRegion=this.liveRegion; var populate, id=this.opts.id, liveRegion=this.liveRegion;
@ -975,7 +1128,6 @@ the specific language governing permissions and limitations under the Apache Lic
if (compound) { if (compound) {
innerContainer=$("<ul></ul>"); innerContainer=$("<ul></ul>");
innerContainer.addClass("select2-result-sub"); innerContainer.addClass("select2-result-sub");
populate(result.children, innerContainer, depth+1); populate(result.children, innerContainer, depth+1);
@ -1046,7 +1198,6 @@ the specific language governing permissions and limitations under the Apache Lic
opts.id=function(e) { return e.id; }; opts.id=function(e) { return e.id; };
} else { } else {
if (!("query" in opts)) { if (!("query" in opts)) {
if ("ajax" in opts) { if ("ajax" in opts) {
ajaxUrl = opts.element.data("ajax-url"); ajaxUrl = opts.element.data("ajax-url");
if (ajaxUrl && ajaxUrl.length > 0) { if (ajaxUrl && ajaxUrl.length > 0) {
@ -1325,10 +1476,11 @@ the specific language governing permissions and limitations under the Apache Lic
}; };
if (above) { if (above) {
css.top = offset.top - dropHeight;
css.bottom = 'auto';
this.container.addClass("select2-drop-above"); this.container.addClass("select2-drop-above");
$dropdown.addClass("select2-drop-above"); $dropdown.addClass("select2-drop-above");
dropHeight = $dropdown.outerHeight(false);
css.top = offset.top - dropHeight;
css.bottom = 'auto';
} }
else { else {
css.top = dropTop; css.top = dropTop;
@ -1481,6 +1633,9 @@ the specific language governing permissions and limitations under the Apache Lic
this.clearSearch(); this.clearSearch();
this.search.removeClass("select2-active"); this.search.removeClass("select2-active");
// Remove the aria active descendant for highlighted element
this.search.removeAttr("aria-activedescendant");
this.opts.element.trigger($.Event("select2-close")); this.opts.element.trigger($.Event("select2-close"));
}, },
@ -1499,6 +1654,27 @@ the specific language governing permissions and limitations under the Apache Lic
}, },
/**
* @return {Boolean} Whether or not search value was changed.
* @private
*/
prefillNextSearchTerm: function () {
// initializes search's value with nextSearchTerm (if defined by user)
// ignore nextSearchTerm if the dropdown is opened by the user pressing a letter
if(this.search.val() !== "") {
return false;
}
var nextSearchTerm = this.opts.nextSearchTerm(this.data(), this.lastSearchTerm);
if(nextSearchTerm !== undefined){
this.search.val(nextSearchTerm);
this.search.select();
return true;
}
return false;
},
//abstract //abstract
getMaximumSelectionSize: function() { getMaximumSelectionSize: function() {
return evaluate(this.opts.maximumSelectionSize, this.opts.element); return evaluate(this.opts.maximumSelectionSize, this.opts.element);
@ -1812,6 +1988,9 @@ the specific language governing permissions and limitations under the Apache Lic
if (data.results.length === 0 && checkFormatter(opts.formatNoMatches, "formatNoMatches")) { if (data.results.length === 0 && checkFormatter(opts.formatNoMatches, "formatNoMatches")) {
render("<li class='select2-no-results'>" + evaluate(opts.formatNoMatches, opts.element, search.val()) + "</li>"); render("<li class='select2-no-results'>" + evaluate(opts.formatNoMatches, opts.element, search.val()) + "</li>");
if(this.showSearch){
this.showSearch(search.val());
}
return; return;
} }
@ -1916,7 +2095,7 @@ the specific language governing permissions and limitations under the Apache Lic
} else if (this.opts.width === "copy" || this.opts.width === "resolve") { } else if (this.opts.width === "copy" || this.opts.width === "resolve") {
// check if there is inline style on the element that contains width // check if there is inline style on the element that contains width
style = this.opts.element.attr('style'); style = this.opts.element.attr('style');
if (style !== undefined) { if (typeof(style) === "string") {
attrs = style.split(';'); attrs = style.split(';');
for (i = 0, l = attrs.length; i < l; i = i + 1) { for (i = 0, l = attrs.length; i < l; i = i + 1) {
attr = attrs[i].replace(/\s/g, ''); attr = attrs[i].replace(/\s/g, '');
@ -2015,14 +2194,7 @@ the specific language governing permissions and limitations under the Apache Lic
} }
} }
// initializes search's value with nextSearchTerm (if defined by user) this.prefillNextSearchTerm();
// ignore nextSearchTerm if the dropdown is opened by the user pressing a letter
if(this.search.val() === "") {
if(this.nextSearchTerm != undefined){
this.search.val(this.nextSearchTerm);
this.search.select();
}
}
this.focusser.prop("disabled", true).val(""); this.focusser.prop("disabled", true).val("");
this.updateResults(true); this.updateResults(true);
@ -2109,7 +2281,7 @@ the specific language governing permissions and limitations under the Apache Lic
this.focusser.attr("id", "s2id_autogen"+idSuffix); this.focusser.attr("id", "s2id_autogen"+idSuffix);
elementLabel = $("label[for='" + this.opts.element.attr("id") + "']"); elementLabel = $("label[for='" + this.opts.element.attr("id") + "']");
this.opts.element.focus(this.bind(function () { this.focus(); })); this.opts.element.on('focus.select2', this.bind(function () { this.focus(); }));
this.focusser.prev() this.focusser.prev()
.text(elementLabel.text()) .text(elementLabel.text())
@ -2165,7 +2337,7 @@ the specific language governing permissions and limitations under the Apache Lic
// without this the search field loses focus which is annoying // without this the search field loses focus which is annoying
if (document.activeElement === this.body.get(0)) { if (document.activeElement === this.body.get(0)) {
window.setTimeout(this.bind(function() { window.setTimeout(this.bind(function() {
if (this.opened()) { if (this.opened() && this.results && this.results.length > 1) {
this.search.focus(); this.search.focus();
} }
}), 0); }), 0);
@ -2317,7 +2489,7 @@ the specific language governing permissions and limitations under the Apache Lic
self.updateSelection(selected); self.updateSelection(selected);
self.close(); self.close();
self.setPlaceholder(); self.setPlaceholder();
self.nextSearchTerm = self.opts.nextSearchTerm(selected, self.search.val()); self.lastSearchTerm = self.search.val();
} }
}); });
} }
@ -2454,7 +2626,7 @@ the specific language governing permissions and limitations under the Apache Lic
this.opts.element.trigger({ type: "select2-selected", val: this.id(data), choice: data }); this.opts.element.trigger({ type: "select2-selected", val: this.id(data), choice: data });
this.nextSearchTerm = this.opts.nextSearchTerm(data, this.search.val()); this.lastSearchTerm = this.search.val();
this.close(); this.close();
if ((!options || !options.noFocus) && this.opts.shouldFocusInput(this)) { if ((!options || !options.noFocus) && this.opts.shouldFocusInput(this)) {
@ -2508,9 +2680,23 @@ the specific language governing permissions and limitations under the Apache Lic
if (arguments.length > 1) { if (arguments.length > 1) {
triggerChange = arguments[1]; triggerChange = arguments[1];
if (this.opts.debug && console && console.warn) {
console.warn(
'Select2: The second option to `select2("val")` is not supported in Select2 4.0.0. ' +
'The `change` event will always be triggered in 4.0.0.'
);
}
} }
if (this.select) { if (this.select) {
if (this.opts.debug && console && console.warn) {
console.warn(
'Select2: Setting the value on a <select> using `select2("val")` is no longer supported in 4.0.0. ' +
'You can use the `.val(newValue).trigger("change")` method provided by jQuery instead.'
);
}
this.select this.select
.val(val) .val(val)
.find("option").filter(function() { return this.selected }).each2(function (i, elm) { .find("option").filter(function() { return this.selected }).each2(function (i, elm) {
@ -2559,6 +2745,13 @@ the specific language governing permissions and limitations under the Apache Lic
if (data == undefined) data = null; if (data == undefined) data = null;
return data; return data;
} else { } else {
if (opts.debug && console && console.warn) {
console.warn(
'Select2: The `select2("data")` method can no longer set selected values in 4.0.0, ' +
'consider using the `.val()` method instead.'
);
}
if (arguments.length > 1) { if (arguments.length > 1) {
triggerChange = arguments[1]; triggerChange = arguments[1];
} }
@ -2704,7 +2897,7 @@ the specific language governing permissions and limitations under the Apache Lic
this.search.prev() this.search.prev()
.text($("label[for='" + this.opts.element.attr("id") + "']").text()) .text($("label[for='" + this.opts.element.attr("id") + "']").text())
.attr('for', this.search.attr('id')); .attr('for', this.search.attr('id'));
this.opts.element.focus(this.bind(function () { this.focus(); })); this.opts.element.on('focus.select2', this.bind(function () { this.focus(); }));
this.search.on("input paste", this.bind(function() { this.search.on("input paste", this.bind(function() {
if (this.search.attr('placeholder') && this.search.val().length == 0) return; if (this.search.attr('placeholder') && this.search.val().length == 0) return;
@ -2922,16 +3115,9 @@ the specific language governing permissions and limitations under the Apache Lic
this.focusSearch(); this.focusSearch();
// initializes search's value with nextSearchTerm (if defined by user) this.prefillNextSearchTerm();
// ignore nextSearchTerm if the dropdown is opened by the user pressing a letter
if(this.search.val() === "") {
if(this.nextSearchTerm != undefined){
this.search.val(this.nextSearchTerm);
this.search.select();
}
}
this.updateResults(true); this.updateResults(true);
if (this.opts.shouldFocusInput(this)) { if (this.opts.shouldFocusInput(this)) {
this.search.focus(); this.search.focus();
} }
@ -2957,21 +3143,18 @@ the specific language governing permissions and limitations under the Apache Lic
// multi // multi
updateSelection: function (data) { updateSelection: function (data) {
var ids = [], filtered = [], self = this; var ids = {}, filtered = [], self = this;
// filter out duplicates // filter out duplicates
$(data).each(function () { $(data).each(function () {
if (indexOf(self.id(this), ids) < 0) { if (!(self.id(this) in ids)) {
ids.push(self.id(this)); ids[self.id(this)] = 0;
filtered.push(this); filtered.push(this);
} }
}); });
data = filtered;
this.selection.find(".select2-search-choice").remove(); this.selection.find(".select2-search-choice").remove();
$(data).each(function () { this.addSelectedChoice(filtered);
self.addSelectedChoice(this);
});
self.postprocessResults(); self.postprocessResults();
}, },
@ -2998,7 +3181,7 @@ the specific language governing permissions and limitations under the Apache Lic
this.opts.element.trigger({ type: "selected", val: this.id(data), choice: data }); this.opts.element.trigger({ type: "selected", val: this.id(data), choice: data });
// keep track of the search's value before it gets cleared // keep track of the search's value before it gets cleared
this.nextSearchTerm = this.opts.nextSearchTerm(data, this.search.val()); this.lastSearchTerm = this.search.val();
this.clearSearch(); this.clearSearch();
this.updateResults(); this.updateResults();
@ -3018,10 +3201,8 @@ the specific language governing permissions and limitations under the Apache Lic
this.updateResults(true); this.updateResults(true);
} else { } else {
// initializes search's value with nextSearchTerm and update search result // initializes search's value with nextSearchTerm and update search result
if(this.nextSearchTerm != undefined){ if (this.prefillNextSearchTerm()) {
this.search.val(this.nextSearchTerm);
this.updateResults(); this.updateResults();
this.search.select();
} }
} }
this.positionDropdown(); this.positionDropdown();
@ -3047,6 +3228,14 @@ the specific language governing permissions and limitations under the Apache Lic
}, },
addSelectedChoice: function (data) { addSelectedChoice: function (data) {
var val = this.getVal(), self = this;
$(data).each(function () {
val.push(self.createChoice(this));
});
this.setVal(val);
},
createChoice: function (data) {
var enableChoice = !data.locked, var enableChoice = !data.locked,
enabledItem = $( enabledItem = $(
"<li class='select2-search-choice'>" + "<li class='select2-search-choice'>" +
@ -3059,7 +3248,6 @@ the specific language governing permissions and limitations under the Apache Lic
"</li>"); "</li>");
var choice = enableChoice ? enabledItem : disabledItem, var choice = enableChoice ? enabledItem : disabledItem,
id = this.id(data), id = this.id(data),
val = this.getVal(),
formatted, formatted,
cssClass; cssClass;
@ -3093,8 +3281,7 @@ the specific language governing permissions and limitations under the Apache Lic
choice.data("select2-data", data); choice.data("select2-data", data);
choice.insertBefore(this.searchContainer); choice.insertBefore(this.searchContainer);
val.push(id); return id;
this.setVal(val);
}, },
// multi // multi
@ -3226,14 +3413,16 @@ the specific language governing permissions and limitations under the Apache Lic
// multi // multi
setVal: function (val) { setVal: function (val) {
var unique;
if (this.select) { if (this.select) {
this.select.val(val); this.select.val(val);
} else { } else {
unique = []; var unique = [], valMap = {};
// filter out duplicates // filter out duplicates
$(val).each(function () { $(val).each(function () {
if (indexOf(this, unique) < 0) unique.push(this); if (!(this in valMap)) {
unique.push(this);
valMap[this] = 0;
}
}); });
this.opts.element.val(unique.length === 0 ? "" : unique.join(this.opts.separator)); this.opts.element.val(unique.length === 0 ? "" : unique.join(this.opts.separator));
} }
@ -3249,11 +3438,9 @@ the specific language governing permissions and limitations under the Apache Lic
for (var j = 0; j < old.length; j++) { for (var j = 0; j < old.length; j++) {
if (equal(this.opts.id(current[i]), this.opts.id(old[j]))) { if (equal(this.opts.id(current[i]), this.opts.id(old[j]))) {
current.splice(i, 1); current.splice(i, 1);
if(i>0){ i--;
i--;
}
old.splice(j, 1); old.splice(j, 1);
j--; break;
} }
} }
} }
@ -3423,6 +3610,7 @@ the specific language governing permissions and limitations under the Apache Lic
// plugin defaults, accessible to users // plugin defaults, accessible to users
$.fn.select2.defaults = { $.fn.select2.defaults = {
debug: false,
width: "copy", width: "copy",
loadMorePadding: 0, loadMorePadding: 0,
closeOnSelect: true, closeOnSelect: true,

File diff suppressed because one or more lines are too long

View File

@ -2,15 +2,17 @@
* Select2 Indonesian translation. * Select2 Indonesian translation.
* *
* Author: Ibrahim Yusuf <ibrahim7usuf@gmail.com> * Author: Ibrahim Yusuf <ibrahim7usuf@gmail.com>
* Author: Salahuddin Hairai <mr.od3n@gmail.com>
*/ */
(function ($) { (function ($) {
"use strict"; "use strict";
$.fn.select2.locales['id'] = { $.fn.select2.locales['id'] = {
formatMatches: function (matches) { if (matches === 1) { return "Satu keputusan ditemui, tekan enter untuk memilih."; } return matches + " keputusan ditemui, gunakan kekunci anak panah ke atas dan ke bawah untuk menavigasi."; },
formatNoMatches: function () { return "Tidak ada data yang sesuai"; }, formatNoMatches: function () { return "Tidak ada data yang sesuai"; },
formatInputTooShort: function (input, min) { var n = min - input.length; return "Masukkan " + n + " huruf lagi" + (n == 1 ? "" : "s"); }, formatInputTooShort: function (input, min) { var n = min - input.length; return "Masukkan " + n + " huruf lagi"; },
formatInputTooLong: function (input, max) { var n = input.length - max; return "Hapus " + n + " huruf" + (n == 1 ? "" : "s"); }, formatInputTooLong: function (input, max) { var n = input.length - max; return "Hapuskan " + n + " huruf" ; },
formatSelectionTooBig: function (limit) { return "Anda hanya dapat memilih " + limit + " pilihan" + (limit == 1 ? "" : "s"); }, formatSelectionTooBig: function (limit) { return "Anda hanya dapat memilih " + limit + " pilihan"; },
formatLoadMore: function (pageNumber) { return "Mengambil data…"; }, formatLoadMore: function (pageNumber) { return "Mengambil data…"; },
formatSearching: function () { return "Mencari…"; } formatSearching: function () { return "Mencari…"; }
}; };

View File

@ -2,11 +2,13 @@
* Select2 Malay translation. * Select2 Malay translation.
* *
* Author: Kepoweran <kepoweran@gmail.com> * Author: Kepoweran <kepoweran@gmail.com>
* Author: Salahuddin Hairai <mr.od3n@gmail.com>
*/ */
(function ($) { (function ($) {
"use strict"; "use strict";
$.fn.select2.locales['ms'] = { $.fn.select2.locales['ms'] = {
formatMatches: function (matches) { if (matches === 1) { return "Satu keputusan ditemui, tekan enter untuk memilih."; } return matches + " keputusan ditemui, gunakan kekunci anak panah ke atas dan ke bawah untuk menavigasi."; },
formatNoMatches: function () { return "Tiada padanan yang ditemui"; }, formatNoMatches: function () { return "Tiada padanan yang ditemui"; },
formatInputTooShort: function (input, min) { var n = min - input.length; return "Sila masukkan " + n + " aksara lagi"; }, formatInputTooShort: function (input, min) { var n = min - input.length; return "Sila masukkan " + n + " aksara lagi"; },
formatInputTooLong: function (input, max) { var n = input.length - max; return "Sila hapuskan " + n + " aksara"; }, formatInputTooLong: function (input, max) { var n = input.length - max; return "Sila hapuskan " + n + " aksara"; },

View File

@ -7,6 +7,7 @@
"use strict"; "use strict";
$.fn.select2.locales['tr'] = { $.fn.select2.locales['tr'] = {
formatMatches: function (matches) { if (matches === 1) { return "Sadece bir sonuç bulundu, seçmek için enter tuşuna basabilirsiniz."; } return matches + " sonuç bulundu, yukarı ve aşağı tuşları ile seçebilirsiniz."; },
formatNoMatches: function () { return "Sonuç bulunamadı"; }, formatNoMatches: function () { return "Sonuç bulunamadı"; },
formatInputTooShort: function (input, min) { var n = min - input.length; return "En az " + n + " karakter daha girmelisiniz"; }, formatInputTooShort: function (input, min) { var n = min - input.length; return "En az " + n + " karakter daha girmelisiniz"; },
formatInputTooLong: function (input, max) { var n = input.length - max; return n + " karakter azaltmalısınız"; }, formatInputTooLong: function (input, max) { var n = input.length - max; return n + " karakter azaltmalısınız"; },

View File

@ -1,16 +1,16 @@
/** /**
* Select2 Vietnamese translation. * Select2 Vietnamese translation.
* *
* Author: Long Nguyen <olragon@gmail.com> * Author: Long Nguyen <olragon@gmail.com>, Nguyen Chien Cong
*/ */
(function ($) { (function ($) {
"use strict"; "use strict";
$.fn.select2.locales['vi'] = { $.fn.select2.locales['vi'] = {
formatNoMatches: function () { return "Không tìm thấy kết quả"; }, formatNoMatches: function () { return "Không tìm thấy kết quả"; },
formatInputTooShort: function (input, min) { var n = min - input.length; return "Vui lòng nhập nhiều hơn " + n + " ký tự" + (n == 1 ? "" : "s"); }, formatInputTooShort: function (input, min) { var n = min - input.length; return "Vui lòng nhập nhiều hơn " + n + " ký tự"; },
formatInputTooLong: function (input, max) { var n = input.length - max; return "Vui lòng nhập ít hơn " + n + " ký tự" + (n == 1? "" : "s"); }, formatInputTooLong: function (input, max) { var n = input.length - max; return "Vui lòng nhập ít hơn " + n + " ký tự"; },
formatSelectionTooBig: function (limit) { return "Chỉ có thể chọn được " + limit + " tùy chọn" + (limit == 1 ? "" : "s"); }, formatSelectionTooBig: function (limit) { return "Chỉ có thể chọn được " + limit + " lựa chọn"; },
formatLoadMore: function (pageNumber) { return "Đang lấy thêm kết quả…"; }, formatLoadMore: function (pageNumber) { return "Đang lấy thêm kết quả…"; },
formatSearching: function () { return "Đang tìm…"; } formatSearching: function () { return "Đang tìm…"; }
}; };