Koha/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc
Julian Maurice ed7543287b Bug 20538: Remove the need of writing [% KOHA_VERSION %] everywhere
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>
2018-04-13 11:49:44 -03:00

113 lines
4.3 KiB
PHP

[% USE Asset %]
[% USE AudioAlerts %]
[%# Prevent XFS attacks -%]
[% UNLESS popup %]
<script type="text/javascript">
if (self === top) {
var antiClickjack = document.getElementById("antiClickjack");
antiClickjack.parentNode.removeChild(antiClickjack);
} else {
top.location = self.location;
}
</script>
[% END %]
[% Asset.js("lib/jquery/jquery-2.2.3.min.js") %]
[% Asset.js("lib/jquery/jquery-migrate-1.3.0.min.js") %]
[% Asset.js("lib/jquery/jquery-ui-1.11.4.min.js") %]
[% Asset.js("lib/shortcut/shortcut.js") %]
[% Asset.js("lib/jquery/plugins/jquery.cookie.min.js") %]
[% Asset.js("lib/jquery/plugins/jquery.highlight-3.js") %]
[% Asset.js("lib/bootstrap/bootstrap.min.js") %]
[% Asset.js("lib/jquery/plugins/jquery.validate.min.js") %]
<!-- koha core js -->
[% Asset.js("js/staff-global.js") %]
[% Asset.js("js/commons.js") %]
[% INCLUDE 'validator-strings.inc' %]
[% IF ( IntranetUserJS ) %]
<script type="text/javascript">
//<![CDATA[
[% IntranetUserJS %]
//]]>
</script>
[% END %]
[% IF ( virtualshelves || intranetbookbag ) %]
<script type="text/javascript">
//<![CDATA[
var MSG_BASKET_EMPTY = _("Your cart is currently empty");
var MSG_RECORD_IN_BASKET = _("This item is already in your cart");
var MSG_RECORD_ADDED = _("This item has been added to your cart");
var MSG_NRECORDS_ADDED = _("%s item(s) added to your cart");
var MSG_NRECORDS_IN_BASKET = _("%s already in your cart");
var MSG_NO_RECORD_SELECTED = _("No item was selected");
var MSG_NO_RECORD_ADDED = _("No item was added to your cart (already in your cart)!");
var MSG_CONFIRM_DEL_BASKET = _("Are you sure you want to empty your cart?");
var MSG_CONFIRM_DEL_RECORDS = _("Are you sure you want to remove the selected items?");
var MSG_IN_YOUR_CART = _("Items in your cart: %s");
var MSG_NON_RESERVES_SELECTED = _("One or more selected items cannot be reserved.");
var MSG_ITEM_NOT_IN_CART = _("Add to cart");
var MSG_ITEM_IN_CART = _("In your cart");
var MSG_RECORD_REMOVED = _("The item has been removed from your cart");
//]]>
</script>
[% Asset.js("js/basket.js") %]
[% END %]
[% IF LocalCoverImages %]
[% Asset.js("js/localcovers.js") %]
<script type="text/javascript">
//<![CDATA[
var NO_LOCAL_JACKET = _("No cover image available");
//]]>
</script>
[% END %]
[% IF Koha.Preference('AudioAlerts') || AudioAlertsPage %]
<script type="text/javascript">
//<![CDATA[
var AUDIO_ALERT_PATH = '[% interface %]/[% theme %]/sound/';
var AUDIO_ALERTS = JSON.parse( '[% AudioAlerts.AudioAlerts | replace( "'", "\\'" ) | replace( '"', '\\"' ) %]' );
//]]>
$( document ).ready(function() {
if ( AUDIO_ALERTS ) {
for ( var k in AUDIO_ALERTS ) {
var alert = AUDIO_ALERTS[k];
if ( $( alert.selector ).length ) {
playSound( alert.sound );
break;
}
}
}
});
</script>
[% END %]
[% IF ( CAN_user_circulate_circulate_remaining_permissions ) %]
[% IF ( CircAutocompl ) %]
<script type="text/javascript">
$(document).ready(function(){
var obj = $( "#findborrower" ).autocomplete({
source: "/cgi-bin/koha/circ/ysearch.pl",
minLength: 3,
select: function( event, ui ) {
$( "#findborrower" ).val( ui.item.cardnumber );
$("#patronsearch").submit();
return false;
}
}).data( "ui-autocomplete" );
if( obj ) {
obj._renderItem = function( ul, item ) {
return $( "<li></li>" )
.data( "ui-autocomplete-item", item )
.append( "<a>" + item.surname + ", " + item.firstname + " (" + item.cardnumber + ") <small>" + item.dateofbirth + " " + item.address + " " + item.city + " " + item.zipcode + " " + item.country + "</small></a>" )
.appendTo( ul );
};
}
});
</script>
[% END %]
[% END %]