(function(f,c){c.yit_panel_typography=function(a,d){this.element=c(d);this._init(a)};c.yit_panel_typography.defaults={elements:{size:".typography_size",unit:".typography_unit",family:".typography_family",style:".typography_style",color:".typography_color",preview:".font-preview p",refresh:".refresh"}};c.yit_panel_typography.prototype={_init:function(a){this.options=c.extend(!0,{},c.yit_panel_typography.defaults,a);""==yit_family_string&&(a=c.parseJSON(yit_web_fonts),yit_family_string+='<optgroup label="Web Fonts">',
    c.each(a.items,function(a,b){yit_family_string+="<option>"+b+"</option>"}),yit_family_string+="</optgroup>",a=c.parseJSON(yit_google_fonts),yit_family_string+='<optgroup label="Google Fonts">',c.each(a.items,function(a,b){yit_family_string+="<option>"+b+"</option>"}),yit_family_string+="</optgroup>");this._loadElements();this._initEvents()},_loadElements:function(){var a=this.options.elements,c=this.element,b;for(b in a)a[b]=c.find(a[b])},_initEvents:function(){var a=this.options.elements,d=a.size;
    d.spinner({min:d.data("min")?d.data("min"):null,max:d.data("max")?d.data("max"):null});a.color.ColorPicker({color:a.color.data("color"),onShow:function(a){c(a).fadeIn(500);return!1},onHide:function(a){c(a).fadeOut(500);return!1},onChange:function(b,c){a.color.find("div").css("backgroundColor","#"+c);a.color.next("input").attr("value","#"+c);a.refresh.is(":visible")||a.preview.css("color","#"+c)}});a.refresh.on("click",function(b){b.preventDefault();c(this).parent().fadeOut("slow");a.preview.css("color",
        a.color.next().val());b=a.size.val();var e=a.unit.val();a.preview.css("font-size",b+e);a.preview.css("line-height",("em"==e||"rem"==e?Number(b)+0.4:Number(b)+4)+e);b=a.style.val();"italic"==b?a.preview.css({"font-weight":"normal","font-style":"italic"}):"bold"==b?a.preview.css({"font-weight":"bold","font-style":"normal"}):"extra-bold"==b?a.preview.css({"font-weight":"800","font-style":"normal"}):"bold-italic"==b?a.preview.css({"font-weight":"bold","font-style":"italic"}):a.preview.css({"font-weight":"normal",
        "font-style":"normal"});"Web fonts"==a.family.find("option:selected").parent().attr("label")?a.preview.css("font-family",a.family.val()):(WebFontConfig={google:{families:[a.family.find("option:selected").text()]},fontactive:function(b){a.preview.css("font-family",b)}},b=document.createElement("script"),b.src=("https:"==document.location.protocol?"https":"http")+"://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js",b.type="text/javascript",b.async="true",e=document.getElementsByTagName("script")[0],
        e.parentNode.insertBefore(b,e))});c([a.size,a.unit]).each(function(){c(this).on("change",function(){if(!a.refresh.is(":visible")){var b=a.size.val(),c=a.unit.val();a.preview.css({"font-size":b+c,"line-height":("em"==c||"rem"==c?Number(b)+0.4:Number(b)+4)+c}).trigger("resize")}})});d=a.family;d.on("mousedown",function(){var a=c(this);if(!1==a.data("instance")){a.val();var d=a.find("option:selected").text();a.html(yit_family_string).find("option").filter(function(){return c(this).text()==d}).attr("selected",
        !0);a.data("instance","true")}});d.on("change",function(){if(!a.refresh.is(":visible")){if("Web fonts"==c(this).find("option:selected").parent().attr("label"))a.preview.css("font-family",c(this).val());else{WebFontConfig={google:{families:[c(this).val()]},fontactive:function(b){a.preview.css("font-family",b)}};var b=document.createElement("script");b.src=("https:"==document.location.protocol?"https":"http")+"://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js";b.type="text/javascript";b.async="true";
        var d=document.getElementsByTagName("script")[0];d.parentNode.insertBefore(b,d)}a.preview.trigger("resize")}});a.style.on("change",function(){if(!a.refresh.is(":visible")){var b=c(this).val();"italic"==b?a.preview.css({"font-weight":"normal","font-style":"italic"}):"bold"==b?a.preview.css({"font-weight":"bold","font-style":"normal"}):"extra-bold"==b?a.preview.css({"font-weight":"800","font-style":"normal"}):"bold-italic"==b?a.preview.css({"font-weight":"bold","font-style":"italic"}):a.preview.css({"font-weight":"normal",
        "font-style":"normal"});a.preview.trigger("resize")}});a.preview.resize(function(){var a=c(this).parents(".yit-box");c(this).parents("form").height(a.height())})}};c.fn.yit_panel_typography=function(a){if("string"===typeof a){var d=Array.prototype.slice.call(arguments,1);this.each(function(){var b=c.data(this,"yit_panel_typography");b?!c.isFunction(b[a])||"_"===a.charAt(0)?console.error("no such method '"+a+"' for yit_panel_typography instance"):b[a].apply(b,d):console.error("cannot call methods on yit_checkout prior to initialization; attempted to call method '"+
    a+"'")})}else this.each(function(){c.data(this,"yit_panel_typography")||c.data(this,"yit_panel_typography",new c.yit_panel_typography(a,this))});return this}})(window,jQuery);
