Current Path : /var/www/www-root/data/www/monolith-realty.ru/bitrix/js/ui/feedback/form/dist/ |
Current File : /var/www/www-root/data/www/monolith-realty.ru/bitrix/js/ui/feedback/form/dist/form.bundle.js.map |
{"version":3,"file":"form.bundle.js","sources":["../src/form.js"],"sourcesContent":["import { Event, ajax, Dom } from 'main.core';\n\nexport type FeedbackFormOptions = {\n\tid: string;\n\tforms: FeedbackFormOptionsForm[];\n\tpresets?: Object;\n\ttitle?: string,\n\tdefaultForm?: FeedbackFormOptionsForm;\n\tportalUri?: string;\n}\n\ntype FeedbackFormOptionsForm = {\n\tzones: string[];\n\tid: number;\n\tlang: string;\n\tsec: string;\n}\n\nexport class Form\n{\n\tstatic #list = [];\n\tstatic #loadedList: {[string]: Form} = {};\n\tstatic #opened = false;\n\n\tstatic getList(): Array\n\t{\n\t\treturn Form.#list;\n\t}\n\n\tstatic getById(id: string | number): Form | null\n\t{\n\t\treturn Form.#list.find((form) => {\n\t\t\treturn form.id === id;\n\t\t}) || null;\n\t}\n\n\tstatic open(formOptions: FeedbackFormOptions): void\n\t{\n\t\tif (Form.#opened)\n\t\t{\n\t\t\treturn;\n\t\t}\n\n\t\tconst formId = formOptions.id;\n\t\tconst loadedForm = Form.#loadedList[formId];\n\n\t\tif (loadedForm)\n\t\t{\n\t\t\tloadedForm.openPanel();\n\n\t\t\treturn;\n\t\t}\n\n\t\tconst form = new Form({ map: formOptions });\n\n\t\tForm.#loadedList[formOptions.id] = form;\n\n\t\tform.openPanel();\n\t}\n\n\tmap: FeedbackFormOptions;\n\tid: string;\n\tportal: string;\n\tpresets: Object;\n\tform: Object;\n\tforms: FeedbackFormOptionsForm[];\n\tdefaultForm: Object;\n\ttitle: ?string;\n\tbutton: ?HTMLElement;\n\tportalUri: ?string;\n\n\tcached: boolean;\n\n\t/**\n\t * @deprecated use static method open\n\t * @param formOptions\n\t */\n\tconstructor(formOptions)\n\t{\n\t\tthis.init(formOptions);\n\t\tForm.#list.push(this);\n\t}\n\n\tinit(formOptions): void\n\t{\n\t\tthis.cached = false;\n\n\t\tif (formOptions.map !== undefined)\n\t\t{\n\t\t\tthis.map = formOptions.map;\n\n\t\t\treturn;\n\t\t}\n\n\t\tthis.id = formOptions.id;\n\t\tthis.portal = formOptions.portal;\n\t\tthis.presets = formOptions.presets || {};\n\t\tthis.form = formOptions.form || {};\n\t\tthis.title = formOptions.title || '';\n\n\t\tif (formOptions.button)\n\t\t{\n\t\t\tthis.button = BX(formOptions.button);\n\t\t\tEvent.bind(this.button, 'click', this.openPanel.bind(this));\n\t\t}\n\t}\n\n\tappendPresets(presets): void\n\t{\n\t\tObject.entries(presets).forEach(([key, value]) => {\n\t\t\tthis.presets[key] = value;\n\t\t});\n\t}\n\n\topenPanel(): void\n\t{\n\t\tForm.#opened = true;\n\n\t\tBX.SidePanel.Instance.open(`ui:feedback-form-${this.id}`, {\n\t\t\tcacheable: false,\n\t\t\tcontentCallback: () => {\n\t\t\t\treturn Promise.resolve();\n\t\t\t},\n\t\t\tanimationDuration: 200,\n\t\t\tevents: {\n\t\t\t\tonLoad: this.checkSidePanelLoad.bind(this),\n\t\t\t\tonBeforeCloseComplete: this.checkSidePanelClosed.bind(this),\n\t\t\t},\n\t\t\twidth: 600,\n\t\t});\n\t}\n\n\tcheckSidePanelClosed()\n\t{\n\t\tForm.#opened = false;\n\t}\n\n\tcheckSidePanelLoad(event): void\n\t{\n\t\tif (this.map && this.cached === false)\n\t\t{\n\t\t\tajax.runAction('ui.feedback.loadData', {\n\t\t\t\tjson: {\n\t\t\t\t\ttitle: this.map.title || null,\n\t\t\t\t\tid: this.map.id || null,\n\t\t\t\t\tpresets: this.map.presets || null,\n\t\t\t\t\tportalUri: this.map.portalUri || null,\n\t\t\t\t\tforms: this.map.forms || null,\n\t\t\t\t\tdefaultForm: this.map.defaultForm || null,\n\t\t\t\t},\n\t\t\t}).then((response) => {\n\t\t\t\tconst params = response.data.params;\n\t\t\t\tthis.id = params.id;\n\t\t\t\tthis.title = params.title;\n\t\t\t\tthis.form = params.form;\n\t\t\t\tthis.presets = params.presets;\n\t\t\t\tthis.portal = params.portal;\n\t\t\t\tthis.cached = true;\n\n\t\t\t\tthis.onSidePanelLoad(event);\n\t\t\t}).catch((response) => {\n\t\t\t\tconsole.error(response);\n\t\t\t});\n\n\t\t\treturn;\n\t\t}\n\n\t\tthis.onSidePanelLoad(event);\n\t}\n\n\tonSidePanelLoad(event)\n\t{\n\t\tconst slider = event.getSlider();\n\n\t\tif (!slider)\n\t\t{\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#appendFormToSlider(slider);\n\n\t\tsetTimeout(() => {\n\t\t\tslider.showLoader();\n\t\t}, 0);\n\n\t\tthis.loadForm(this.checkLoader.bind(this, slider));\n\t}\n\n\t#appendFormToSlider(slider): void\n\t{\n\t\tif (!slider)\n\t\t{\n\t\t\treturn;\n\t\t}\n\n\t\tthis.formNode = Dom.create('div');\n\t\tconst titleNode = Dom.create('div', {\n\t\t\tstyle: {\n\t\t\t\tmarginBottom: '25px',\n\t\t\t\tfont: '26px/26px var(--ui-font-family-primary, var(--ui-font-family-helvetica))',\n\t\t\t\tcolor: 'var(--ui-color-text-primary)',\n\t\t\t},\n\t\t\ttext: this.title,\n\t\t});\n\n\t\tconst containerNode = Dom.create('div', {\n\t\t\tstyle: {\n\t\t\t\tpadding: '20px',\n\t\t\t\toverflowY: 'auto',\n\t\t\t},\n\t\t\tchildren: [\n\t\t\t\ttitleNode,\n\t\t\t\tthis.formNode,\n\t\t\t],\n\t\t});\n\n\t\tDom.append(containerNode, slider.layout.content);\n\t}\n\n\tcheckLoader(slider): void\n\t{\n\t\tsetTimeout(() => {\n\t\t\tslider.closeLoader();\n\t\t}, 100);\n\t}\n\n\tloadForm(callback)\n\t{\n\t\tconst form = this.form;\n\t\tif (!form || !form.id || !form.lang || !form.sec)\n\t\t{\n\t\t\treturn;\n\t\t}\n\n\t\tif (form.presets)\n\t\t{\n\t\t\tthis.appendPresets(form.presets);\n\t\t}\n\n\t\tconst objectId = `b24form${this.id}`;\n\n\t\tthis.#appendFormScript(`${this.portal}/bitrix/js/crm/form_loader.js`, objectId);\n\n\t\tEvent.bind(top, 'b24:form:init', this.#handleB24FormInit);\n\n\t\ttop[objectId]({\n\t\t\tid: form.id,\n\t\t\tlang: form.lang,\n\t\t\tsec: form.sec,\n\t\t\ttype: 'inline',\n\t\t\tnode: this.formNode,\n\t\t\tpresets: this.presets,\n\t\t\thandlers: {\n\t\t\t\tload: callback,\n\t\t\t},\n\t\t});\n\t}\n\n\t#appendFormScript(u: string, b: string)\n\t{\n\t\ttop.Bitrix24FormObject = b;\n\n\t\ttop[b] = top[b] || function() {\n\t\t\t// eslint-disable-next-line prefer-rest-params\n\t\t\targuments[0].ref = u;\n\t\t\t// eslint-disable-next-line prefer-rest-params\n\t\t\t(top[b].forms = top[b].forms || []).push(arguments[0]);\n\t\t};\n\n\t\tif (top[b].forms)\n\t\t{\n\t\t\treturn;\n\t\t}\n\t\tconst scriptElement = top.document.createElement('script');\n\t\tconst r = Date.now();\n\t\tscriptElement.async = 1;\n\t\tscriptElement.src = `${u}?${r}`;\n\t\tconst h = top.document.getElementsByTagName('script')[0];\n\t\tDom.insertBefore(scriptElement, h);\n\t}\n\n\t#handleB24FormInit(event)\n\t{\n\t\tconst eventForm = event.detail.object;\n\t\teventForm.design.setFont('var(--ui-font-family-primary),var(--ui-font-family-helvetica)');\n\t}\n}\n"],"names":["Form","getList","getById","id","find","form","open","formOptions","formId","loadedForm","openPanel","map","constructor","init","push","cached","undefined","portal","presets","title","button","BX","Event","bind","appendPresets","Object","entries","forEach","key","value","SidePanel","Instance","cacheable","contentCallback","Promise","resolve","animationDuration","events","onLoad","checkSidePanelLoad","onBeforeCloseComplete","checkSidePanelClosed","width","event","ajax","runAction","json","portalUri","forms","defaultForm","then","response","params","data","onSidePanelLoad","catch","console","error","slider","getSlider","setTimeout","showLoader","loadForm","checkLoader","closeLoader","callback","lang","sec","objectId","top","type","node","formNode","handlers","load","Dom","create","titleNode","style","marginBottom","font","color","text","containerNode","padding","overflowY","children","append","layout","content","u","b","Bitrix24FormObject","arguments","ref","scriptElement","document","createElement","r","Date","now","async","src","h","getElementsByTagName","insertBefore","eventForm","detail","object","design","setFont"],"mappings":";;;;;;CAA6C;CAAA;CAAA;CAAA;CAAA;CAAA;AAkB7C,CAAO,MAAMA,IAAI,CACjB;GAKC,OAAOC,OAAO,GACd;KACC,+CAAOD,IAAI;;GAGZ,OAAOE,OAAO,CAACC,EAAmB,EAClC;KACC,OAAO,wCAAAH,IAAI,gBAAOI,IAAI,CAAEC,IAAI,IAAK;OAChC,OAAOA,IAAI,CAACF,EAAE,KAAKA,EAAE;MACrB,CAAC,IAAI,IAAI;;GAGX,OAAOG,IAAI,CAACC,WAAgC,EAC5C;KACC,4CAAIP,IAAI,qBACR;OACC;;KAGD,MAAMQ,MAAM,GAAGD,WAAW,CAACJ,EAAE;KAC7B,MAAMM,UAAU,GAAG,wCAAAT,IAAI,4BAAaQ,MAAM,CAAC;KAE3C,IAAIC,UAAU,EACd;OACCA,UAAU,CAACC,SAAS,EAAE;OAEtB;;KAGD,MAAML,IAAI,GAAG,IAAIL,IAAI,CAAC;OAAEW,GAAG,EAAEJ;MAAa,CAAC;KAE3C,wCAAAP,IAAI,4BAAaO,WAAW,CAACJ,EAAE,CAAC,GAAGE,IAAI;KAEvCA,IAAI,CAACK,SAAS,EAAE;;;CAiBlB;CACA;CACA;GACCE,WAAW,CAACL,WAAW,EACvB;KAAA;OAAA;;KAAA;OAAA;;KAAA;OAAA;;KACC,IAAI,CAACM,IAAI,CAACN,WAAW,CAAC;KACtB,wCAAAP,IAAI,gBAAOc,IAAI,CAAC,IAAI,CAAC;;GAGtBD,IAAI,CAACN,WAAW,EAChB;KACC,IAAI,CAACQ,MAAM,GAAG,KAAK;KAEnB,IAAIR,WAAW,CAACI,GAAG,KAAKK,SAAS,EACjC;OACC,IAAI,CAACL,GAAG,GAAGJ,WAAW,CAACI,GAAG;OAE1B;;KAGD,IAAI,C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