Your IP : 172.70.130.191


Current Path : /var/www/element/data/www/revenuestory.ru/bitrix/js/ui/textcrop/dist/
Upload File :
Current File : /var/www/element/data/www/revenuestory.ru/bitrix/js/ui/textcrop/dist/bundle.js.map

{"version":3,"file":"bundle.js","sources":["../src/index.js"],"sourcesContent":["import { Tag, Type } from 'main.core';\n\nexport class TextCrop\n{\n\tconstructor(options)\n\t{\n\t\tthis.target = options.target || null;\n\t\tthis.rows = options.rows || 2;\n\t\tthis.resize = options.resize || false;\n\t\tthis.text = null;\n\t\tthis.rowHeight = null;\n\n\t\tthis.layout = {\n\t\t\twrapper: null,\n\t\t\tbasicBlock: null\n\t\t}\n\t}\n\n\tgetText()\n\t{\n\t\tif(!this.text)\n\t\t{\n\t\t\tthis.text = this.target\n\t\t\t\t? this.target.innerText\n\t\t\t\t: null;\n\t\t}\n\n\t\treturn this.text;\n\t}\n\n\tgetWrapper()\n\t{\n\t\tif(!this.layout.wrapper)\n\t\t{\n\t\t\tthis.layout.wrapper = Tag.render`\n\t\t\t\t<div>${this.getText()}</div>\n\t\t\t`;\n\t\t}\n\n\t\treturn this.layout.wrapper;\n\t}\n\n\tgetBasicBlock()\n\t{\n\t\tif(!this.layout.basicBlock)\n\t\t{\n\t\t\tthis.layout.basicBlock = Tag.render`\n\t\t\t\t<div>a</div>\n\t\t\t`;\n\t\t}\n\n\t\treturn this.layout.basicBlock;\n\t}\n\n\tgetRowHeight()\n\t{\n\t\tif(!this.rowHeight)\n\t\t{\n\t\t\tlet styleAtt = getComputedStyle(this.getWrapper());\n\n\t\t\tif (styleAtt.lineHeight  === 'normal')\n\t\t\t{\n\t\t\t\tlet firstHeight = this.getWrapper().offsetHeight;\n\t\t\t\tthis.layout.wrapper.appendChild(this.getBasicBlock());\n\t\t\t\tlet secondHeight = this.getWrapper().offsetHeight;\n\t\t\t\tthis.getBasicBlock().remove();\n\n\t\t\t\tthis.rowHeight = secondHeight - firstHeight;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tthis.rowHeight = styleAtt.lineHeight;\n\t\t\t}\n\t\t}\n\n\t\treturn this.rowHeight;\n\t}\n\n\tcropResize()\n\t{\n\t\tif(this.resize)\n\t\t{\n\t\t\tlet timer;\n\t\t\twindow.addEventListener('resize', () => {\n\t\t\t\tif (!timer)\n\t\t\t\t{\n\t\t\t\t\ttimer = setTimeout(() => {\n\t\t\t\t\t\tthis.init();\n\t\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\t}, 100);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\tcrop()\n\t{\n\t\tthis.init();\n\t}\n\n\tinit()\n\t{\n\t\tif(!Type.isDomNode(this.target))\n\t\t{\n\t\t\treturn;\n\t\t}\n\n\t\tthis.getText();\n\t\tthis.target.innerText = '';\n\t\tthis.layout.wrapper = '';\n\t\tthis.target.appendChild(this.getWrapper());\n\n\t\tlet rowHeight = this.getRowHeight();\n\t\tlet cropText = '';\n\t\tlet numberRows = this.getWrapper().offsetHeight / parseInt(rowHeight);\n\n\t\tif (numberRows > this.rows)\n\t\t{\n\t\t\tthis.target.setAttribute('title', this.getText());\n\n\t\t\twhile (this.getWrapper().offsetHeight / parseInt(rowHeight) > this.rows)\n\t\t\t{\n\t\t\t\tcropText = this.layout.wrapper.textContent.substring(0, this.layout.wrapper.textContent.length - 4);\n\t\t\t\tthis.layout.wrapper.innerHTML = cropText + '...';\n\t\t\t}\n\t\t}\n\n\t\tthis.cropResize();\n\t}\n}\n\n"],"names":["TextCrop","options","target","rows","resize","text","rowHeight","layout","wrapper","basicBlock","innerText","Tag","render","getText","styleAtt","getComputedStyle","getWrapper","lineHeight","firstHeight","offsetHeight","appendChild","getBasicBlock","secondHeight","remove","timer","window","addEventListener","setTimeout","init","clearTimeout","Type","isDomNode","getRowHeight","cropText","numberRows","parseInt","setAttribute","textContent","substring","length","innerHTML","cropResize"],"mappings":";;;;;KAEaA,QAAb;CAEC,oBAAYC,OAAZ,EACA;CAAA;CACC,SAAKC,MAAL,G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