ed7543287b
Having to write [% KOHA_VERSION %] for each url is bad because: - It's easily forgettable when adding new <script> or <link> - It prevents grep'ing for the full filename - It violates the DRY principle - If at some point we want to change the "force js and css reload" mechanism, it will be tedious This patch: - adds a Template::Toolkit plugin that generates <script> and <link> tags for JS and CSS files, and inserts automatically the Koha version in the filename - use the new plugin to remove all occurences of [% KOHA_VERSION %] - remove the code that was adding KOHA_VERSION as a template variable Test plan: 1. Apply patch 2. Go to several different pages in Koha (opac and intranet) while checking your browser's dev tools (there should be no 404 for JS and CSS files, and the Koha version should appear in filenames) and the server logs (there should be no "File not found") 3. `git grep KOHA_VERSION` should return nothing 4. prove t/db_dependent/Koha/Template/Plugin/Asset.t Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
53 lines
1.6 KiB
C++
53 lines
1.6 KiB
C++
[% USE Asset %]
|
|
<script src="[% interface %]/lib/select2/js/select2.min.js"></script>
|
|
[% Asset.css("lib/select2/css/select2.min.css") %]
|
|
[% Asset.css("css/select2.css") %]
|
|
<script>
|
|
jQuery.extend($.fn.select2.defaults, {
|
|
allowClear: true,
|
|
width: function() {
|
|
var width = this.element.outerWidth();
|
|
|
|
// 18 is the width of .select2-arrow
|
|
width -= 18;
|
|
|
|
if (this.allowClear) {
|
|
// 42 is the margin-right of .select2-chosen when allowClear is true
|
|
width += 42;
|
|
} else {
|
|
// 26 is the margin-right of .select2-chosen when allowClear is false
|
|
width += 26;
|
|
}
|
|
|
|
return width;
|
|
},
|
|
|
|
// Internationalization
|
|
formatMatches: function (matches) {
|
|
if (matches === 1) {
|
|
return _("One result is available, press enter to select it.");
|
|
}
|
|
return _("%s results are available, use up and down arrow keys to navigate.").format(matches);
|
|
},
|
|
formatNoMatches: function () {
|
|
return _("No matches found");
|
|
},
|
|
formatInputTooShort: function (input, min) {
|
|
var n = min - input.length;
|
|
return _("Please enter %n or more characters").format(n);
|
|
},
|
|
formatInputTooLong: function (input, max) {
|
|
var n = input.length - max;
|
|
return _("Please delete %d character(s)").format(n);
|
|
},
|
|
formatSelectionTooBig: function (limit) {
|
|
return _("You can only select %s item(s)").format(limit);
|
|
},
|
|
formatLoadMore: function (pageNumber) {
|
|
return _("Loading more results…");
|
|
},
|
|
formatSearching: function () {
|
|
return _("Searching…");
|
|
}
|
|
});
|
|
</script>
|