Lines 3-48
Link Here
|
3 |
[% Asset.js("lib/select2/js/select2.min.js") | $raw %] |
3 |
[% Asset.js("lib/select2/js/select2.min.js") | $raw %] |
4 |
[% Asset.css("lib/select2/css/select2.min.css") | $raw %] |
4 |
[% Asset.css("lib/select2/css/select2.min.css") | $raw %] |
5 |
[% Asset.css("css/select2.css") | $raw %] |
5 |
[% Asset.css("css/select2.css") | $raw %] |
6 |
<!-- select2.inc --> |
6 |
[% Asset.js("js/select2.js") | $raw %] |
7 |
<script> |
|
|
8 |
$.fn.select2.defaults.set("allowClear", true); |
9 |
$.fn.select2.defaults.set("placeholder", ""); |
10 |
$.fn.select2.defaults.set("dropdownAutoWidth", true); |
11 |
|
12 |
// Internationalization |
13 |
$.fn.select2.defaults.set("language", { |
14 |
errorLoading:function(){return"The results could not be loaded."}, |
15 |
inputTooLong:function(e){ |
16 |
var n = e.input.length - e.max; |
17 |
return _("Please delete %d character(s)").format(n); |
18 |
}, |
19 |
inputTooShort:function(e){ |
20 |
var n = e.min - e.input.length; |
21 |
return _("Please enter %n or more characters").format(n); |
22 |
}, |
23 |
formatResult: function(item) { |
24 |
return $('<div>', {title: item.element[0].title}).text(item.text); |
25 |
}, |
26 |
loadingMore:function(){return"Loading more results…"}, |
27 |
maximumSelected:function(e){ |
28 |
return _("You can only select %s item(s)").format(e.max); |
29 |
}, |
30 |
noResults:function(){return _("No results found")}, |
31 |
searching:function(){return _("Searching…")}, |
32 |
removeAllItems:function(){return _("Remove all items")}, |
33 |
removeItem:function(){return _("Remove item")} |
34 |
}); |
35 |
|
36 |
$(document).ready(function(){ |
37 |
$(".select2").select2(); |
38 |
$(".select2").on("select2:clear", function (evt) { |
39 |
$(this).on("select2:opening.cancelOpen", function (evt) { |
40 |
evt.preventDefault(); |
41 |
|
42 |
$(this).off("select2:opening.cancelOpen"); |
43 |
}); |
44 |
}); |
45 |
}); |
46 |
|
47 |
</script> |
48 |
<!-- / select2.inc --> |