Current Path : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/ui/textcrop/dist/ |
Current File : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/ui/textcrop/dist/textcrop.bundle.min.js |
this.BX=this.BX||{};(function(t,e){"use strict";let i=t=>t,s,r;class h{constructor(t){this.target=t.target||null;this.rows=t.rows||2;this.resize=t.resize||false;this.text=null;this.rowHeight=null;this.layout={wrapper:null,basicBlock:null}}getText(){if(!this.text){this.text=BX.util.htmlspecialchars(this.target?this.target.innerText:null)}return this.text}getWrapper(){if(!this.layout.wrapper){this.layout.wrapper=e.Tag.render(s||(s=i` <div>${0}</div> `),this.getText())}return this.layout.wrapper}getBasicBlock(){if(!this.layout.basicBlock){this.layout.basicBlock=e.Tag.render(r||(r=i` <div>a</div> `))}return this.layout.basicBlock}getRowHeight(){if(!this.rowHeight){let t=getComputedStyle(this.getWrapper());if(t.lineHeight==="normal"){let t=this.getWrapper().offsetHeight;this.layout.wrapper.appendChild(this.getBasicBlock());let e=this.getWrapper().offsetHeight;this.getBasicBlock().remove();this.rowHeight=e-t}else{this.rowHeight=t.lineHeight}}return this.rowHeight}cropResize(){if(this.resize){let t;window.addEventListener("resize",(()=>{if(!t){t=setTimeout((()=>{this.init();clearTimeout(t)}),100)}}))}}crop(){this.init()}init(){if(!e.Type.isDomNode(this.target)){return}this.getText();this.target.innerText="";this.layout.wrapper="";this.target.appendChild(this.getWrapper());let t=this.getRowHeight();let i="";let s=this.getWrapper().offsetHeight/parseInt(t);if(s>this.rows){this.target.setAttribute("title",this.getText());while(this.getWrapper().offsetHeight/parseInt(t)>this.rows){i=this.layout.wrapper.textContent.substring(0,this.layout.wrapper.textContent.length-4);this.layout.wrapper.textContent=i+"..."}}this.cropResize()}}t.TextCrop=h})(this.BX.UI=this.BX.UI||{},BX); //# sourceMappingURL=textcrop.bundle.map.js