1
0
mirror of synced 2024-11-25 22:36:03 +03:00

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
This commit is contained in:
Kevin Brown 2014-06-11 19:52:08 -04:00
parent 172f973d7b
commit b13c9b474d
2 changed files with 5 additions and 5 deletions

View File

@ -1110,7 +1110,7 @@ the specific language governing permissions and limitations under the Apache Lic
this.attachEvent("onpropertychange", self._sync); this.attachEvent("onpropertychange", self._sync);
}); });
} }
// safari, chrome, firefox, IE11 // safari, chrome, firefox, IE11
observer = window.MutationObserver || window.WebKitMutationObserver|| window.MozMutationObserver; observer = window.MutationObserver || window.WebKitMutationObserver|| window.MozMutationObserver;
if (observer !== undefined) { if (observer !== undefined) {
@ -1349,7 +1349,7 @@ the specific language governing permissions and limitations under the Apache Lic
lastMousePosition.x = e.pageX; lastMousePosition.x = e.pageX;
lastMousePosition.y = e.pageY; lastMousePosition.y = e.pageY;
}); });
return true; return true;
}, },
@ -3397,7 +3397,7 @@ the specific language governing permissions and limitations under the Apache Lic
}, },
formatResultCssClass: function(data) {return data.css;}, formatResultCssClass: function(data) {return data.css;},
formatSelectionCssClass: function(data, container) {return undefined;}, 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"; }, 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"); }, 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"); }, formatInputTooLong: function (input, max) { var n = input.length - max; return "Please delete " + n + " character" + (n == 1? "" : "s"); },

View File

@ -1,13 +1,13 @@
/** /**
* Select2 <Language> translation. * Select2 <Language> translation.
* *
* Author: Your Name <your@email> * Author: Your Name <your@email>
*/ */
(function ($) { (function ($) {
"use strict"; "use strict";
$.extend($.fn.select2.defaults, { $.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"; }, 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"); }, 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"); }, formatInputTooLong: function (input, max) { var n = input.length - max; return "Please delete " + n + " character" + (n == 1 ? "" : "s"); },