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IAE9EgE,EAAc,SAACrC,GACnBA,EAAMK,kBACNL,EAAMG,gBACR,EACA8B,EAAUlC,GAAG,QAAS,sBAAsB,SAACC,GAC3C,IAAMsC,EAAoBlE,SAASF,EAAeG,KAAK,2BAA4B,IAC7EkE,EAAiBpE,EAAE6B,EAAME,eACzBsC,EAAoBpE,SAASmE,EAAelE,KAAK,mBAAoB,IACvEkE,EAAelE,KAAK,YACtBgE,EAAYrC,GACkC,SAApCuC,EAAelE,KAAK,aAA6BiE,EAAoBE,EAAqBJ,IACpGD,EAAmBtC,WAAW,UAC9BwC,EAAYrC,GAEhB,GACF,E,0BCjBA7B,GAAE,WACAsE,GACF,G","sources":["webpack://decidim-development-app/../usr/local/bundle/bundler/gems/decidim-module-ptp-18c7422633b7/decidim-budgets_booth/app/packs/src/decidim/budgets_booth/exit_handler.js","webpack://decidim-development-app/../usr/local/bundle/bundler/gems/decidim-module-ptp-18c7422633b7/decidim-budgets_booth/app/packs/src/decidim/budgets_booth/popup_selected_project.js","webpack://decidim-development-app/../usr/local/bundle/bundler/gems/decidim-module-ptp-18c7422633b7/decidim-budgets_booth/app/packs/src/decidim/budgets_booth/progressFixed.js","webpack://decidim-development-app/webpack/bootstrap","webpack://decidim-development-app/../usr/local/bundle/bundler/gems/decidim-module-ptp-18c7422633b7/decidim-budgets_booth/app/packs/src/decidim/budgets_booth/projects.js","webpack://decidim-development-app/../usr/local/bundle/bundler/gems/decidim-module-ptp-18c7422633b7/decidim-budgets_booth/app/packs/entrypoints/decidim_budgets_booth_voting.js"],"sourcesContent":["const currentAllocationZero = () => {\n const $budgetSummary = $(\".budget-summary__progressbox\");\n return parseInt($budgetSummary.attr(\"data-current-allocation\"), 10) === 0;\n}\n\nconst isSafeUrl = (exitUrl) => {\n if (!exitUrl) {\n return false\n }\n\n const safeUrls = [\n $(\".budget-summary\").attr(\"data-safe-url\").split(\"?\")[0],\n `${location.pathname}#`,\n `${location.href}#`,\n \"#\"\n ];\n\n let safe = false;\n safeUrls.forEach((url) => {\n if (exitUrl.startsWith(url)) {\n safe = true\n }\n });\n\n return safe;\n}\n\nconst allowExitFrom = ($el) => {\n if (currentAllocationZero()) {\n return true\n } else if ($el.attr(\"target\") === \"_blank\") {\n return true;\n } else if ($el.parents(\"#loginModal\").length > 0) {\n return true;\n } else if ($el.parents(\"#authorizationModal\").length > 0) {\n return true;\n } else if ($el.attr(\"id\") === \"exit-notification-link\") {\n return true;\n } else if ($el.parents(\".voting-wrapper\").length > 0) {\n return true;\n } else if (isSafeUrl($el.attr(\"href\"))) {\n return true\n }\n\n return false;\n}\n\n$(() => {\n const $exitNotification = $(\"#exit-notification\");\n const $exitLink = $(\"#exit-notification-link\");\n const defaultExitUrl = $exitLink.attr(\"href\");\n const defaultExitLinkText = $exitLink.text();\n let exitLinkText = defaultExitLinkText;\n\n if ($exitNotification.length < 1) {\n // Do not apply when not inside the voting pipeline\n return;\n }\n\n const openExitNotification = (url, method = null) => {\n if (method && method !== \"get\") {\n $exitLink.attr(\"data-method\", method);\n } else {\n $exitLink.removeAttr(\"data-method\");\n }\n\n $exitLink.attr(\"href\", url);\n $exitLink.html(exitLinkText);\n $exitNotification.foundation(\"open\");\n };\n\n $(document).on(\"click\", \"a\", (event) => {\n exitLinkText = defaultExitLinkText;\n\n const $link = $(event.currentTarget);\n if (!allowExitFrom($link)) {\n event.preventDefault();\n openExitNotification($link.attr(\"href\"), $link.data(\"method\"));\n }\n });\n // Custom handling for the header sign out so that it won't trigger the\n // logout form submit and so that it changes the exit link text. This does\n // not trigger the document link click listener because it has the\n // data-method attribute to trigger a form submit event.\n $(\".header a.sign-out-link\").on(\"click\", (event) => {\n event.preventDefault();\n event.stopPropagation();\n\n const $link = $(event.currentTarget);\n exitLinkText = $link.text();\n openExitNotification($link.attr(\"href\"), $link.data(\"method\"));\n });\n // Custom handling for the exit link which needs to change the exit link\n // text to the default text as this is not handled by the document click\n // listener.\n $(\"a[data-open='exit-notification']\").on(\"click\", () => {\n exitLinkText = defaultExitLinkText;\n openExitNotification(defaultExitUrl);\n });\n});\n","$(() => {\n const queryString = window.location.search;\n const urlParams = new URLSearchParams(queryString);\n const selectedProject = $(`#project-modal-${urlParams.get(\"select_project\")}`);\n if (selectedProject.length === 1) {\n selectedProject.foundation(\"open\");\n }\n});\n","$(() => {\n const checkProgressPosition = () => {\n let progressFix = document.querySelector(\"[data-progressbox-fixed]\"),\n progressRef = document.querySelector(\"[data-progress-reference]\"),\n progressVisibleClass = \"is-progressbox-visible\";\n\n if (!progressRef || !progressFix) {\n return;\n }\n\n let progressPosition = progressRef.getBoundingClientRect().bottom;\n if (progressPosition > 0) {\n progressFix.classList.remove(progressVisibleClass);\n } else {\n progressFix.classList.add(progressVisibleClass);\n }\n }\n\n window.addEventListener(\"scroll\", checkProgressPosition);\n\n window.DecidimBudgets = window.DecidimBudgets || {};\n window.DecidimBudgets.checkProgressPosition = checkProgressPosition;\n});\n","// 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","const initializeProjects = () => {\n const $projects = $(\"#projects, #project, .reveal.large\");\n const $budgetSummaryTotal = $(\".budget-summary__total\");\n const $budgetExceedModal = $(\"#budget-excess\");\n const $budgetSummary = $(\".budget-summary__progressbox\");\n const totalAllocation = parseInt($budgetSummaryTotal.attr(\"data-total-allocation\"), 10);\n\n const cancelEvent = (event) => {\n event.stopPropagation();\n event.preventDefault();\n };\n $projects.on(\"click\", \".customized-budget\", (event) => {\n const currentAllocation = parseInt($budgetSummary.attr(\"data-current-allocation\"), 10);\n const $currentTarget = $(event.currentTarget);\n const projectAllocation = parseInt($currentTarget.attr(\"data-allocation\"), 10);\n if ($currentTarget.attr(\"disabled\")) {\n cancelEvent(event);\n } else if (($currentTarget.attr(\"data-add\") === \"true\") && ((currentAllocation + projectAllocation) > totalAllocation)) {\n $budgetExceedModal.foundation(\"toggle\");\n cancelEvent(event);\n }\n });\n};\n\n\nexport default initializeProjects;\n","import initializeProjects from \"src/decidim/budgets_booth/projects\"\nimport \"src/decidim/budgets_booth/progressFixed\"\nimport \"src/decidim/budgets_booth/exit_handler\"\nimport \"src/decidim/budgets_booth/popup_selected_project\"\n\n$(() => {\n initializeProjects();\n});\n"],"names":["allowExitFrom","$el","$budgetSummary","$","parseInt","attr","parents","length","exitUrl","safeUrls","split","location","pathname","href","safe","forEach","url","startsWith","isSafeUrl","$exitNotification","$exitLink","defaultExitUrl","defaultExitLinkText","text","exitLinkText","openExitNotification","method","removeAttr","html","foundation","document","on","event","$link","currentTarget","preventDefault","data","stopPropagation","queryString","window","search","urlParams","URLSearchParams","selectedProject","get","checkProgressPosition","progressFix","querySelector","progressRef","progressVisibleClass","getBoundingClientRect","bottom","classList","remove","add","addEventListener","DecidimBudgets","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","exports","module","__webpack_modules__","$projects","$budgetSummaryTotal","$budgetExceedModal","totalAllocation","cancelEvent","currentAllocation","$currentTarget","projectAllocation","initializeProjects"],"sourceRoot":""}