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EAAE,gCACnBmE,EAAcnE,EAAE,uBAChBoE,EAAkBnE,SAASgE,EAAoB/D,KAAK,yBAA0B,IAE9EmE,EAAc,SAACrC,GACnBhC,EAAEgC,EAAME,eAAeoC,YAAY,mBACnCtC,EAAMK,kBACNL,EAAMG,gBACR,EAEAgC,EAAYpC,GAAG,QAAS,QAAQ,WAC9B/B,EAAE,wBAAwBuE,OAC5B,IAEAP,EAAUjC,GAAG,QAAS,sBAAsB,SAACC,GAC3C,IAAMwC,EAAoBvE,SAASF,EAAeG,KAAK,2BAA4B,IAC7EuE,EAAiBzE,EAAEgC,EAAME,eACzBwC,EAAoBzE,SAASwE,EAAevE,KAAK,mBAAoB,IAGvEyE,EAAkB,KAChBC,EAAoBH,EAAetE,QAAQ,sBAAsB0E,QAAQzC,KAAK,mBAC1DV,IAAtBkD,IACAD,EAAkB3E,EAAE,sCAADQ,OAAuCoE,EAAiB,MAAKC,SAGpF,IAAIC,EAAkBN,EAAoBE,EAAqBN,EAC3DW,GAAwB,EAExBJ,GAAmBA,EAAgBvE,OAAS,IAG5C2E,EAFkC9E,SAAS0E,EAAgBzE,KAAK,2BAA4B,IAEtCwE,EADtBzE,SAAS0E,EAAgBzE,KAAK,mBAAoB,KACoB4E,GAGtGL,EAAevE,KAAK,YACtBmE,EAAYrC,GACkC,SAApCyC,EAAevE,KAAK,cAAqD,IAA1B6E,GACzD/E,EAAE,kBAADQ,OAAmBoE,IAAqB/C,WAAW,UACpDwC,EAAYrC,IACkC,SAApCyC,EAAevE,KAAK,cAA6C,IAAlB4E,IACvDZ,EAAmBrC,WAAW,UAC9BwC,EAAYrC,GAElB,GACF,E,2BC5CAhC,GAAE,WACAgF,GACF,G","sources":["webpack://app/../usr/local/bundle/bundler/gems/decidim-module-ptp-46bb834a68d5/decidim-budgets_booth/app/packs/src/decidim/budgets_booth/exit_handler.js","webpack://app/../usr/local/bundle/bundler/gems/decidim-module-ptp-46bb834a68d5/decidim-budgets_booth/app/packs/src/decidim/budgets_booth/popup_selected_project.js","webpack://app/../usr/local/bundle/bundler/gems/decidim-module-ptp-46bb834a68d5/decidim-budgets_booth/app/packs/src/decidim/budgets_booth/progressFixed.js","webpack://app/webpack/bootstrap","webpack://app/../usr/local/bundle/bundler/gems/decidim-module-ptp-46bb834a68d5/decidim-budgets_booth/app/packs/src/decidim/budgets_booth/projects.js","webpack://app/../usr/local/bundle/bundler/gems/decidim-module-ptp-46bb834a68d5/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 $voteButton = $(\".budget-vote-button\");\n const totalAllocation = parseInt($budgetSummaryTotal.attr(\"data-total-allocation\"), 10);\n\n const cancelEvent = (event) => {\n $(event.currentTarget).removeClass(\"loading-spinner\");\n event.stopPropagation();\n event.preventDefault();\n };\n\n $voteButton.on(\"click\", \"span\", () => {\n $(\".budget-list__action\").click();\n });\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\n\n let $targetCategory = null;\n const $targetCategoryId = $currentTarget.parents(\".budget-list__data\").first().data(\"categoryId\");\n if ($targetCategoryId !== undefined) {\n $targetCategory = $(`.vote_by_category[data-category-id=${$targetCategoryId}]`).first();\n }\n\n let quotaExceeded = ((currentAllocation + projectAllocation) > totalAllocation);\n let categoryQuotaExceeded = false;\n\n if ($targetCategory && $targetCategory.length > 0) {\n const currentCategoryAllocation = parseInt($targetCategory.attr(\"data-current-allocation\"), 10);\n const totalCategoryAllocation = parseInt($targetCategory.attr(\"data-allocation\"), 10);\n categoryQuotaExceeded = ((currentCategoryAllocation + projectAllocation) > totalCategoryAllocation || quotaExceeded);\n }\n \n if ($currentTarget.attr(\"disabled\")) {\n cancelEvent(event);\n } else if (($currentTarget.attr(\"data-add\") === \"true\") && categoryQuotaExceeded === true) {\n $(`#budget-excess-${$targetCategoryId}`).foundation(\"toggle\");\n cancelEvent(event);\n } else if (($currentTarget.attr(\"data-add\") === \"true\") && quotaExceeded === true) {\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","concat","location","pathname","href","safe","forEach","url","startsWith","isSafeUrl","$exitNotification","$exitLink","defaultExitUrl","defaultExitLinkText","text","exitLinkText","openExitNotification","method","arguments","undefined","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","exports","module","__webpack_modules__","$projects","$budgetSummaryTotal","$budgetExceedModal","$voteButton","totalAllocation","cancelEvent","removeClass","click","currentAllocation","$currentTarget","projectAllocation","$targetCategory","$targetCategoryId","first","quotaExceeded","categoryQuotaExceeded","initializeProjects"],"sourceRoot":""}