Current Path : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/landing/ui/tool/ |
Current File : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/landing/ui/tool/auto-font-scale.min.js |
(function(){"use strict";BX.namespace("BX.Landing.UI.Tool");var t=BX.Landing.Utils.bind;var n=BX.Landing.Utils.slice;var i=BX.Landing.Utils.onCustomEvent;var e=BX.width(window);function o(){return BX.width(window)<1100}function s(){var t=e!==BX.width(window);e=BX.width(window);return t}BX.Landing.UI.Tool.autoFontScale=function(n){this.entries=n.map(this.createEntry,this);t(window,"resize",this.onResize.bind(this,false));t(window,"orientationchange",this.onResize.bind(this,true));i("BX.Landing.Block:init",this.onAddBlock.bind(this));this.adjust(true)};BX.Landing.UI.Tool.autoFontScale.prototype={onResize:function(t){this.adjust(t);clearTimeout(this.falbackTimeoutId);this.falbackTimeoutId=setTimeout(function(){this.adjust(true)}.bind(this),250)},adjust:function(t){if(t===true||s()){var n=o();this.entries.forEach(function(t){if(n){t.adjust()}else{t.resetSize()}})}},createEntry:function(t){return new BX.Landing.UI.Tool.autoFontScaleEntry(t)},addElements:function(t){t.forEach(function(t){var n=this.entries.some(function(n){return n.element===t});if(!n){this.entries.push(this.createEntry(t))}},this)},onAddBlock:function(t){var i=n(t.block.querySelectorAll("h1, h2, h3, h4, h5, [data-auto-font-scale]"));this.addElements(i)}}})();