{"version":3,"file":"js/decidim_budgets.js","mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAOA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;ACnGA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;;;;;;;;;;ACtBA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;AClCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;ACtBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;ACvBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;ACPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;ACPA;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;ACNA;;;;;;;;;;;;;;;;;;ACAA;AACA;AACA;;AAEA;AACA","sources":["webpack://code/./vendor/decidim-gems/decidim-budgets/app/packs/src/decidim/budgets/exit_handler.js","webpack://code/./vendor/decidim-gems/decidim-budgets/app/packs/src/decidim/budgets/progressFixed.js","webpack://code/./vendor/decidim-gems/decidim-budgets/app/packs/src/decidim/budgets/projects.js","webpack://code/./vendor/decidim-gems/decidim-budgets/app/packs/images/ sync ^\\.\\/.*$","webpack://code/webpack/bootstrap","webpack://code/webpack/runtime/compat get default export","webpack://code/webpack/runtime/define property getters","webpack://code/webpack/runtime/hasOwnProperty shorthand","webpack://code/webpack/runtime/make namespace object","webpack://code/webpack/runtime/publicPath","webpack://code/./vendor/decidim-gems/decidim-budgets/app/packs/entrypoints/decidim_budgets.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 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) {\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","$(() => {\n const $projects = $(\"#projects, #project\");\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\", \".budget-list__action\", (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 if (!$currentTarget.attr(\"data-open\")) {\n $currentTarget.addClass(\"loading-spinner\");\n }\n\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","var map = {\n\t\"./decidim/budgets/decidim_budgets.svg\": \"./vendor/decidim-gems/decidim-budgets/app/packs/images/decidim/budgets/decidim_budgets.svg\"\n};\n\n\nfunction webpackContext(req) {\n\tvar id = webpackContextResolve(req);\n\treturn __webpack_require__(id);\n}\nfunction webpackContextResolve(req) {\n\tif(!__webpack_require__.o(map, req)) {\n\t\tvar e = new Error(\"Cannot find module '\" + req + \"'\");\n\t\te.code = 'MODULE_NOT_FOUND';\n\t\tthrow e;\n\t}\n\treturn map[req];\n}\nwebpackContext.keys = function webpackContextKeys() {\n\treturn Object.keys(map);\n};\nwebpackContext.resolve = webpackContextResolve;\nmodule.exports = webpackContext;\nwebpackContext.id = \"./vendor/decidim-gems/decidim-budgets/app/packs/images sync recursive ^\\\\.\\\\/.*$\";","// 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 = function(module) {\n\tvar getter = module && module.__esModule ?\n\t\tfunction() { return module['default']; } :\n\t\tfunction() { return module; };\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = function(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 = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }","// define __esModule on exports\n__webpack_require__.r = function(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};","__webpack_require__.p = \"/decidim-packs/\";","import \"src/decidim/budgets/projects\"\nimport \"src/decidim/budgets/progressFixed\"\nimport \"src/decidim/budgets/exit_handler\"\n\n// Images\nrequire.context(\"../images\", true)\n"],"names":[],"sourceRoot":""}