File Editor
Directories:
.. (Back)
Files:
class-sinatra-customizer-control-typography.php
typography.css
typography.js
typography.min.css
typography.min.js
Create New File
Create
Edit File: typography.min.js
!function($){"use strict";wp.customize.controlConstructor["sinatra-typography"]=wp.customize.Control.extend({ready:function(){var control=this,setting=control.setting.get(),popup_content=control.container.find(".popup-content");control.container.find("#font-family-"+control.params.id).select2(),control.container.find("#font-subsets-"+control.params.id).select2(),control.update_font_subsets_field(setting["font-family"]),control.container.on("change","#font-family-"+control.params.id,(function(){control.update_font_weight_field($(this).val()),control.update_font_subsets_field($(this).val())})),control.container.on("change","[data-option]",(function(){control.update_value()})),control.container.find(".sinatra-range-wrapper").each((function(){var $this=$(this);$this.rangeControl({id:control.params.id+"-"+$this.data("option-id"),option:$this.data("option-id"),unit:control.params.units[$this.data("option-id")],value:setting[$this.data("options-id")],responsive:control.params.responsive,change:function(){control.update_value()}})})),control.container.on("select2:opening","#font-family-"+control.params.id,(function(){control.populate_font_family_field(),control.container.off("select2:opening","#font-family-"+control.params.id)})),control.container.on("mousedown",'[data-option="font-weight"]',(function(){control.update_font_weight_field(control.container.find("#font-family-"+control.params.id).val()),control.container.off("mousedown",'[data-option="font-weight"]')})),control.container.on("select2:opening","#font-subsets-"+control.params.id,(function(){control.update_font_subsets_field(control.container.find("#font-family-"+control.params.id).val()),control.container.off("mousedown",'[data-option="font-subsets"]')})),control.container.find(".popup-link").on("click",(function(){popup_content.toggleClass("hidden"),$(this).toggleClass("active"),$(this).siblings(".reset-defaults").toggleClass("active"),$("body").on("click",outside_click_close)})),control.container.find(".reset-defaults").on("click",(function(){"font-family"in control.params.display&&(control.populate_font_family_field(),control.container.find("#font-family-"+control.params.id).val(control.params.default["font-family"]).trigger("change")),["font-weight","font-style","text-transform","text-decoration"].forEach((item=>{item in control.params.display&&control.container.find('[data-option="'+item+'"]').val(control.params.default[item]).trigger("change")})),["font-size","line-height","letter-spacing"].forEach((item=>{control.container.find('[data-option-id="'+item+'"]').find(".sinatra-reset-range").click()}))}));var outside_click_close=function(e){$(e.target).closest(".select2-container").length||$(e.target).closest(".customize-save-button-wrapper").length||$(e.target).closest(".reset-defaults").length||control.container.has($(e.target).closest(".popup-link")).length||control.container.has($(e.target).closest(".popup-content")).length||popup_content.hasClass("hidden")||(popup_content.addClass("hidden"),control.container.find(".popup-link").removeClass("active"),control.container.find(".reset-defaults").removeClass("active"),$("body").off("click",outside_click_close))}},update_value:function(){var option,value={};this.container.find("[data-option]").each((function(){option=$(this).data("option"),value[option]="font-size-unit"===option||"line-height-unit"===option||"letter-spacing-unit"===option?$(this).is(":checked")?$(this).val():value[option]:$(this).val()})),this.setting.set(value)},update_font_weight_field:function(font_family){var self=this,options="",selected="",setting=self.setting.get();if("inherit"===font_family&&(selected=' selected="selected"'),options+='<option value="inherit"'+selected+">"+self.params.l10n.inherit+"</option>","inherit"===font_family||"default"===font_family){$.each(["100","200","300","400","500","600","700","800","900"],(function(index,variant){selected=variant===setting["font-weight"]?' selected="selected"':"",options+='<option value="'+variant+'"'+selected+">"+self.params.l10n.weights[variant]+"</option>"}))}else $.each(sinatra_typography_vars.fonts,(function(group_id,group){void 0===group.fonts[font_family]||$.each(group.fonts[font_family].variants,(function(index,variant){selected=variant===setting["font-weight"]?' selected="selected"':"",options+='<option value="'+variant+'"'+selected+">"+self.params.l10n.weights[variant]+"</option>"}))}));self.container.find(".sinatra-typography-font-weight").find("select").html(options)},update_font_subsets_field:function(font_family){var options="",selected="",setting=this.setting.get(),field=this.container.find(".sinatra-typography-font-subsets");"default"!==font_family&&"inherit"!==font_family?($.each(sinatra_typography_vars.fonts,(function(group_id,group){if(void 0!==group.fonts[font_family])return"system_fonts"===group_id||"standard_fonts"===group_id?field.hide():field.show(),void $.each(group.fonts[font_family].subsets,(function(index,subsets){selected="",(setting["font-subsets"]&&-1!==setting["font-subsets"].indexOf(subsets)||"latin"===subsets)&&(selected=' selected="selected"'),options+='<option value="'+subsets+'"'+selected+">"+subsets+"</option>"}))})),field.find("select").html(options)):field.hide()},populate_font_family_field:function(e){var options="",selected="",setting=this.setting.get();selected="inherit"===setting["font-family"]?' selected="selected"':"",options+='<option value="inherit"'+selected+">"+this.params.l10n.inherit+"</option>",selected="default"===setting["font-family"]?' selected="selected"':"",options+='<option value="default"'+selected+">"+this.params.l10n.default+"</option>",$.each(sinatra_typography_vars.fonts,(function(group_id,group){options+='<optgroup label="'+group.name+'">',$.each(group.fonts,(function(font,font_options){selected=font===setting["font-family"]?' selected="selected"':"",options+='<option value="'+font+'"'+selected+">"+font+"</option>"})),options+="</optgroup>"})),this.container.find("#font-family-"+this.params.id).html(options)}})}(jQuery);
Save Changes
Rename File
Rename