From b13c9b474df3c8080ffd0b2375c3ddd1e936f2fa Mon Sep 17 00:00:00 2001 From: Kevin Brown Date: Wed, 11 Jun 2014 19:52:08 -0400 Subject: [PATCH] Small `formatMatches` change for single results This changes `formatMatches` to notify the user that they can select the single result. This is a more clear result compared to the previous one. This closes the following issue: https://github.com/ivaynberg/select2/issues/2329 --- select2.js | 6 +++--- select2_locale_en.js.template | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/select2.js b/select2.js index cf54469a..a07e3231 100644 --- a/select2.js +++ b/select2.js @@ -1110,7 +1110,7 @@ the specific language governing permissions and limitations under the Apache Lic this.attachEvent("onpropertychange", self._sync); }); } - + // safari, chrome, firefox, IE11 observer = window.MutationObserver || window.WebKitMutationObserver|| window.MozMutationObserver; if (observer !== undefined) { @@ -1349,7 +1349,7 @@ the specific language governing permissions and limitations under the Apache Lic lastMousePosition.x = e.pageX; lastMousePosition.y = e.pageY; }); - + return true; }, @@ -3397,7 +3397,7 @@ the specific language governing permissions and limitations under the Apache Lic }, formatResultCssClass: function(data) {return data.css;}, formatSelectionCssClass: function(data, container) {return undefined;}, - formatMatches: function (matches) { return matches + " results are available, use up and down arrow keys to navigate."; }, + formatMatches: function (matches) { if (matches === 1) { return "One result is available, press enter to select it."; } return matches + " results are available, use up and down arrow keys to navigate."; }, formatNoMatches: function () { return "No matches found"; }, formatInputTooShort: function (input, min) { var n = min - input.length; return "Please enter " + n + " or more character" + (n == 1? "" : "s"); }, formatInputTooLong: function (input, max) { var n = input.length - max; return "Please delete " + n + " character" + (n == 1? "" : "s"); }, diff --git a/select2_locale_en.js.template b/select2_locale_en.js.template index cf2b68f6..9a65edd6 100644 --- a/select2_locale_en.js.template +++ b/select2_locale_en.js.template @@ -1,13 +1,13 @@ /** * Select2 translation. - * + * * Author: Your Name */ (function ($) { "use strict"; $.extend($.fn.select2.defaults, { - formatMatches: function (matches) { return matches + " results are available, use up and down arrow keys to navigate."; }, + formatMatches: function (matches) { if (matches === 1) { return "One result is available, press enter to select it."; } return matches + " results are available, use up and down arrow keys to navigate."; }, formatNoMatches: function () { return "No matches found"; }, formatInputTooShort: function (input, min) { var n = min - input.length; return "Please enter " + n + " or more character" + (n == 1 ? "" : "s"); }, formatInputTooLong: function (input, max) { var n = input.length - max; return "Please delete " + n + " character" + (n == 1 ? "" : "s"); },