%PDF- %PDF-
Direktori : /proc/self/root/home/bitrix/www/bitrix/js/landing/ui/field/ |
Current File : //proc/self/root/home/bitrix/www/bitrix/js/landing/ui/field/font_field.min.js |
(function(){"use strict";BX.namespace("BX.Landing.UI.Field");var e=BX.Landing.Utils.isFunction;var t=BX.Landing.Utils.isPlainObject;var n=BX.Landing.Utils.bind;var i=BX.Landing.Utils.proxy;var a=BX.Landing.Utils.escapeHtml;var s=BX.Landing.Utils.addClass;var o=BX.Landing.Utils.clone;BX.Landing.UI.Field.Font=function(o){BX.Landing.UI.Field.BaseField.apply(this,arguments);s(this.layout,"landing-ui-field-font");this.frame=o.frame;this.items=[];if(t(o.items)){var l=Object.keys(this.items);this.items=l.map(function(e){return{name:this.items[e],value:e}},this)}this.onChangeHandler=e(o.onChange)?o.onChange:function(){};this.onValueChangeHandler=e(o.onValueChange)?o.onValueChange:function(){};this.content=a(this.content);this.input.innerHTML=this.content;if(this.frame){var r=this.frame.document.querySelectorAll(this.selector)[0];if(r){var c=BX.style(r,"font-family");if(c){c=c.replace(/['|"]/g,"");this.content=c.split(",")[0];this.input.innerHTML=this.content}}}n(this.input,"click",i(this.onInputClick,this))};function l(e){return"g-font-"+e.toLowerCase().replace(/ /g,"-")}BX.Landing.UI.Field.Font.prototype={constructor:BX.Landing.UI.Field.Font,__proto__:BX.Landing.UI.Field.BaseField.prototype,onInputClick:function(e){e.preventDefault();e.stopPropagation();BX.Landing.UI.Panel.GoogleFonts.getInstance().show().then(function(e){if(!this.response){this.response=o(BX.Landing.UI.Panel.GoogleFonts.getInstance().response);this.response.forEach(function(e){this.items.push({name:e.family,value:l(e.family)})},this)}this.setValue(e)}.bind(this))},setValue:function(e){if(t(e)){var n=l(e.family);var i=BX.Landing.UI.Panel.GoogleFonts.getInstance().client.makeUrl({family:e.family.replace(/ /g,"+")});var s=BX.Landing.UI.Tool.FontManager.getInstance();s.addFont({className:n,family:e.family,href:i,category:e.category},window);this.input.innerHTML=a(e.family);this.onChangeHandler(n,this.items,this.postfix,this.property);this.onValueChangeHandler(this);s.removeUnusedFonts();var o="";s.getUsedLoadedFonts().forEach(function(e){if(e.element){e.element.setAttribute("rel","stylesheet");e.element.removeAttribute("media");o+="<noscript>"+e.element.outerHTML+"</noscript>\n";e.element.setAttribute("rel","preload");e.element.setAttribute("onload","this.removeAttribute('onload');this.rel='stylesheet'");e.element.setAttribute("as","style");o+=e.element.outerHTML+"\n"}if(e.CSSDeclaration){o+=e.CSSDeclaration.outerHTML}});o=o.replace("async@load","all");BX.Landing.Backend.getInstance().action("Landing::updateHead",{content:o})}}}})();