Created
March 5, 2014 16:31
-
-
Save xavierartot/9370715 to your computer and use it in GitHub Desktop.
charging Google font
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// charging google font | |
1 | |
2 $.get("https://www.googleapis.com/webfonts/v1/webfonts?key=AIzaSyChZeTZ-DzMW-45IUBXUSuBha9MWEiXXtI", {}, | |
3 function (data) { | |
4 // charge toutes les polices dans le select | |
5 $.each(data.items, function (index, value) { | |
6 $('#fonts-l').append($("<option class='google'></option>").attr("value", value.family).text(value.family)); | |
7 }); | |
8 | |
9 // au chargement de la page on affiche la police enregistrer | |
10 var t = $.trim( $('.hide-fonts').text() ); | |
11 $("#fonts-l ").val(t).attr('selected', 'selected'); | |
12 | |
13 if($("#fonts-l").find('option:selected').hasClass('google') ){ | |
14 $('body') | |
15 .append("<link rel='stylesheet' href='http://fonts.googleapis.com/css?family=" + t.replace(/\s+/g," ") +"' type='text/css' media='all' />"); | |
16 $('#primary-navigation a').css({'font-family':'"'+t+'"'}); | |
17 } | |
18 }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment