Current Path : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/ui/collapser/dist/ |
Current File : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/ui/collapser/dist/bundle.js.map |
{"version":3,"file":"bundle.js","sources":["../src/collapser.js"],"sourcesContent":["import { Dom, Type, Text } from 'main.core';\nimport { EventEmitter } from 'main.core.events';\nimport type { CollapserParams } from './types/collapser';\n\nexport class Collapser\n{\n\t#id: string;\n\t#isOpen: boolean;\n\t#outerContainer: HTMLElement;\n\t#innerContainer: HTMLElement;\n\t#duration: number;\n\t#calcProgress: function;\n\n\tconstructor(params: CollapserParams)\n\t{\n\t\tthis.#id = Type.isNil(params.id) ? 'collapser_' + Text.getRandom(8) : params.id;\n\t\tthis.#isOpen = Type.isBoolean(params.isOpen) ? params.isOpen : true;\n\t\tthis.#outerContainer = params.outerContainer;\n\t\tthis.#innerContainer = params.innerContainer;\n\t\tthis.#duration = Type.isNumber(params.duration) ? params.duration : 500;\n\t\tthis.#calcProgress = Type.isFunction(params.calcProgress) ? params.calcProgress : this.#linear;\n\t\tthis.init(params);\n\t}\n\n\tinit(params: CollapserParams): void\n\t{\n\t\tDom.style(this.getChildrenContainer(), 'overflow', 'hidden');\n\n\t\tif (!this.#isOpen)\n\t\t{\n\t\t\tDom.style(this.getChildrenContainer(), 'height', '0px');\n\t\t}\n\n\t\tif (Type.isElementNode(params.buttons))\n\t\t{\n\t\t\tparams.buttons = [params.buttons];\n\t\t}\n\n\t\tif (Type.isArray(params.buttons) || params.buttons instanceof NodeList)\n\t\t{\n\t\t\tfor (const index in params.buttons)\n\t\t\t{\n\t\t\t\tconst button = params.buttons[index];\n\t\t\t\tif (Type.isElementNode(button))\n\t\t\t\t{\n\t\t\t\t\tbutton.addEventListener('click', this.toggle.bind(this))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tthis.getOuterContainer().addEventListener('click', this.toggle.bind(this))\n\t\t}\n\t}\n\n\texpand(): void\n\t{\n\t\tif (this.isOpen())\n\t\t{\n\t\t\treturn;\n\t\t}\n\n\t\tthis.showAnimate(true);\n\t}\n\n\tcollapse(): void\n\t{\n\t\tif (!this.isOpen())\n\t\t{\n\t\t\treturn;\n\t\t}\n\n\t\tthis.showAnimate(false);\n\t}\n\n\tshowAnimate(isOpen: boolean): void\n\t{\n\t\tlet start = performance.now();\n\t\tconst draw = this.makeDraw(this.isOpen());\n\n\t\tconst animate = (time) => {\n\t\t\tlet partTime = (time - start) / this.#duration;\n\n\t\t\tif (partTime > 1)\n\t\t\t{\n\t\t\t\tpartTime = 1;\n\t\t\t}\n\n\t\t\tlet process = this.#calcProgress(partTime);\n\t\t\tdraw(process);\n\n\t\t\tif (partTime < 1)\n\t\t\t{\n\t\t\t\trequestAnimationFrame(animate);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tthis.setOpen(isOpen);\n\t\t\t\tEventEmitter.emit(\n\t\t\t\t\tEventEmitter.GLOBAL_TARGET,\n\t\t\t\t\t'BX.UI.Collapse:onToggle', {\n\t\t\t\t\t\tisOpen: this.isOpen(),\n\t\t\t\t\t\tsource: this,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tif (isOpen)\n\t\t\t\t{\n\t\t\t\t\tDom.style(this.getChildrenContainer(), 'height', null);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\trequestAnimationFrame(animate);\n\t}\n\n\tmakeDraw(isOpen: boolean): function\n\t{\n\t\tif (isOpen)\n\t\t{\n\t\t\treturn (partTime) => {\n\t\t\t\tconst process = this.getChildrenContainer().offsetHeight - this.getChildrenContainer().offsetHeight * partTime;\n\t\t\t\tDom.style(this.getChildrenContainer(), 'height', process + 'px');\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturn (partTime) => {\n\t\t\t\tconst process = this.getChildrenContainer().scrollHeight * partTime;\n\t\t\t\tDom.style(this.getChildrenContainer(), 'height', process + 'px');\n\t\t\t}\n\t\t}\n\t}\n\n\t#linear(partTime): number\n\t{\n\t\treturn partTime;\n\t}\n\n\tgetChildrenContainer(): HTMLElement\n\t{\n\t\treturn this.#innerContainer;\n\t}\n\n\tgetOuterContainer(): HTMLElement\n\t{\n\t\treturn this.#outerContainer;\n\t}\n\n\tsetOpen(state: boolean): void\n\t{\n\t\tthis.#isOpen = state;\n\t}\n\n\tisOpen(): boolean\n\t{\n\t\treturn this.#isOpen;\n\t}\n\n\ttoggle(): void\n\t{\n\t\tthis.isOpen() ? this.collapse() : this.expand();\n\t}\n\n\tgetId(): string\n\t{\n\t\treturn this.#id;\n\t}\n}"],"names":["Collapser","params","Type","isNil","id","Text","getRandom","isBoolean","isOpen","outerContainer","innerContainer","isNumber","duration","isFunction","calcProgress","init","Dom","style","getChildrenContainer","isElementNode","buttons","isArray","NodeList","index","button","addEventListener","toggle","bind","getOuterContainer","showAnimate","start","performance","now","draw","makeDraw","animate","time","partTime","process","requestAnimationFrame","setOpen","EventEmitter","emit","GLOBAL_TARGET","source","offsetHeight","scrollHeight","state","collapse","expand"],"mappings":";;;;;;;;AAAA,CACgD;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAGhD,KAAaA,SAAS;GASrB,mBAAYC,MAAuB,EACnC;KAAA;KAAA;KAAA;OAAA;OAAA;;KAAA;OAAA;OAAA;;KAAA;OAAA;OAAA;;KAAA;OAAA;OAAA;;KAAA;OAAA;OAAA;;KAAA;OAAA;OAAA;;KACC,sCAAI,OAAOC,cAAI,CAACC,KAAK,CAACF,MAAM,CAACG,EAAE,CAAC,GAAG,YAAY,GAAGC,cAAI,CAACC,SAAS,CAAC,CAAC,CAAC,GAAGL,MAAM,CAACG,EAAE;KAC/E,sCAAI,WAAWF,cAAI,CAACK,SAAS,CAACN,MAAM,CAACO,MAAM,CAAC,GAAGP,MAAM,CAACO,MAAM,GAAG,IAAI;KACnE,sCAAI,mBAAmBP,MAAM,CAACQ,cAAc;KAC5C,sCAAI,mBAAmBR,MAAM,CAACS,cAAc;KAC5C,s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