var SV=window.SV||{};
(function(f,h,k,l){SV.FontSizeChooserForm=XF.extend(XF.OverlayClick,{eventNameSpace:"SVFontSizeChooserFormClick",__backup:{init:"svInit"},options:{allowedSizes:null,buttonText:XF.phrase("close")},init:function(){this.options.allowedSizes?this.svInit():console.error("No allowed sizes have been set.")},getOverlayHtml:function(){return XF.getOverlayHtml({html:this.getSvSettingsBlockHtml(),title:XF.phrase("settings")})},getSvSettingsBlockHtml:function(){return'
'+this.getSvSettingsFieldsHtml()+
'
'+
this.options.buttonText+"
"},getSvSettingsFieldsHtml:function(){return this.getSvSettingsFieldRowHtml("font_size","font_size","select","1em",{allowedValues:this.options.allowedSizes})},getSvSettingsFieldRowHtml:function(a,b,c,d,e){b=this.getSvSettingsInputElement(b,c,d,e);return' '+XF.htmlspecialchars(XF.phrase(XF.htmlspecialchars(a)))+"
"+b.prop("outerHTML")+" "},getSvSettingsInputElement:function(a,b,c,d){var e=null,g=this.getSvInputDefaultValue(a,c);switch(b){case "select":if(!d.allowedValues)return console.error("No allowed values provided for "+XF.htmlspecialchars(a)+" of type ("+XF.htmlspecialchars(b)+")"),!1;e=f(" ",{id:"js-XFUniqueId"+XF.getUniqueCounter(),name:XF.htmlspecialchars(a)});e.attr("data-default-value",
XF.htmlspecialchars(c));f.each(d.allowedValues,function(a,b){e.append(f(" ").attr("value",XF.htmlspecialchars(a)).attr("selected",a===g).text(XF.htmlspecialchars(b)))})}return null===e?(console.error("Wait, That's illegal."),!1):e.val(g).addClass("input")},getSvInputDefaultValue:function(a,b){if(!a)return console.error("No input name provided."),!1;b=void 0===b?"":b;var c=null,d=XF.LocalStorage.getJson("svFontSizeChooserSettings");d&&(a=d[a])&&(c=XF.htmlspecialchars(a));null===c&&(c=b);return c}});
SV.FontSizeChooserConfirm=XF.Event.newHandler({eventNameSpace:"SVFontSizeChooserConfirmClick",$overlay:null,init:function(){var a=this.$target.closest(".overlay");a&&a.length&&(a.xfUniqueId(),this.$overlay=a)},click:function(){this.$overlay&&(this.confirm(),this.$overlay.trigger("overlay:hide"))},confirm:function(){var a=this.getSettings();f("html").css("font-size",a.font_size?a.font_size:"")},getSettings:function(){var a={};this.$overlay&&(f("#"+this.$overlay.attr("id")+" :input").each(function(){var b=
f(this),c=b.attr("name"),d=b.val();b=b.attr("data-default-value");void 0!==b&&c&&d!==b&&(a[c]=d)}),0===Object.keys(a).length?XF.LocalStorage.remove("svFontSizeChooserSettings"):XF.LocalStorage.setJson("svFontSizeChooserSettings",a,!0));return a}});XF.Event.register("click","sv-font-size-chooser-form","SV.FontSizeChooserForm");XF.Event.register("click","sv-font-size-chooser-confirm","SV.FontSizeChooserConfirm")})(jQuery,window,document);