diff --git a/build/index.asset.php b/build/index.asset.php index 5f5941a..5706514 100644 --- a/build/index.asset.php +++ b/build/index.asset.php @@ -1 +1 @@ - array('wp-block-editor', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives', 'wp-rich-text'), 'version' => '993b2ef7b5a4436e4110'); + array('wp-block-editor', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives', 'wp-rich-text'), 'version' => '070b1fa722a75063a380'); diff --git a/build/index.js b/build/index.js index e21304a..414f134 100644 --- a/build/index.js +++ b/build/index.js @@ -58,8 +58,8 @@ function getThematiqueFamilySlug(thematique_slug) { case "urbanisme": return "energies-urbanisme"; case "patrimoine": - case "renovation": - return "patrimoine-renovation"; + case "sante-et-securite": + return "patrimoine-sante-securite"; case "location": return "location"; } diff --git a/build/index.js.map b/build/index.js.map index 4b7b602..994be09 100644 --- a/build/index.js.map +++ b/build/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","mappings":";;;;;;;;;;;;;;;;;;AAAmD;;AAEnD;AACA;AACA;AACkD;AAClD,cAAc,iEAAa,CAAC,sDAAG;AAC/B;AACA;AACA,CAAC,EAAE,iEAAa,CAAC,uDAAI;AACrB;AACA,CAAC;AACD,iEAAe,KAAK,EAAC;AACrB;;;;;;;;;;;;;;ACbO,SAASA,uBAAuBA,CAACC,eAAe,EAAE;EACxD,QAAQA,eAAe;IACtB,KAAK,SAAS;IACd,KAAK,WAAW;MACf,OAAO,oBAAoB;IAE5B,KAAK,YAAY;IACjB,KAAK,sBAAsB;MAC1B,OAAO,yBAAyB;IAEjC,KAAK,WAAW;IAChB,KAAK,cAAc;MAClB,OAAO,qBAAqB;IAE7B,KAAK,UAAU;IACf,KAAK,WAAW;MACf,OAAO,oBAAoB;IAE5B,KAAK,YAAY;IACjB,KAAK,YAAY;MAChB,OAAO,uBAAuB;IAE/B,KAAK,UAAU;MACd,OAAO,UAAU;EACnB;AACD;;;;;;;;;;;;;;;;;;;;;;;;;ACzBuG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,CAACvC,QAAQ,GAAG,qBAAqB,GAAG,mBAAoB;IAC/DwC,OAAO,EAAEA,CAAA,KAAM;MACdpC,gBAAgB,CAAC,IAAI,CAAC;IACvB;EAAE,CACF,CAAC,EACDJ,QAAQ,IACRgC,iEAAA,CAACzC,gEAAa;IACb+C,IAAI,EAAE5C,wDAAM;IACZ6C,KAAK,EAAE,sBAAuB;IAC9BC,OAAO,EAAEA,CAAA,KAAM;MACdT,YAAY,CAAC,CAAC;IACf;EAAE,CACF,CAEW,CACA,CACd,CAAC;AAEL,CAAC;AAEDnD,wEAAkB,CAACiB,UAAU,EAAE;EAC9B4C,KAAK,EAAEzD,mDAAE,CAAC,SAAS,EAAE,kBAAkB,CAAC;EACxC0D,OAAO,EAAE,QAAQ;EACjB3B,UAAU,EAAE;IACX6C,YAAY,EAAE,oBAAoB;IAClCG,qBAAqB,EAAE,yBAAyB;IAChDF,eAAe,EAAE;EAClB,CAAC;EACD1B,SAAS,EAAE,cAAc;EACzBS,IAAI,EAAEC;AACP,CAAC,CAAC;;;;;;;;;;;ACpJF;;;;;;;;;;;;ACAA;;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;UCAA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;;WCtBA;WACA;WACA;WACA;WACA;WACA,iCAAiC,WAAW;WAC5C;WACA;;;;;WCPA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA;;;;;WCPA;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D;;;;;;;;;;;;;;;;ACN4C;AACD;AAEX;AACc","sources":["webpack://multi-blocks/./node_modules/@wordpress/icons/build-module/library/trash.js","webpack://multi-blocks/./blocks/utilities.js","webpack://multi-blocks/./src/format-types/brochure/brochure.js","webpack://multi-blocks/./src/format-types/tooltip/tooltip.js","webpack://multi-blocks/./src/format-types/brochure/brochure.css?c994","webpack://multi-blocks/./src/format-types/tooltip/tooltip.css?0248","webpack://multi-blocks/external window [\"wp\",\"blockEditor\"]","webpack://multi-blocks/external window [\"wp\",\"components\"]","webpack://multi-blocks/external window [\"wp\",\"data\"]","webpack://multi-blocks/external window [\"wp\",\"element\"]","webpack://multi-blocks/external window [\"wp\",\"i18n\"]","webpack://multi-blocks/external window [\"wp\",\"primitives\"]","webpack://multi-blocks/external window [\"wp\",\"richText\"]","webpack://multi-blocks/webpack/bootstrap","webpack://multi-blocks/webpack/runtime/compat get default export","webpack://multi-blocks/webpack/runtime/define property getters","webpack://multi-blocks/webpack/runtime/hasOwnProperty shorthand","webpack://multi-blocks/webpack/runtime/make namespace object","webpack://multi-blocks/./src/index.js"],"sourcesContent":["import { createElement } from \"@wordpress/element\";\n\n/**\n * WordPress dependencies\n */\nimport { SVG, Path } from '@wordpress/primitives';\nconst trash = createElement(SVG, {\n xmlns: \"http://www.w3.org/2000/svg\",\n viewBox: \"0 0 24 24\"\n}, createElement(Path, {\n d: \"M20 5h-5.7c0-1.3-1-2.3-2.3-2.3S9.7 3.7 9.7 5H4v2h1.5v.3l1.7 11.1c.1 1 1 1.7 2 1.7h5.7c1 0 1.8-.7 2-1.7l1.7-11.1V7H20V5zm-3.2 2l-1.7 11.1c0 .1-.1.2-.3.2H9.1c-.1 0-.3-.1-.3-.2L7.2 7h9.6z\"\n}));\nexport default trash;\n//# sourceMappingURL=trash.js.map","export function getThematiqueFamilySlug(thematique_slug) {\r\n\tswitch (thematique_slug) {\r\n\t\tcase \"energie\":\r\n\t\tcase \"urbanisme\":\r\n\t\t\treturn \"energies-urbanisme\";\r\n\r\n\t\tcase \"acoustique\":\r\n\t\tcase \"petites-coproprietes\":\r\n\t\t\treturn \"acoustique-coproprietes\";\r\n\r\n\t\tcase \"isolation\":\r\n\t\tcase \"au-quotidien\":\r\n\t\t\treturn \"isolation-quotidien\";\r\n\r\n\t\tcase \"energies\":\r\n\t\tcase \"urbanisme\":\r\n\t\t\treturn \"energies-urbanisme\";\r\n\r\n\t\tcase \"patrimoine\":\r\n\t\tcase \"renovation\":\r\n\t\t\treturn \"patrimoine-renovation\";\r\n\r\n\t\tcase \"location\":\r\n\t\t\treturn \"location\";\r\n\t}\r\n}\r\n","import { registerFormatType, toggleFormat, applyFormat, getActiveFormats } from \"@wordpress/rich-text\";\r\nimport { __ } from \"@wordpress/i18n\";\r\nimport { BlockControls, __experimentalLinkControl as LinkControl } from \"@wordpress/block-editor\";\r\nimport { Popover, Button } from \"@wordpress/components\";\r\n\r\nimport { ToolbarGroup, ToolbarButton, TextareaControl } from \"@wordpress/components\";\r\nimport { check, trash } from \"@wordpress/icons\";\r\n\r\nimport { useState } from \"@wordpress/element\";\r\nimport { useSelect } from \"@wordpress/data\"; // pour les querry\r\n\r\nconst formatName = \"homegrade-format/brochure-format\";\r\n\r\nconst BrochureLinkFormatButton = (props) => {\r\n\tconst { isActive, value, onChange } = props;\r\n\tconst [isPopoverOpen, setIsPopoverOpen] = useState(false);\r\n\tconst [relatedPost, setRelatedPost] = useState(\"\");\r\n\tconst [pendingBrochure, setPendingBrochure] = useState(false);\r\n\r\n\tconst activeFormat = getActiveFormats(value).filter((format) => format.type === formatName)[0];\r\n\r\n\tconst brochurePost = useSelect((select) => {\r\n\t\tif (activeFormat && activeFormat.attributes.brochurePostID) {\r\n\t\t\treturn select(\"core\").getEntityRecord(\r\n\t\t\t\t\"postType\",\r\n\t\t\t\t\"brochures\",\r\n\t\t\t\tactiveFormat.attributes.brochurePostID\r\n\t\t\t);\r\n\t\t}\r\n\t});\r\n\r\n\tconst brochureAttachedMedia = useSelect((select) => {\r\n\t\tif (brochurePost && brochurePost.acf && brochurePost.acf.brochure_pdf) {\r\n\t\t\treturn select(\"core\").getEntityRecord(\"postType\", \"attachment\", brochurePost.acf.brochure_pdf);\r\n\t\t}\r\n\t});\r\n\r\n\tfunction setFormat(postDatas) {\r\n\t\tconsole.log(\"postdata\", postDatas);\r\n\t\tsetIsPopoverOpen(!isPopoverOpen);\r\n\t\tsetPendingBrochure(true);\r\n\t\tonChange(\r\n\t\t\tapplyFormat(value, {\r\n\t\t\t\ttype: formatName,\r\n\t\t\t\tattributes: {\r\n\t\t\t\t\thref: postDatas.url,\r\n\t\t\t\t\tbrochurePostID: postDatas.id.toString(),\r\n\t\t\t\t\ttarget: \"_blank\",\r\n\t\t\t\t\tstyle: \"text-decoration: underline;\",\r\n\t\t\t\t},\r\n\t\t\t})\r\n\t\t);\r\n\t}\r\n\r\n\tfunction removeFormat() {\r\n\t\tsetIsPopoverOpen(false);\r\n\t\tonChange(\r\n\t\t\ttoggleFormat(value, {\r\n\t\t\t\ttype: formatName,\r\n\t\t\t})\r\n\t\t);\r\n\t}\r\n\r\n\t// if (brochurePost && brochureAttachedMedia && pendingBrochure) {\r\n\t// \tonChange(\r\n\t// \t\tapplyFormat(value, {\r\n\t// \t\t\ttype: formatName,\r\n\t// \t\t\tattributes: {\r\n\t// \t\t\t\ttarget: \"_blank\",\r\n\t// \t\t\t\tbrochurePostID: brochurePost.id.toString(),\r\n\t// \t\t\t\tbrochureID: brochureAttachedMedia.id.toString(),\r\n\t// \t\t\t\thref: brochurePost.link,\r\n\t// \t\t\t\tstyle: \"text-decoration: underline;\",\r\n\t// \t\t\t},\r\n\t// \t\t})\r\n\t// \t);\r\n\t// \tsetPendingBrochure(false);\r\n\t// }\r\n\r\n\treturn (\r\n\t\t<>\r\n\t\t\t\r\n\t\t\t\t{isPopoverOpen && (\r\n\t\t\t\t\t setIsPopoverOpen(false)}\r\n\t\t\t\t\t\tclassName='popover_tooltip_field'>\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t)}\r\n\r\n\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\t!isActive ? setIsPopoverOpen(!isPopoverOpen) : removeFormat()\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t/>\r\n\t\t\t\t\r\n\t\t\t\r\n\t\t\r\n\t);\r\n};\r\n\r\nregisterFormatType(\"homegrade-format/brochure-format\", {\r\n\ttitle: \"Lien Brochure/Fiche-info\",\r\n\ttagName: \"a\",\r\n\tattributes: {\r\n\t\tbrochureID: \"brochure-id\",\r\n\t\tbrochurePostID: \"brochure-post-id\",\r\n\t},\r\n\tclassName: \"brochure-link-format\",\r\n\tedit: BrochureLinkFormatButton,\r\n});\r\n","import { __ } from \"@wordpress/i18n\";\r\nimport { registerFormatType, toggleFormat, applyFormat, getActiveFormats } from \"@wordpress/rich-text\";\r\n\r\nimport { BlockControls, __experimentalLinkControl as LinkControl } from \"@wordpress/block-editor\";\r\nimport { Popover, ToolbarGroup, ToolbarButton } from \"@wordpress/components\";\r\nimport { trash } from \"@wordpress/icons\";\r\nimport { useState } from \"@wordpress/element\";\r\nimport { useSelect } from \"@wordpress/data\"; // pour les querry\r\n\r\nconst formatName = \"homegrade-format/tooltip\";\r\n\r\nconst Edit = (props) => {\r\n\tconst { isActive, value, onChange } = props;\r\n\tconst [isPopoverOpen, setIsPopoverOpen] = useState(false);\r\n\tconst [pendingDefinition, setPendingDefinition] = useState(false);\r\n\r\n\tconst activeFormat = getActiveFormats(value).filter((format) => format.type === formatName)[0];\r\n\tconst lang = getAdminLanguageFromCookie(\"wp-wpml_current_language\");\r\n\r\n\tfunction getAdminLanguageFromCookie(c_name) {\r\n\t\tvar c_value = document.cookie,\r\n\t\t\tc_start = c_value.indexOf(\" \" + c_name + \"=\");\r\n\t\tif (c_start == -1) c_start = c_value.indexOf(c_name + \"=\");\r\n\t\tif (c_start == -1) {\r\n\t\t\tc_value = null;\r\n\t\t} else {\r\n\t\t\tc_start = c_value.indexOf(\"=\", c_start) + 1;\r\n\t\t\tvar c_end = c_value.indexOf(\";\", c_start);\r\n\t\t\tif (c_end == -1) {\r\n\t\t\t\tc_end = c_value.length;\r\n\t\t\t}\r\n\t\t\tc_value = unescape(c_value.substring(c_start, c_end));\r\n\t\t}\r\n\t\treturn c_value;\r\n\t}\r\n\tfunction removeFormat() {\r\n\t\tsetIsPopoverOpen(false);\r\n\t\tonChange(\r\n\t\t\ttoggleFormat(value, {\r\n\t\t\t\ttype: formatName,\r\n\t\t\t})\r\n\t\t);\r\n\t}\r\n\tfunction setFormat(postDatas) {\r\n\t\tsetPendingDefinition(true);\r\n\t\tsetIsPopoverOpen(false);\r\n\r\n\t\tonChange(\r\n\t\t\tapplyFormat(value, {\r\n\t\t\t\ttype: formatName,\r\n\t\t\t\tattributes: {\r\n\t\t\t\t\tdefinitionId: postDatas.id.toString(),\r\n\t\t\t\t\tdataTooltipWord: postDatas.title,\r\n\t\t\t\t},\r\n\t\t\t})\r\n\t\t);\r\n\t}\r\n\r\n\tconst post = useSelect((select) => {\r\n\t\tif (activeFormat && activeFormat.attributes.definitionId) {\r\n\t\t\treturn select(\"core\").getEntityRecord(\r\n\t\t\t\t\"postType\",\r\n\t\t\t\t\"vocabulaire\",\r\n\t\t\t\tactiveFormat.attributes.definitionId\r\n\t\t\t);\r\n\t\t}\r\n\t});\r\n\r\n\tif (post && pendingDefinition) {\r\n\t\tonChange(\r\n\t\t\tapplyFormat(value, {\r\n\t\t\t\ttype: formatName,\r\n\t\t\t\tattributes: {\r\n\t\t\t\t\tdataTooltipDefinition: post.acf.definition,\r\n\t\t\t\t\tdefinitionId: activeFormat.attributes.definitionId,\r\n\t\t\t\t\tdataTooltipWord: activeFormat.attributes.dataTooltipWord,\r\n\t\t\t\t},\r\n\t\t\t})\r\n\t\t);\r\n\t\tsetPendingDefinition(false);\r\n\t}\r\n\r\n\treturn (\r\n\t\t<>\r\n\t\t\t\r\n\t\t\t\t{isPopoverOpen && (\r\n\t\t\t\t\t setIsPopoverOpen(false)}\r\n\t\t\t\t\t\tclassName='popover_tooltip_field'>\r\n\t\t\t\t\t\t setFormat(postDatas)}\r\n\t\t\t\t\t\t/>\r\n\t\t\t\t\t\r\n\t\t\t\t)}\r\n\r\n\t\t\t\t\r\n\t\t\t\t\t {\r\n\t\t\t\t\t\t\tsetIsPopoverOpen(true);\r\n\t\t\t\t\t\t}}\r\n\t\t\t\t\t/>\r\n\t\t\t\t\t{isActive && (\r\n\t\t\t\t\t\t {\r\n\t\t\t\t\t\t\t\tremoveFormat();\r\n\t\t\t\t\t\t\t}}\r\n\t\t\t\t\t\t/>\r\n\t\t\t\t\t)}\r\n\t\t\t\t\r\n\t\t\t\r\n\t\t\r\n\t);\r\n};\r\n\r\nregisterFormatType(formatName, {\r\n\ttitle: __(\"Tooltip\", \"homegrade-format\"),\r\n\ttagName: \"button\",\r\n\tattributes: {\r\n\t\tdefinitionId: \"data-definition-id\",\r\n\t\tdataTooltipDefinition: \"data-tooltip-definition\",\r\n\t\tdataTooltipWord: \"data-tooltip-word\",\r\n\t},\r\n\tclassName: \"tooltip-word\",\r\n\tedit: Edit,\r\n});\r\n","// extracted by mini-css-extract-plugin\nexport {};","// extracted by mini-css-extract-plugin\nexport {};","module.exports = window[\"wp\"][\"blockEditor\"];","module.exports = window[\"wp\"][\"components\"];","module.exports = window[\"wp\"][\"data\"];","module.exports = window[\"wp\"][\"element\"];","module.exports = window[\"wp\"][\"i18n\"];","module.exports = window[\"wp\"][\"primitives\"];","module.exports = window[\"wp\"][\"richText\"];","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import \"./format-types/tooltip/tooltip.css\";\r\nimport \"./format-types/tooltip/tooltip.js\";\r\n\r\nimport \"../blocks/utilities.js\";\r\nimport \"./format-types/brochure/brochure.css\";\r\nimport \"./format-types/brochure/brochure.js\";\r\n"],"names":["getThematiqueFamilySlug","thematique_slug","registerFormatType","toggleFormat","applyFormat","getActiveFormats","__","BlockControls","__experimentalLinkControl","LinkControl","Popover","Button","ToolbarGroup","ToolbarButton","TextareaControl","check","trash","useState","useSelect","formatName","BrochureLinkFormatButton","props","isActive","value","onChange","isPopoverOpen","setIsPopoverOpen","relatedPost","setRelatedPost","pendingBrochure","setPendingBrochure","activeFormat","filter","format","type","brochurePost","select","attributes","brochurePostID","getEntityRecord","brochureAttachedMedia","acf","brochure_pdf","setFormat","postDatas","console","log","href","url","id","toString","target","style","removeFormat","createElement","Fragment","onClose","className","suggestionsQuery","subtype","icon","label","onClick","title","tagName","brochureID","edit","Edit","pendingDefinition","setPendingDefinition","lang","getAdminLanguageFromCookie","c_name","c_value","document","cookie","c_start","indexOf","c_end","length","unescape","substring","definitionId","dataTooltipWord","post","dataTooltipDefinition","definition","link","tile","kind","isCollapsed"],"sourceRoot":""} \ No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,CAAC;EACD1B,SAAS,EAAE,cAAc;EACzBS,IAAI,EAAEC;AACP,CAAC,CAAC;;;;;;;;;;;ACpJF;;;;;;;;;;;;ACAA;;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;UCAA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;;WCtBA;WACA;WACA;WACA;WACA;WACA,iCAAiC,WAAW;WAC5C;WACA;;;;;WCPA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA;;;;;WCPA;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D;;;;;;;;;;;;;;;;ACN4C;AACD;AAEX;AACc","sources":["webpack://multi-blocks/./node_modules/@wordpress/icons/build-module/library/trash.js","webpack://multi-blocks/./blocks/utilities.js","webpack://multi-blocks/./src/format-types/brochure/brochure.js","webpack://multi-blocks/./src/format-types/tooltip/tooltip.js","webpack://multi-blocks/./src/format-types/brochure/brochure.css?c994","webpack://multi-blocks/./src/format-types/tooltip/tooltip.css?0248","webpack://multi-blocks/external window [\"wp\",\"blockEditor\"]","webpack://multi-blocks/external window [\"wp\",\"components\"]","webpack://multi-blocks/external window [\"wp\",\"data\"]","webpack://multi-blocks/external window [\"wp\",\"element\"]","webpack://multi-blocks/external window [\"wp\",\"i18n\"]","webpack://multi-blocks/external window [\"wp\",\"primitives\"]","webpack://multi-blocks/external window [\"wp\",\"richText\"]","webpack://multi-blocks/webpack/bootstrap","webpack://multi-blocks/webpack/runtime/compat get default export","webpack://multi-blocks/webpack/runtime/define property getters","webpack://multi-blocks/webpack/runtime/hasOwnProperty shorthand","webpack://multi-blocks/webpack/runtime/make namespace object","webpack://multi-blocks/./src/index.js"],"sourcesContent":["import { createElement } from \"@wordpress/element\";\n\n/**\n * WordPress dependencies\n */\nimport { SVG, Path } from '@wordpress/primitives';\nconst trash = createElement(SVG, {\n xmlns: \"http://www.w3.org/2000/svg\",\n viewBox: \"0 0 24 24\"\n}, createElement(Path, {\n d: \"M20 5h-5.7c0-1.3-1-2.3-2.3-2.3S9.7 3.7 9.7 5H4v2h1.5v.3l1.7 11.1c.1 1 1 1.7 2 1.7h5.7c1 0 1.8-.7 2-1.7l1.7-11.1V7H20V5zm-3.2 2l-1.7 11.1c0 .1-.1.2-.3.2H9.1c-.1 0-.3-.1-.3-.2L7.2 7h9.6z\"\n}));\nexport default trash;\n//# sourceMappingURL=trash.js.map","export function getThematiqueFamilySlug(thematique_slug) {\r\n\tswitch (thematique_slug) {\r\n\t\tcase \"energie\":\r\n\t\tcase \"urbanisme\":\r\n\t\t\treturn \"energies-urbanisme\";\r\n\r\n\t\tcase \"acoustique\":\r\n\t\tcase \"petites-coproprietes\":\r\n\t\t\treturn \"acoustique-coproprietes\";\r\n\r\n\t\tcase \"isolation\":\r\n\t\tcase \"au-quotidien\":\r\n\t\t\treturn \"isolation-quotidien\";\r\n\r\n\t\tcase \"energies\":\r\n\t\tcase \"urbanisme\":\r\n\t\t\treturn \"energies-urbanisme\";\r\n\r\n\t\tcase \"patrimoine\":\r\n\t\tcase \"sante-et-securite\":\r\n\t\t\treturn \"patrimoine-sante-securite\";\r\n\r\n\t\tcase \"location\":\r\n\t\t\treturn \"location\";\r\n\t}\r\n}\r\n","import { registerFormatType, toggleFormat, applyFormat, getActiveFormats } from \"@wordpress/rich-text\";\r\nimport { __ } from \"@wordpress/i18n\";\r\nimport { BlockControls, __experimentalLinkControl as LinkControl } from \"@wordpress/block-editor\";\r\nimport { Popover, Button } from \"@wordpress/components\";\r\n\r\nimport { ToolbarGroup, ToolbarButton, TextareaControl } from \"@wordpress/components\";\r\nimport { check, trash } from \"@wordpress/icons\";\r\n\r\nimport { useState } from \"@wordpress/element\";\r\nimport { useSelect } from \"@wordpress/data\"; // pour les querry\r\n\r\nconst formatName = \"homegrade-format/brochure-format\";\r\n\r\nconst BrochureLinkFormatButton = (props) => {\r\n\tconst { isActive, value, onChange } = props;\r\n\tconst [isPopoverOpen, setIsPopoverOpen] = useState(false);\r\n\tconst [relatedPost, setRelatedPost] = useState(\"\");\r\n\tconst [pendingBrochure, setPendingBrochure] = useState(false);\r\n\r\n\tconst activeFormat = getActiveFormats(value).filter((format) => format.type === formatName)[0];\r\n\r\n\tconst brochurePost = useSelect((select) => {\r\n\t\tif (activeFormat && activeFormat.attributes.brochurePostID) {\r\n\t\t\treturn select(\"core\").getEntityRecord(\r\n\t\t\t\t\"postType\",\r\n\t\t\t\t\"brochures\",\r\n\t\t\t\tactiveFormat.attributes.brochurePostID\r\n\t\t\t);\r\n\t\t}\r\n\t});\r\n\r\n\tconst brochureAttachedMedia = useSelect((select) => {\r\n\t\tif (brochurePost && brochurePost.acf && brochurePost.acf.brochure_pdf) {\r\n\t\t\treturn select(\"core\").getEntityRecord(\"postType\", \"attachment\", brochurePost.acf.brochure_pdf);\r\n\t\t}\r\n\t});\r\n\r\n\tfunction setFormat(postDatas) {\r\n\t\tconsole.log(\"postdata\", postDatas);\r\n\t\tsetIsPopoverOpen(!isPopoverOpen);\r\n\t\tsetPendingBrochure(true);\r\n\t\tonChange(\r\n\t\t\tapplyFormat(value, {\r\n\t\t\t\ttype: formatName,\r\n\t\t\t\tattributes: {\r\n\t\t\t\t\thref: postDatas.url,\r\n\t\t\t\t\tbrochurePostID: postDatas.id.toString(),\r\n\t\t\t\t\ttarget: \"_blank\",\r\n\t\t\t\t\tstyle: \"text-decoration: underline;\",\r\n\t\t\t\t},\r\n\t\t\t})\r\n\t\t);\r\n\t}\r\n\r\n\tfunction removeFormat() {\r\n\t\tsetIsPopoverOpen(false);\r\n\t\tonChange(\r\n\t\t\ttoggleFormat(value, {\r\n\t\t\t\ttype: formatName,\r\n\t\t\t})\r\n\t\t);\r\n\t}\r\n\r\n\t// if (brochurePost && brochureAttachedMedia && pendingBrochure) {\r\n\t// \tonChange(\r\n\t// \t\tapplyFormat(value, {\r\n\t// \t\t\ttype: formatName,\r\n\t// \t\t\tattributes: {\r\n\t// \t\t\t\ttarget: \"_blank\",\r\n\t// \t\t\t\tbrochurePostID: brochurePost.id.toString(),\r\n\t// \t\t\t\tbrochureID: brochureAttachedMedia.id.toString(),\r\n\t// \t\t\t\thref: brochurePost.link,\r\n\t// \t\t\t\tstyle: \"text-decoration: underline;\",\r\n\t// \t\t\t},\r\n\t// \t\t})\r\n\t// \t);\r\n\t// \tsetPendingBrochure(false);\r\n\t// }\r\n\r\n\treturn (\r\n\t\t<>\r\n\t\t\t\r\n\t\t\t\t{isPopoverOpen && (\r\n\t\t\t\t\t setIsPopoverOpen(false)}\r\n\t\t\t\t\t\tclassName='popover_tooltip_field'>\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t)}\r\n\r\n\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\t!isActive ? setIsPopoverOpen(!isPopoverOpen) : removeFormat()\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t/>\r\n\t\t\t\t\r\n\t\t\t\r\n\t\t\r\n\t);\r\n};\r\n\r\nregisterFormatType(\"homegrade-format/brochure-format\", {\r\n\ttitle: \"Lien Brochure/Fiche-info\",\r\n\ttagName: \"a\",\r\n\tattributes: {\r\n\t\tbrochureID: \"brochure-id\",\r\n\t\tbrochurePostID: \"brochure-post-id\",\r\n\t},\r\n\tclassName: \"brochure-link-format\",\r\n\tedit: BrochureLinkFormatButton,\r\n});\r\n","import { __ } from \"@wordpress/i18n\";\r\nimport { registerFormatType, toggleFormat, applyFormat, getActiveFormats } from \"@wordpress/rich-text\";\r\n\r\nimport { BlockControls, __experimentalLinkControl as LinkControl } from \"@wordpress/block-editor\";\r\nimport { Popover, ToolbarGroup, ToolbarButton } from \"@wordpress/components\";\r\nimport { trash } from \"@wordpress/icons\";\r\nimport { useState } from \"@wordpress/element\";\r\nimport { useSelect } from \"@wordpress/data\"; // pour les querry\r\n\r\nconst formatName = \"homegrade-format/tooltip\";\r\n\r\nconst Edit = (props) => {\r\n\tconst { isActive, value, onChange } = props;\r\n\tconst [isPopoverOpen, setIsPopoverOpen] = useState(false);\r\n\tconst [pendingDefinition, setPendingDefinition] = useState(false);\r\n\r\n\tconst activeFormat = getActiveFormats(value).filter((format) => format.type === formatName)[0];\r\n\tconst lang = getAdminLanguageFromCookie(\"wp-wpml_current_language\");\r\n\r\n\tfunction getAdminLanguageFromCookie(c_name) {\r\n\t\tvar c_value = document.cookie,\r\n\t\t\tc_start = c_value.indexOf(\" \" + c_name + \"=\");\r\n\t\tif (c_start == -1) c_start = c_value.indexOf(c_name + \"=\");\r\n\t\tif (c_start == -1) {\r\n\t\t\tc_value = null;\r\n\t\t} else {\r\n\t\t\tc_start = c_value.indexOf(\"=\", c_start) + 1;\r\n\t\t\tvar c_end = c_value.indexOf(\";\", c_start);\r\n\t\t\tif (c_end == -1) {\r\n\t\t\t\tc_end = c_value.length;\r\n\t\t\t}\r\n\t\t\tc_value = unescape(c_value.substring(c_start, c_end));\r\n\t\t}\r\n\t\treturn c_value;\r\n\t}\r\n\tfunction removeFormat() {\r\n\t\tsetIsPopoverOpen(false);\r\n\t\tonChange(\r\n\t\t\ttoggleFormat(value, {\r\n\t\t\t\ttype: formatName,\r\n\t\t\t})\r\n\t\t);\r\n\t}\r\n\tfunction setFormat(postDatas) {\r\n\t\tsetPendingDefinition(true);\r\n\t\tsetIsPopoverOpen(false);\r\n\r\n\t\tonChange(\r\n\t\t\tapplyFormat(value, {\r\n\t\t\t\ttype: formatName,\r\n\t\t\t\tattributes: {\r\n\t\t\t\t\tdefinitionId: postDatas.id.toString(),\r\n\t\t\t\t\tdataTooltipWord: postDatas.title,\r\n\t\t\t\t},\r\n\t\t\t})\r\n\t\t);\r\n\t}\r\n\r\n\tconst post = useSelect((select) => {\r\n\t\tif (activeFormat && activeFormat.attributes.definitionId) {\r\n\t\t\treturn select(\"core\").getEntityRecord(\r\n\t\t\t\t\"postType\",\r\n\t\t\t\t\"vocabulaire\",\r\n\t\t\t\tactiveFormat.attributes.definitionId\r\n\t\t\t);\r\n\t\t}\r\n\t});\r\n\r\n\tif (post && pendingDefinition) {\r\n\t\tonChange(\r\n\t\t\tapplyFormat(value, {\r\n\t\t\t\ttype: formatName,\r\n\t\t\t\tattributes: {\r\n\t\t\t\t\tdataTooltipDefinition: post.acf.definition,\r\n\t\t\t\t\tdefinitionId: activeFormat.attributes.definitionId,\r\n\t\t\t\t\tdataTooltipWord: activeFormat.attributes.dataTooltipWord,\r\n\t\t\t\t},\r\n\t\t\t})\r\n\t\t);\r\n\t\tsetPendingDefinition(false);\r\n\t}\r\n\r\n\treturn (\r\n\t\t<>\r\n\t\t\t\r\n\t\t\t\t{isPopoverOpen && (\r\n\t\t\t\t\t setIsPopoverOpen(false)}\r\n\t\t\t\t\t\tclassName='popover_tooltip_field'>\r\n\t\t\t\t\t\t setFormat(postDatas)}\r\n\t\t\t\t\t\t/>\r\n\t\t\t\t\t\r\n\t\t\t\t)}\r\n\r\n\t\t\t\t\r\n\t\t\t\t\t {\r\n\t\t\t\t\t\t\tsetIsPopoverOpen(true);\r\n\t\t\t\t\t\t}}\r\n\t\t\t\t\t/>\r\n\t\t\t\t\t{isActive && (\r\n\t\t\t\t\t\t {\r\n\t\t\t\t\t\t\t\tremoveFormat();\r\n\t\t\t\t\t\t\t}}\r\n\t\t\t\t\t\t/>\r\n\t\t\t\t\t)}\r\n\t\t\t\t\r\n\t\t\t\r\n\t\t\r\n\t);\r\n};\r\n\r\nregisterFormatType(formatName, {\r\n\ttitle: __(\"Tooltip\", \"homegrade-format\"),\r\n\ttagName: \"button\",\r\n\tattributes: {\r\n\t\tdefinitionId: \"data-definition-id\",\r\n\t\tdataTooltipDefinition: \"data-tooltip-definition\",\r\n\t\tdataTooltipWord: \"data-tooltip-word\",\r\n\t},\r\n\tclassName: \"tooltip-word\",\r\n\tedit: Edit,\r\n});\r\n","// extracted by mini-css-extract-plugin\nexport {};","// extracted by mini-css-extract-plugin\nexport {};","module.exports = window[\"wp\"][\"blockEditor\"];","module.exports = window[\"wp\"][\"components\"];","module.exports = window[\"wp\"][\"data\"];","module.exports = window[\"wp\"][\"element\"];","module.exports = window[\"wp\"][\"i18n\"];","module.exports = window[\"wp\"][\"primitives\"];","module.exports = window[\"wp\"][\"richText\"];","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import \"./format-types/tooltip/tooltip.css\";\r\nimport \"./format-types/tooltip/tooltip.js\";\r\n\r\nimport \"../blocks/utilities.js\";\r\nimport \"./format-types/brochure/brochure.css\";\r\nimport \"./format-types/brochure/brochure.js\";\r\n"],"names":["getThematiqueFamilySlug","thematique_slug","registerFormatType","toggleFormat","applyFormat","getActiveFormats","__","BlockControls","__experimentalLinkControl","LinkControl","Popover","Button","ToolbarGroup","ToolbarButton","TextareaControl","check","trash","useState","useSelect","formatName","BrochureLinkFormatButton","props","isActive","value","onChange","isPopoverOpen","setIsPopoverOpen","relatedPost","setRelatedPost","pendingBrochure","setPendingBrochure","activeFormat","filter","format","type","brochurePost","select","attributes","brochurePostID","getEntityRecord","brochureAttachedMedia","acf","brochure_pdf","setFormat","postDatas","console","log","href","url","id","toString","target","style","removeFormat","createElement","Fragment","onClose","className","suggestionsQuery","subtype","icon","label","onClick","title","tagName","brochureID","edit","Edit","pendingDefinition","setPendingDefinition","lang","getAdminLanguageFromCookie","c_name","c_value","document","cookie","c_start","indexOf","c_end","length","unescape","substring","definitionId","dataTooltipWord","post","dataTooltipDefinition","definition","link","tile","kind","isCollapsed"],"sourceRoot":""} \ No newline at end of file diff --git a/build/tooltipFront.asset.php b/build/tooltipFront.asset.php index 1f66e9c..20c431b 100644 --- a/build/tooltipFront.asset.php +++ b/build/tooltipFront.asset.php @@ -1 +1 @@ - array(), 'version' => '434e8e7be8d10dd950b8'); + array(), 'version' => '64eafff4867d071b75c0'); diff --git a/build/tooltipFront.js b/build/tooltipFront.js index d373482..82870a1 100644 --- a/build/tooltipFront.js +++ b/build/tooltipFront.js @@ -1,8 +1,8 @@ /******/ (() => { // webpackBootstrap var __webpack_exports__ = {}; -/*!*******************************************************!*\ - !*** ./src/format-types/tooltip/tooltip-front_new.js ***! - \*******************************************************/ +/*!***************************************************!*\ + !*** ./src/format-types/tooltip/tooltip-front.js ***! + \***************************************************/ async function tooltipsInit() { await buildTooltips(); await observeTooltips(); diff --git a/build/tooltipFront.js.map b/build/tooltipFront.js.map index 4efd70c..54ab8d9 100644 --- a/build/tooltipFront.js.map +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C9E,IAAI,CAACrD,YAAY,EAAE;EACnBA,YAAY,CAACC,YAAY,CAAC,aAAa,EAAE,OAAO,CAAC;EACjD;AACD;;AACA,SAAS0D,WAAWA,CAAChE,WAAW,EAAE;EACjCA,WAAW,CAACM,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC;EAClD;EACA,MAAMD,YAAY,GAAGL,WAAW,CAACoE,kBAAkB;EACnD,IAAI,CAAC/D,YAAY,IAAI,CAACA,YAAY,CAACgE,SAAS,CAACC,QAAQ,CAAC,eAAe,CAAC,EAAE;EACxEjE,YAAY,CAACC,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC;AACjD;AACA,SAASwD,aAAaA,CAAC9D,WAAW,EAAE;EACnC,MAAMuE,UAAU,GAAGvE,WAAW,CAACS,YAAY,CAAC,eAAe,CAAC,KAAK,MAAM;EACvE,IAAI8D,UAAU,EAAE;IACfP,WAAW,CAAChE,WAAW,CAAC;EACzB,CAAC,MAAM;IACNiE,WAAW,CAACjE,WAAW,CAAC;EACzB;AACD;AAEA,SAAS4C,aAAaA,CAACL,KAAK,EAAE;EAC7B,OAAOX,QAAQ,CAAC4C,gBAAgB,CAACjC,KAAK,CAACS,MAAM,EAAE,IAAI,CAAC,CAACyB,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAC/E;AAEApB,MAAM,CAACO,gBAAgB,CAAC,kBAAkB,EAAGC,KAAK,IAAK;EACtD5E,YAAY,CAAC,CAAC;AACf,CAAC,CAAC,C","sources":["webpack://multi-blocks/./src/format-types/tooltip/tooltip-front_new.js"],"sourcesContent":["async function tooltipsInit() {\r\n\tawait buildTooltips();\r\n\tawait observeTooltips();\r\n\t// const tooltipWordsContainer = document.querySelectorAll(\".tooltip-container\");\r\n\t// await observeTooltip(tooltipWordsContainer);\r\n}\r\nasync function getTooltipsDatas(vocabulairesPostsIds) {\r\n\ttry {\r\n\t\tconst response = await fetch(`/wp-json/wp/v2/vocabulaire?include=${vocabulairesPostsIds.toString()}`);\r\n\t\tif (!response.ok) {\r\n\t\t\tthrow new Error(`Request failed with status: ${response.status}`);\r\n\t\t}\r\n\t\tconst data = await response.json();\r\n\t\treturn data;\r\n\t} catch (err) {\r\n\t\tthrow err;\r\n\t}\r\n}\r\nfunction createTooltip(tooltipWord) {\r\n\tconst tooltipContainer = document.createElement(\"div\");\r\n\ttooltipContainer.className = \"tooltip-container\";\r\n\r\n\tconst tooltipPopup = document.createElement(\"span\");\r\n\ttooltipPopup.className = \"tooltip-popup\";\r\n\ttooltipPopup.setAttribute(\"aria-hidden\", \"true\");\r\n\r\n\tconst tooltipDefinition = document.createElement(\"p\");\r\n\ttooltipDefinition.textContent = tooltipWord.getAttribute(\"data-tooltip-definition\");\r\n\ttooltipDefinition.className = \"tooltip-popup__definition\";\r\n\r\n\tconst tooltipTitle = document.createElement(\"h5\");\r\n\ttooltipTitle.textContent = tooltipWord.getAttribute(\"data-tooltip-word\");\r\n\ttooltipTitle.className = \"tooltip-popup__title\";\r\n\r\n\ttooltipPopup.appendChild(tooltipTitle);\r\n\ttooltipPopup.appendChild(tooltipDefinition);\r\n\r\n\ttooltipContainer.appendChild(tooltipPopup);\r\n\ttooltipWord.insertAdjacentElement(\"afterend\", tooltipContainer);\r\n\ttooltipContainer.insertBefore(tooltipWord, tooltipPopup);\r\n\t// tooltipContainer.appendChild(tooltipWord);\r\n\t// tooltipWord.appendChild(tooltipContainer);\r\n}\r\nasync function buildTooltips() {\r\n\tlet tooltipWords = document.querySelectorAll(\".tooltip-word\");\r\n\tconst vocabulairesPostsIds = Array.from(tooltipWords).map((element) =>\r\n\t\telement.getAttribute(\"data-definition-id\")\r\n\t);\r\n\r\n\ttry {\r\n\t\tconst tooltipData = await getTooltipsDatas(vocabulairesPostsIds);\r\n\r\n\t\ttooltipWords.forEach((word, index) => {\r\n\t\t\tconst foundTooltipDatas = tooltipData.find(\r\n\t\t\t\t(tooltip) => tooltip.id === parseInt(word.getAttribute(\"data-definition-id\"))\r\n\t\t\t);\r\n\r\n\t\t\tif (foundTooltipDatas) {\r\n\t\t\t\tword.setAttribute(\"data-tooltip-word\", foundTooltipDatas.title.rendered);\r\n\t\t\t\tword.setAttribute(\"data-tooltip-definition\", foundTooltipDatas.acf.definition);\r\n\t\t\t}\r\n\t\t\tword.setAttribute(\"aria-expanded\", \"false\");\r\n\t\t\tcreateTooltip(word, tooltipData[index]);\r\n\t\t});\r\n\t} catch (error) {\r\n\t\tconsole.log(\"Something went wrong!\", error);\r\n\t}\r\n}\r\n\r\nasync function observeTooltips() {\r\n\tlet tooltipWords = document.querySelectorAll(\".tooltip-word\");\r\n\t// CHAPTER IntersectionObserver\r\n\tconst tooltipsObserver = new IntersectionObserver((entries) => {\r\n\t\tentries.forEach((entry) => {\r\n\t\t\tconst margin = 10;\r\n\r\n\t\t\t// DEPASSE À GAUCHE\r\n\t\t\tif (entry.boundingClientRect.x < 0) {\r\n\t\t\t\tconst currentPos = getCurrentPos(entry);\r\n\t\t\t\tconst missingSpace = Math.abs(entry.boundingClientRect.x);\r\n\t\t\t\tentry.target.style.left = `${currentPos + missingSpace + margin}px`;\r\n\t\t\t\tentry.target.style.setProperty(\"--tooltip-x-position\", \"12%\");\r\n\t\t\t}\r\n\t\t\t// DEPASSE À DROITE\r\n\t\t\tif (entry.boundingClientRect.x + entry.boundingClientRect.width > window.innerWidth) {\r\n\t\t\t\tconst currentPos = getCurrentPos(entry);\r\n\t\t\t\tconst difference = entry.boundingClientRect.width - entry.intersectionRect.width;\r\n\r\n\t\t\t\tentry.target.style.left = `${currentPos - difference - margin}px`;\r\n\t\t\t\tentry.target.style.setProperty(\"--tooltip-x-position\", `calc(60% + ${difference}px)`);\r\n\t\t\t}\r\n\r\n\t\t\t// Check aspect ratio to be sure the element is visible\r\n\t\t\t// const aspect = entry.intersectionRatio;\r\n\t\t\t// if (entry.isIntersecting) {\r\n\t\t\t// }\r\n\t\t});\r\n\t});\r\n\ttooltipWords.forEach((tooltipWord) => {\r\n\t\tconst tooltipPopup = tooltipWord.parentElement.querySelector(\".tooltip-popup\");\r\n\r\n\t\ttooltipsObserver.observe(tooltipPopup);\r\n\r\n\t\ttooltipWord.addEventListener(\"click\", (event) => {\r\n\t\t\ttoggleTooltip(tooltipWord);\r\n\t\t});\r\n\t\ttooltipWord.addEventListener(\"keydown\", (event) => {\r\n\t\t\tswitch (event.key) {\r\n\t\t\t\tcase \"Escape\":\r\n\t\t\t\t\thideTooltip(tooltipWord);\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t});\r\n\t\ttooltipWord.addEventListener(\"mouseover\", (event) => {\r\n\t\t\tshowTooltip(tooltipWord);\r\n\t\t});\r\n\t\ttooltipWord.addEventListener(\"focus\", (event) => {\r\n\t\t\tshowTooltip(tooltipWord);\r\n\t\t});\r\n\r\n\t\ttooltipWord.addEventListener(\"mouseout\", (event) => {\r\n\t\t\tvar isFocused = document.activeElement === tooltipWord;\r\n\t\t\tif (!isFocused) {\r\n\t\t\t\thideTooltip(tooltipWord);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\ttooltipWord.addEventListener(\"focusout\", (event) => {\r\n\t\t\thideTooltip(tooltipWord);\r\n\t\t});\r\n\t});\r\n}\r\nfunction showTooltip(tooltipWord) {\r\n\ttooltipWord.setAttribute(\"aria-expanded\", \"true\");\r\n\t// const tooltipPopup = tooltipWord.querySelector(\".tooltip-popup\");\r\n\tconst tooltipPopup = tooltipWord.parentElement.querySelector(\".tooltip-popup\");\r\n\tif (!tooltipPopup) return;\r\n\ttooltipPopup.setAttribute(\"aria-hidden\", \"false\");\r\n\t// positionTooltip(tooltipWord, tooltipPopup);\r\n}\r\nfunction hideTooltip(tooltipWord) {\r\n\ttooltipWord.setAttribute(\"aria-expanded\", \"false\");\r\n\t// const tooltipPopup = tooltipWord.querySelector(\".tooltip-popup\");\r\n\tconst tooltipPopup = tooltipWord.nextElementSibling;\r\n\tif (!tooltipPopup || !tooltipPopup.classList.contains(\"tooltip-popup\")) return;\r\n\ttooltipPopup.setAttribute(\"aria-hidden\", \"true\");\r\n}\r\nfunction toggleTooltip(tooltipWord) {\r\n\tconst isExpanded = tooltipWord.getAttribute(\"aria-expanded\") === \"true\";\r\n\tif (isExpanded) {\r\n\t\thideTooltip(tooltipWord);\r\n\t} else {\r\n\t\tshowTooltip(tooltipWord);\r\n\t}\r\n}\r\n\r\nfunction getCurrentPos(entry) {\r\n\treturn parseInt(getComputedStyle(entry.target, null).getPropertyValue(\"left\"));\r\n}\r\n\r\nwindow.addEventListener(\"DOMContentLoaded\", (event) => {\r\n\ttooltipsInit();\r\n});\r\n"],"names":["tooltipsInit","buildTooltips","observeTooltips","getTooltipsDatas","vocabulairesPostsIds","response","fetch","toString","ok","Error","status","data","json","err","createTooltip","tooltipWord","tooltipContainer","document","createElement","className","tooltipPopup","setAttribute","tooltipDefinition","textContent","getAttribute","tooltipTitle","appendChild","insertAdjacentElement","insertBefore","tooltipWords","querySelectorAll","Array","from","map","element","tooltipData","forEach","word","index","foundTooltipDatas","find","tooltip","id","parseInt","title","rendered","acf","definition","error","console","log","tooltipsObserver","IntersectionObserver","entries","entry","margin","boundingClientRect","x","currentPos","getCurrentPos","missingSpace","Math","abs","target","style","left","setProperty","width","window","innerWidth","difference","intersectionRect","parentElement","querySelector","observe","addEventListener","event","toggleTooltip","key","hideTooltip","showTooltip","isFocused","activeElement","nextElementSibling","classList","contains","isExpanded","getComputedStyle","getPropertyValue"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"tooltipFront.js","mappings":";;;;;AAAA,eAAeA,YAAYA,CAAA,EAAG;EAC7B,MAAMC,aAAa,CAAC,CAAC;EACrB,MAAMC,eAAe,CAAC,CAAC;EACvB;EACA;AACD;;AACA,eAAeC,gBAAgBA,CAACC,oBAAoB,EAAE;EACrD,IAAI;IACH,MAAMC,QAAQ,GAAG,MAAMC,KAAK,CAAE,sCAAqCF,oBAAoB,CAACG,QAAQ,CAAC,CAAE,EAAC,CAAC;IACrG,IAAI,CAACF,QAAQ,CAACG,EAAE,EAAE;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EAAE,MAAM,CAAC;AACjD;AACA,SAASwD,aAAaA,CAAC9D,WAAW,EAAE;EACnC,MAAMuE,UAAU,GAAGvE,WAAW,CAACS,YAAY,CAAC,eAAe,CAAC,KAAK,MAAM;EACvE,IAAI8D,UAAU,EAAE;IACfP,WAAW,CAAChE,WAAW,CAAC;EACzB,CAAC,MAAM;IACNiE,WAAW,CAACjE,WAAW,CAAC;EACzB;AACD;AAEA,SAAS4C,aAAaA,CAACL,KAAK,EAAE;EAC7B,OAAOX,QAAQ,CAAC4C,gBAAgB,CAACjC,KAAK,CAACS,MAAM,EAAE,IAAI,CAAC,CAACyB,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAC/E;AAEApB,MAAM,CAACO,gBAAgB,CAAC,kBAAkB,EAAGC,KAAK,IAAK;EACtD5E,YAAY,CAAC,CAAC;AACf,CAAC,CAAC,C","sources":["webpack://multi-blocks/./src/format-types/tooltip/tooltip-front.js"],"sourcesContent":["async function tooltipsInit() {\r\n\tawait buildTooltips();\r\n\tawait observeTooltips();\r\n\t// const tooltipWordsContainer = document.querySelectorAll(\".tooltip-container\");\r\n\t// await observeTooltip(tooltipWordsContainer);\r\n}\r\nasync function getTooltipsDatas(vocabulairesPostsIds) {\r\n\ttry {\r\n\t\tconst response = await fetch(`/wp-json/wp/v2/vocabulaire?include=${vocabulairesPostsIds.toString()}`);\r\n\t\tif (!response.ok) {\r\n\t\t\tthrow new Error(`Request failed with status: ${response.status}`);\r\n\t\t}\r\n\t\tconst data = await response.json();\r\n\t\treturn data;\r\n\t} catch (err) {\r\n\t\tthrow err;\r\n\t}\r\n}\r\nfunction createTooltip(tooltipWord) {\r\n\tconst tooltipContainer = document.createElement(\"div\");\r\n\ttooltipContainer.className = \"tooltip-container\";\r\n\r\n\tconst tooltipPopup = document.createElement(\"span\");\r\n\ttooltipPopup.className = \"tooltip-popup\";\r\n\ttooltipPopup.setAttribute(\"aria-hidden\", \"true\");\r\n\r\n\tconst tooltipDefinition = document.createElement(\"p\");\r\n\ttooltipDefinition.textContent = tooltipWord.getAttribute(\"data-tooltip-definition\");\r\n\ttooltipDefinition.className = \"tooltip-popup__definition\";\r\n\r\n\tconst tooltipTitle = document.createElement(\"h5\");\r\n\ttooltipTitle.textContent = tooltipWord.getAttribute(\"data-tooltip-word\");\r\n\ttooltipTitle.className = \"tooltip-popup__title\";\r\n\r\n\ttooltipPopup.appendChild(tooltipTitle);\r\n\ttooltipPopup.appendChild(tooltipDefinition);\r\n\r\n\ttooltipContainer.appendChild(tooltipPopup);\r\n\ttooltipWord.insertAdjacentElement(\"afterend\", tooltipContainer);\r\n\ttooltipContainer.insertBefore(tooltipWord, tooltipPopup);\r\n\t// tooltipContainer.appendChild(tooltipWord);\r\n\t// tooltipWord.appendChild(tooltipContainer);\r\n}\r\nasync function buildTooltips() {\r\n\tlet tooltipWords = document.querySelectorAll(\".tooltip-word\");\r\n\tconst vocabulairesPostsIds = Array.from(tooltipWords).map((element) =>\r\n\t\telement.getAttribute(\"data-definition-id\")\r\n\t);\r\n\r\n\ttry {\r\n\t\tconst tooltipData = await getTooltipsDatas(vocabulairesPostsIds);\r\n\r\n\t\ttooltipWords.forEach((word, index) => {\r\n\t\t\tconst foundTooltipDatas = tooltipData.find(\r\n\t\t\t\t(tooltip) => tooltip.id === parseInt(word.getAttribute(\"data-definition-id\"))\r\n\t\t\t);\r\n\r\n\t\t\tif (foundTooltipDatas) {\r\n\t\t\t\tword.setAttribute(\"data-tooltip-word\", foundTooltipDatas.title.rendered);\r\n\t\t\t\tword.setAttribute(\"data-tooltip-definition\", foundTooltipDatas.acf.definition);\r\n\t\t\t}\r\n\t\t\tword.setAttribute(\"aria-expanded\", \"false\");\r\n\r\n\t\t\tcreateTooltip(word, tooltipData[index]);\r\n\t\t});\r\n\t} catch (error) {\r\n\t\tconsole.log(\"Something went wrong!\", error);\r\n\t}\r\n}\r\n\r\nasync function observeTooltips() {\r\n\tlet tooltipWords = document.querySelectorAll(\".tooltip-word\");\r\n\t// CHAPTER IntersectionObserver\r\n\tconst tooltipsObserver = new IntersectionObserver((entries) => {\r\n\t\tentries.forEach((entry) => {\r\n\t\t\tconst margin = 10;\r\n\r\n\t\t\t// DEPASSE À GAUCHE\r\n\t\t\tif (entry.boundingClientRect.x < 0) {\r\n\t\t\t\tconst currentPos = getCurrentPos(entry);\r\n\t\t\t\tconst missingSpace = Math.abs(entry.boundingClientRect.x);\r\n\t\t\t\tentry.target.style.left = `${currentPos + missingSpace + margin}px`;\r\n\t\t\t\tentry.target.style.setProperty(\"--tooltip-x-position\", \"12%\");\r\n\t\t\t}\r\n\t\t\t// DEPASSE À DROITE\r\n\t\t\tif (entry.boundingClientRect.x + entry.boundingClientRect.width > window.innerWidth) {\r\n\t\t\t\tconst currentPos = getCurrentPos(entry);\r\n\t\t\t\tconst difference = entry.boundingClientRect.width - entry.intersectionRect.width;\r\n\r\n\t\t\t\tentry.target.style.left = `${currentPos - difference - margin}px`;\r\n\t\t\t\tentry.target.style.setProperty(\"--tooltip-x-position\", `calc(60% + ${difference}px)`);\r\n\t\t\t}\r\n\r\n\t\t\t// Check aspect ratio to be sure the element is visible\r\n\t\t\t// const aspect = entry.intersectionRatio;\r\n\t\t\t// if (entry.isIntersecting) {\r\n\t\t\t// }\r\n\t\t});\r\n\t});\r\n\ttooltipWords.forEach((tooltipWord) => {\r\n\t\tconst tooltipPopup = tooltipWord.parentElement.querySelector(\".tooltip-popup\");\r\n\r\n\t\ttooltipsObserver.observe(tooltipPopup);\r\n\r\n\t\ttooltipWord.addEventListener(\"click\", (event) => {\r\n\t\t\ttoggleTooltip(tooltipWord);\r\n\t\t});\r\n\t\ttooltipWord.addEventListener(\"keydown\", (event) => {\r\n\t\t\tswitch (event.key) {\r\n\t\t\t\tcase \"Escape\":\r\n\t\t\t\t\thideTooltip(tooltipWord);\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t});\r\n\t\ttooltipWord.addEventListener(\"mouseover\", (event) => {\r\n\t\t\tshowTooltip(tooltipWord);\r\n\t\t});\r\n\t\ttooltipWord.addEventListener(\"focus\", (event) => {\r\n\t\t\tshowTooltip(tooltipWord);\r\n\t\t});\r\n\r\n\t\ttooltipWord.addEventListener(\"mouseout\", (event) => {\r\n\t\t\tvar isFocused = document.activeElement === tooltipWord;\r\n\t\t\tif (!isFocused) {\r\n\t\t\t\thideTooltip(tooltipWord);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\ttooltipWord.addEventListener(\"focusout\", (event) => {\r\n\t\t\thideTooltip(tooltipWord);\r\n\t\t});\r\n\t});\r\n}\r\nfunction showTooltip(tooltipWord) {\r\n\ttooltipWord.setAttribute(\"aria-expanded\", \"true\");\r\n\t// const tooltipPopup = tooltipWord.querySelector(\".tooltip-popup\");\r\n\tconst tooltipPopup = tooltipWord.parentElement.querySelector(\".tooltip-popup\");\r\n\tif (!tooltipPopup) return;\r\n\ttooltipPopup.setAttribute(\"aria-hidden\", \"false\");\r\n\t// positionTooltip(tooltipWord, tooltipPopup);\r\n}\r\nfunction hideTooltip(tooltipWord) {\r\n\ttooltipWord.setAttribute(\"aria-expanded\", \"false\");\r\n\t// const tooltipPopup = tooltipWord.querySelector(\".tooltip-popup\");\r\n\tconst tooltipPopup = tooltipWord.nextElementSibling;\r\n\tif (!tooltipPopup || !tooltipPopup.classList.contains(\"tooltip-popup\")) return;\r\n\ttooltipPopup.setAttribute(\"aria-hidden\", \"true\");\r\n}\r\nfunction toggleTooltip(tooltipWord) {\r\n\tconst isExpanded = tooltipWord.getAttribute(\"aria-expanded\") === \"true\";\r\n\tif (isExpanded) {\r\n\t\thideTooltip(tooltipWord);\r\n\t} else {\r\n\t\tshowTooltip(tooltipWord);\r\n\t}\r\n}\r\n\r\nfunction getCurrentPos(entry) {\r\n\treturn parseInt(getComputedStyle(entry.target, null).getPropertyValue(\"left\"));\r\n}\r\n\r\nwindow.addEventListener(\"DOMContentLoaded\", (event) => {\r\n\ttooltipsInit();\r\n});\r\n"],"names":["tooltipsInit","buildTooltips","observeTooltips","getTooltipsDatas","vocabulairesPostsIds","response","fetch","toString","ok","Error","status","data","json","err","createTooltip","tooltipWord","tooltipContainer","document","createElement","className","tooltipPopup","setAttribute","tooltipDefinition","textContent","getAttribute","tooltipTitle","appendChild","insertAdjacentElement","insertBefore","tooltipWords","querySelectorAll","Array","from","map","element","tooltipData","forEach","word","index","foundTooltipDatas","find","tooltip","id","parseInt","title","rendered","acf","definition","error","console","log","tooltipsObserver","IntersectionObserver","entries","entry","margin","boundingClientRect","x","currentPos","getCurrentPos","missingSpace","Math","abs","target","style","left","setProperty","width","window","innerWidth","difference","intersectionRect","parentElement","querySelector","observe","addEventListener","event","toggleTooltip","key","hideTooltip","showTooltip","isFocused","activeElement","nextElementSibling","classList","contains","isExpanded","getComputedStyle","getPropertyValue"],"sourceRoot":""} \ No newline at end of file