Skip to content

Instantly share code, notes, and snippets.

@renorram
Created January 11, 2017 13:41
Show Gist options
  • Save renorram/35945d9ddca3c4fae7c4b57db9fb6f41 to your computer and use it in GitHub Desktop.
Save renorram/35945d9ddca3c4fae7c4b57db9fb6f41 to your computer and use it in GitHub Desktop.
$(".views-exposed-form #edit-cor .form-item label").each(function(){
var color = $(this).text();
$(this).parent('div.form-item').addClass(filterColor(color));
});
function filterColor(color){
if(typeof color === 'string'){
if($.inArray(color, Drupal.settings.avanz.colors)!== -1){
return cleanString(color.toLowerCase().replace(/ +/g, "-"));
}
}
}
function cleanString(string){
var str = string.split("");
for(var x = 0;x<str.length;x++){
var c = str[x];
if(c == 'á'){
str[x] = 'a';
}
}
return str.join("");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment