Bug 25727: (follow-up) Some style updates, JS i18n
[koha.git] / koha-tmpl / intranet-tmpl / prog / js / select2.js
1 /* global __ */
2 $.fn.select2.defaults.set("allowClear", true);
3 $.fn.select2.defaults.set("placeholder", "");
4 $.fn.select2.defaults.set("width", "element");
5
6 // Internationalization
7 $.fn.select2.defaults.set("language", {
8     errorLoading:function(){ return __("The results could not be loaded"); },
9     inputTooLong:function(e){
10         var n = e.input.length - e.max;
11         return __("Please delete %d character(s)").format(n);
12     },
13     inputTooShort:function(e){
14         var n = e.min - e.input.length;
15         return __("Please enter %n or more characters").format(n);
16     },
17     formatResult: function(item) {
18         return $('<div>', {title: item.element[0].title}).text(item.text);
19     },
20     loadingMore:function(){ return __("Loading more results…"); },
21     maximumSelected:function(e){
22         return __("You can only select %s item(s)").format(e.max);
23     },
24     noResults:function(){return __("No results found"); },
25     searching:function(){return __("Searching…"); },
26     removeAllItems:function(){return __("Remove all items"); },
27     removeItem:function(){return __("Remove item"); }
28 });
29
30 $(document).ready(function(){
31     $(".select2").select2();
32     $(".select2").on("select2:clear", function () {
33         $(this).on("select2:opening.cancelOpen", function (evt) {
34             evt.preventDefault();
35
36             $(this).off("select2:opening.cancelOpen");
37         });
38     });
39 });