jQuery(document).ready(function(){function h(a){a.preventDefault();a.stopPropagation();b.find(".font-name-info .duplicate-class-name, .font-name-info .wrong-class-name").addClass("hidden");a=b.find(".class-name").val().toLowerCase();if(/^[a-z0-9][-_a-z0-9]*$/.test(a))if(g.find('[name="motopress_google_font_classes['+a+'][family]"]').length)b.find(".font-name-info .duplicate-class-name").removeClass("hidden");else{var c=jQuery("<div />",{"class":"mp-google-font-class-entry"}),d=b.find(".mp-remove-google-font-class-entry").clone(),
e=jQuery("<div />",{"class":"mp-google-font-class-name-container"}),q=jQuery("<span />",{"class":"mp-google-font-class-name",text:a}),k=jQuery("<div />",{"class":"mp-google-font-details"}),l=b.find(".mp-google-fonts-list-container").clone(),f=l.find(".mp-google-fonts-list").attr("name","motopress_google_font_classes["+a+"][family]").val().toLowerCase().split(" ").join("_");e.append(q,d);k.append(l,m(a,f),n(a,f));c.append(e,k);b.before(c);b.find(".class-name").val("")}else b.find(".font-name-info .wrong-class-name").removeClass("hidden")}
function m(a,c){var d=p[c].variants,e=b.find(".mp-google-font-variants").clone();jQuery.each(d,function(b,c){var d=jQuery("<label />",{text:c}),f=jQuery("<input />",{type:"checkbox",name:"motopress_google_font_classes["+a+"][variants][]",value:c});d.prepend(f);e.append(d)});return e}function n(a,c){var d=p[c].subsets,e=b.find(".mp-google-font-subsets").clone();jQuery.each(d,function(b,c){var d=jQuery("<label/>",{text:c}),f=jQuery("<input />",{type:"checkbox",name:"motopress_google_font_classes["+
a+"][subsets][]",value:c});d.prepend(f);e.append(d)});return e}var p=jQuery.parseJSON(motopressGoogleFontsJSON),g=jQuery("#motopress-google-font-class-manager"),b=g.find("#motopress-google-font-class-manager-tools");g.on("change",".mp-google-font-class-entry .mp-google-fonts-list",function(a){a=jQuery(this).closest(".mp-google-font-class-entry");var c=a.find(".mp-google-font-class-name").text(),b=jQuery(this).val().toLowerCase().split(" ").join("_");a.find(".mp-google-font-variants").replaceWith(m(c,
b));a.find(".mp-google-font-subsets").replaceWith(n(c,b))});g.on("click",".mp-google-font-class-entry .mp-remove-google-font-class-entry",function(a){a.preventDefault();a.stopPropagation();jQuery(this).closest(".mp-google-font-class-entry").remove()});b.find(".mp-create-google-font-class-entry").on("click",h);b.find(".class-name").on("keypress",function(a){13===a.which&&h(a)})});
