Skip to content

Instantly share code, notes, and snippets.

@jsicot
Created February 4, 2014 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsicot/8802606 to your computer and use it in GitHub Desktop.
Save jsicot/8802606 to your computer and use it in GitHub Desktop.
Ajouters des langues dans la recherche avancée de l'opac Koha
jQuery(document).ready(function() {
if (jQuery('body#advsearch').size() > 0) {
addOptionsInSelectLangs();
jQuery('#subtypes_unimarc fieldset:first-child').hide();
}
});
function addOptionsInSelectLangs(){
AddOptionToSelect('language-limit', 'Brezhoneg (Breton)', 'ln,rtrn:bre');
AddOptionToSelect('language-limit', 'Català (Catalan)', 'ln,rtrn:cat');
sortDropDownListByText('language-limit');
}
function sortDropDownListByText(selectId) {
var foption = $('#'+ selectId + ' option:first');
var soptions = $('#'+ selectId + ' option:not(:first)').sort(function(a, b) {
return a.text == b.text ? 0 : a.text < b.text ? -1 : 1
});
$('#' + selectId).html(soptions).prepend(foption);
}
function AddOptionToSelect(selectId, optionText, optionValue) {
var opt = new Option(optionText, optionValue);
$(opt).html(optionText);
$('#'+ selectId).append(opt);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment