Current Path : /var/www/www-root/data/www/monolith-realty.ru/bitrix/js/landing/node/icon/dist/ |
Current File : /var/www/www-root/data/www/monolith-realty.ru/bitrix/js/landing/node/icon/dist/icon.bundle.js.map |
{"version":3,"file":"icon.bundle.js","sources":["../src/icon.js"],"sourcesContent":["import { Dom } from 'main.core';\nimport { Img } from 'landing.node.img';\n\nconst encodeDataValue = BX.Landing.Utils.encodeDataValue;\nconst decodeDataValue = BX.Landing.Utils.decodeDataValue;\nconst data = BX.Landing.Utils.data;\nconst attr = BX.Landing.Utils.attr;\n\nexport class Icon extends Img\n{\n\tconstructor(options)\n\t{\n\t\tsuper(options);\n\t\tthis.type = 'icon';\n\t\tthis.node.addEventListener('click', this.onClick.bind(this));\n\t}\n\n\t/**\n\t * Gets form field\n\t * @return {BX.Landing.UI.Field.BaseField}\n\t */\n\tgetField(): BX.Landing.UI.Field.BaseField\n\t{\n\t\tif (this.field)\n\t\t{\n\t\t\tthis.field.content = this.getValue();\n\t\t}\n\t\telse\n\t\t{\n\t\t\tconst value = this.getValue();\n\t\t\tif (value.url)\n\t\t\t{\n\t\t\t\tvalue.url = decodeDataValue(value.url);\n\t\t\t}\n\n\t\t\tconst disableLink = !!this.node.closest('a');\n\n\t\t\tthis.field = new BX.Landing.UI.Field.Icon({\n\t\t\t\tselector: this.selector,\n\t\t\t\ttitle: this.manifest.name,\n\t\t\t\tdisableLink: disableLink,\n\t\t\t\tcontent: value,\n\t\t\t\tdimensions: this.manifest.dimensions || {},\n\t\t\t});\n\t\t}\n\n\t\treturn this.field;\n\t}\n\n\t/**\n\t * Sets node value\n\t * @param value - Path to image\n\t * @param {?boolean} [preventSave = false]\n\t * @param {?boolean} [preventHistory = false]\n\t * @return {Promise<any>}\n\t */\n\tsetValue(value, preventSave = false, preventHistory = false): Promise\n\t{\n\t\tthis.lastValue = this.lastValue || this.getValue();\n\t\tthis.preventSave(preventSave);\n\n\t\treturn setIconValue(this.node, value)\n\t\t\t.then(() => {\n\t\t\t\tif (value.url)\n\t\t\t\t{\n\t\t\t\t\tconst url = this.preparePseudoUrl(value.url);\n\t\t\t\t\tif (url !== null)\n\t\t\t\t\t{\n\t\t\t\t\t\tattr(this.node, 'data-pseudo-url', url);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.onChange(preventHistory);\n\n\t\t\t\tif (!preventHistory)\n\t\t\t\t{\n\t\t\t\t\tBX.Landing.History.getInstance().push();\n\t\t\t\t}\n\n\t\t\t\tthis.lastValue = this.getValue();\n\t\t\t});\n\t}\n\n\t/**\n\t * Gets node value\n\t * @return {{src: string}}\n\t */\n\tgetValue(): { type: string, src: string, id: number, alt: string, classList: string[], url: string }\n\t{\n\t\treturn {\n\t\t\ttype: 'icon',\n\t\t\tsrc: '',\n\t\t\tid: -1,\n\t\t\talt: '',\n\t\t\tclassList: getIconClassList(this.node.className),\n\t\t\turl: encodeDataValue(getPseudoUrl(this)),\n\t\t};\n\t}\n\n\tonClick(event)\n\t{\n\t\tBX.Event.EventEmitter.emit('BX.Landing.Node.Icon:onClick');\n\t}\n}\n\nBX.Landing.Node.Icon = Icon;\n\n// eslint-disable-next-line flowtype/require-return-type\nfunction getPseudoUrl(node)\n{\n\tconst url = data(node.node, 'data-pseudo-url');\n\n\treturn url || '';\n}\n\n/**\n * Gets icon class list\n * @param {string} className\n * @return {string[]}\n */\nfunction getIconClassList(className): string[]\n{\n\treturn className.split(' ');\n}\n\n/**\n * Sets icon value or converts to span and sets value\n * @param {BX.Landing.Node.Icon} node\n * @param {object} value\n * @return {Promise<any>}\n */\nfunction setIconValue(node, value): Promise<any>\n{\n\treturn BX.Landing.UI.Panel.IconPanel\n\t\t.getLibraries()\n\t\t.then((libraries) => {\n\t\t\tlibraries.forEach((library) => {\n\t\t\t\tlibrary.categories.forEach((category) => {\n\t\t\t\t\tcategory.items.forEach((item) => {\n\t\t\t\t\t\tconst className = BX.Type.isObject(item) ? item.options.join(' ') : item;\n\n\t\t\t\t\t\tconst classList = className.split(' ');\n\t\t\t\t\t\tclassList.forEach((classItem) => {\n\t\t\t\t\t\t\tif (classItem)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tDom.removeClass(node, classItem);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tvalue.classList.forEach((className) => {\n\t\t\t\tDom.addClass(node, className);\n\t\t\t});\n\t\t});\n}\n"],"names":["encodeDataValue","BX","Landing","Utils","decodeDataValue","data","attr","Icon","Img","constructor","options","type","node","addEventListener","onClick","bind","getField","field","content","getValue","value","url","disableLink","closest","UI","Field","selector","title","manifest","name","dimensions","setValue","preventSave","preventHistory","lastValue","setIconValue","then","preparePseudoUrl","onChange","History","getInstance","push","src","id","alt","classList","getIconClassList","className","getPseudoUrl","event","Event","EventEmitter","emit","Node","split","Panel","IconPanel","getLibraries","libraries","forEach","library","categories","category","items","item","Type","isObject","join","classItem","Dom","removeClass","addClass"],"mappings":";;;;;CAGA,MAAMA,eAAe,GAAGC,EAAE,CAACC,OAAO,CAACC,KAAK,CAACH,eAAe;CACxD,MAAMI,eAAe,GAAGH,EAAE,CAACC,OAAO,CAACC,KAAK,CAACC,eAAe;CACxD,MAAMC,IAAI,GAAGJ,EAAE,CAACC,OAAO,CAACC,KAAK,CAACE,IAAI;CAClC,MAAMC,IAAI,GAAGL,EAAE,CAACC,OAAO,CAACC,KAAK,CAACG,IAAI;AAElC,CAAO,MAAMC,IAAI,SAASC,oBAAG,CAC7B;GACCC,WAAW,CAACC,OAAO,EACnB;KACC,KAAK,CAACA,OAAO,CAAC;KACd,IAAI,CAACC,IAAI,GAAG,MAAM;KAClB,IAAI,CAACC,IAAI,CAACC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAACC,OAAO,CAACC,IAAI,CAAC,IAAI,CAAC,CAAC;;;;CAI9D;CACA;CACA;GACCC,QAAQ,GACR;KACC,IAAI,IAAI,CAACC,KAAK,EACd;OACC,IAAI,CAACA,KAAK,CA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