From de5fe02f5ece3e1a7da4eee61655e2388077e492 Mon Sep 17 00:00:00 2001 From: od3n Date: Sat, 11 Oct 2014 10:32:31 +0800 Subject: [PATCH 1/8] updated Malay translation --- select2_locale_ms.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/select2_locale_ms.js b/select2_locale_ms.js index 46588d6d..6447c089 100644 --- a/select2_locale_ms.js +++ b/select2_locale_ms.js @@ -2,11 +2,13 @@ * Select2 Malay translation. * * Author: Kepoweran + * Author: Salahuddin Hairai */ (function ($) { "use strict"; $.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"; }, 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"; }, From 2afc930a12f266d2eb0070ec69017478cdcd3a8c Mon Sep 17 00:00:00 2001 From: od3n Date: Sat, 11 Oct 2014 10:33:22 +0800 Subject: [PATCH 2/8] updated Indonesian translation --- select2_locale_id.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/select2_locale_id.js b/select2_locale_id.js index e9c1fd9b..e7ea0ac6 100644 --- a/select2_locale_id.js +++ b/select2_locale_id.js @@ -2,15 +2,17 @@ * Select2 Indonesian translation. * * Author: Ibrahim Yusuf + * Author: Salahuddin Hairai */ (function ($) { "use strict"; $.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"; }, - formatInputTooShort: function (input, min) { var n = min - input.length; return "Masukkan " + n + " huruf lagi" + (n == 1 ? "" : "s"); }, - formatInputTooLong: function (input, max) { var n = input.length - max; return "Hapus " + n + " huruf" + (n == 1 ? "" : "s"); }, - formatSelectionTooBig: function (limit) { return "Anda hanya dapat memilih " + limit + " pilihan" + (limit == 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 "Hapuskan " + n + " huruf" ; }, + formatSelectionTooBig: function (limit) { return "Anda hanya dapat memilih " + limit + " pilihan"; }, formatLoadMore: function (pageNumber) { return "Mengambil data…"; }, formatSearching: function () { return "Mencari…"; } }; From 03a15e070bf555bc7ce3b1a5eab3e6ba3f611bfd Mon Sep 17 00:00:00 2001 From: Valdas Petrulis Date: Mon, 20 Oct 2014 17:24:37 +0300 Subject: [PATCH 3/8] After clearSearch nextSearchTerm is not cleared https://github.com/ivaynberg/select2/issues/2753 --- select2.js | 51 ++++++++++++++++++++++----------------------------- 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/select2.js b/select2.js index 625c786c..077e6cf7 100644 --- a/select2.js +++ b/select2.js @@ -814,8 +814,6 @@ 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. this.dropdown.on("click mouseup mousedown touchstart touchend focusin", function (e) { e.stopPropagation(); }); - this.nextSearchTerm = undefined; - if ($.isFunction(this.opts.initSelection)) { // initialize selection based on the current value of the source element this.initSelection(); @@ -1499,6 +1497,23 @@ the specific language governing permissions and limitations under the Apache Lic }, + /** + * @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; + } + + var nextSearchTerm = this.opts.nextSearchTerm(this.data(), this.search.val()); + if(nextSearchTerm != undefined){ + this.search.val(nextSearchTerm); + this.search.select(); + } + }, + //abstract getMaximumSelectionSize: function() { return evaluate(this.opts.maximumSelectionSize, this.opts.element); @@ -2015,14 +2030,7 @@ the specific language governing permissions and limitations under the Apache Lic } } - // 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() === "") { - if(this.nextSearchTerm != undefined){ - this.search.val(this.nextSearchTerm); - this.search.select(); - } - } + this.prefillNextSearchTerm(); this.focusser.prop("disabled", true).val(""); this.updateResults(true); @@ -2310,7 +2318,6 @@ the specific language governing permissions and limitations under the Apache Lic self.updateSelection(selected); self.close(); self.setPlaceholder(); - self.nextSearchTerm = self.opts.nextSearchTerm(selected, self.search.val()); } }); } @@ -2447,7 +2454,6 @@ 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.nextSearchTerm = this.opts.nextSearchTerm(data, this.search.val()); this.close(); if ((!options || !options.noFocus) && this.opts.shouldFocusInput(this)) { @@ -2914,16 +2920,9 @@ the specific language governing permissions and limitations under the Apache Lic this.focusSearch(); - // 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() === "") { - if(this.nextSearchTerm != undefined){ - this.search.val(this.nextSearchTerm); - this.search.select(); - } - } - + this.prefillNextSearchTerm(); this.updateResults(true); + if (this.opts.shouldFocusInput(this)) { this.search.focus(); } @@ -2989,9 +2988,6 @@ the specific language governing permissions and limitations under the Apache Lic this.opts.element.trigger({ type: "selected", val: this.id(data), choice: data }); - // keep track of the search's value before it gets cleared - this.nextSearchTerm = this.opts.nextSearchTerm(data, this.search.val()); - this.clearSearch(); this.updateResults(); @@ -3010,11 +3006,8 @@ the specific language governing permissions and limitations under the Apache Lic this.updateResults(true); } else { // initializes search's value with nextSearchTerm and update search result - if(this.nextSearchTerm != undefined){ - this.search.val(this.nextSearchTerm); - this.updateResults(); - this.search.select(); - } + this.prefillNextSearchTerm(); + this.updateResults(); } this.positionDropdown(); } else { From 0cc0ac43f524daf919d304d494d69debced6f050 Mon Sep 17 00:00:00 2001 From: Valdas Petrulis Date: Wed, 22 Oct 2014 16:34:28 +0300 Subject: [PATCH 4/8] Fixed not to break use case: setting the new value after someone was just searching with a different value https://github.com/ivaynberg/select2/issues/2751 --- select2.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/select2.js b/select2.js index 077e6cf7..ae04f1a4 100644 --- a/select2.js +++ b/select2.js @@ -814,6 +814,8 @@ 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. this.dropdown.on("click mouseup mousedown touchstart touchend focusin", function (e) { e.stopPropagation(); }); + this.lastSearchTerm = undefined; + if ($.isFunction(this.opts.initSelection)) { // initialize selection based on the current value of the source element this.initSelection(); @@ -1507,7 +1509,7 @@ the specific language governing permissions and limitations under the Apache Lic return; } - var nextSearchTerm = this.opts.nextSearchTerm(this.data(), this.search.val()); + var nextSearchTerm = this.opts.nextSearchTerm(this.data(), this.lastSearchTerm); if(nextSearchTerm != undefined){ this.search.val(nextSearchTerm); this.search.select(); @@ -2318,6 +2320,7 @@ the specific language governing permissions and limitations under the Apache Lic self.updateSelection(selected); self.close(); self.setPlaceholder(); + self.lastSearchTerm = self.search.val(); } }); } @@ -2454,6 +2457,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.lastSearchTerm = this.search.val(); this.close(); if ((!options || !options.noFocus) && this.opts.shouldFocusInput(this)) { @@ -2988,6 +2992,9 @@ the specific language governing permissions and limitations under the Apache Lic this.opts.element.trigger({ type: "selected", val: this.id(data), choice: data }); + // keep track of the search's value before it gets cleared + this.lastSearchTerm = this.search.val(); + this.clearSearch(); this.updateResults(); From c1f338cfbf53be4217d47482bfc0a7f309d6ffce Mon Sep 17 00:00:00 2001 From: Valdas Petrulis Date: Thu, 23 Oct 2014 10:04:39 +0300 Subject: [PATCH 5/8] Dont update the results if the term hasn't changed. https://github.com/ivaynberg/select2/issues/2751 --- select2.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/select2.js b/select2.js index ae04f1a4..09c37cc1 100644 --- a/select2.js +++ b/select2.js @@ -1500,20 +1500,24 @@ 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; + return false; } var nextSearchTerm = this.opts.nextSearchTerm(this.data(), this.lastSearchTerm); - if(nextSearchTerm != undefined){ + if(nextSearchTerm !== undefined){ this.search.val(nextSearchTerm); this.search.select(); + return true; } + + return false; }, //abstract @@ -3013,8 +3017,9 @@ the specific language governing permissions and limitations under the Apache Lic this.updateResults(true); } else { // initializes search's value with nextSearchTerm and update search result - this.prefillNextSearchTerm(); - this.updateResults(); + if (this.prefillNextSearchTerm()) { + this.updateResults(); + } } this.positionDropdown(); } else { From 7f75f46e5baaf0dda5ca88548dbc30e4506ccf0e Mon Sep 17 00:00:00 2001 From: exabugs Date: Tue, 4 Nov 2014 22:04:30 +0900 Subject: [PATCH 6/8] Delete 'StarHuck' code. Because select2 support IE8+. --- select2.css | 3 --- 1 file changed, 3 deletions(-) diff --git a/select2.css b/select2.css index f39cb21d..8742e550 100644 --- a/select2.css +++ b/select2.css @@ -5,9 +5,6 @@ Version: @@ver@@ Timestamp: @@timestamp@@ margin: 0; position: relative; display: inline-block; - /* inline-block for ie7 */ - zoom: 1; - *display: inline; vertical-align: middle; } From a83ae7858aa5c1621eff396d2115bcd965cb9048 Mon Sep 17 00:00:00 2001 From: Jonathan Toms Date: Wed, 5 Nov 2014 00:10:15 -0500 Subject: [PATCH 7/8] recalculate $dropdown height after drop-above class added --- select2.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/select2.js b/select2.js index b66a2d49..1c2c88ed 100644 --- a/select2.js +++ b/select2.js @@ -1325,10 +1325,11 @@ the specific language governing permissions and limitations under the Apache Lic }; if (above) { - css.top = offset.top - dropHeight; - css.bottom = 'auto'; this.container.addClass("select2-drop-above"); $dropdown.addClass("select2-drop-above"); + dropHeight = $dropdown.outerHeight(false); + css.top = offset.top - dropHeight; + css.bottom = 'auto'; } else { css.top = dropTop; From ced4bf692cf04481e10cc65e33e51fae4a9eef94 Mon Sep 17 00:00:00 2001 From: Yuksel Date: Fri, 14 Nov 2014 22:17:49 +0100 Subject: [PATCH 8/8] formatMatches translation added --- select2_locale_tr.js | 1 + 1 file changed, 1 insertion(+) diff --git a/select2_locale_tr.js b/select2_locale_tr.js index 1dda95ca..2330bc20 100644 --- a/select2_locale_tr.js +++ b/select2_locale_tr.js @@ -7,6 +7,7 @@ "use strict"; $.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ı"; }, 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"; },