Skip to content

Instantly share code, notes, and snippets.

@vdchristelle
Created September 9, 2013 07:30
Show Gist options
  • Save vdchristelle/6492489 to your computer and use it in GitHub Desktop.
Save vdchristelle/6492489 to your computer and use it in GitHub Desktop.
make a select from our language list
if($(window).width() > 550){
// make a select from our language list
$('.language ul').each(function(){
var select = $(document.createElement('select')).attr('class', 'select').insertBefore($(this).hide());
$('ul.language-switcher-locale-url > li').each(function(){
var link = $(this).find('a');
var url = link.attr('href');
option = $(document.createElement('option')).appendTo(select).val(url).html($(this).html());
if (link.hasClass('active')) {option.attr('selected', 'selected');}
else {option.removeAttr('selected');}
});
});
// bind href to select
$('.select').live('change', function(){
var Val = $(this).val();
document.location.href = Val;
});
// make our select stylable
$('.language select').coreUISelect();
}; // end > 550
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment