{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./app/javascript/packs/document_templates.js","webpack:///./app/javascript/src/document_templates.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","timeOut","cbox","document","querySelectorAll","allBox","querySelector","docRoute","addCategory","filterParams","urlSearchParams","URLSearchParams","window","location","search","getAll","length","checked","urlCheckbox","initQuery","showOverlay","style","display","filterQuery","parameters","filter","v","a","indexOf","push","encodeURI","setTimeout","url","origin","href","join","removeFromFilter","item","addEventListener","clearTimeout","this","getAttribute","input","sortDropdowns","sortForm","innerHTML","switchSortingTitle","forEach","link","event","preventDefault","hiddenField","createElement","type","appendChild","submit","categories","counter","checkCatHeight","category","offsetHeight","pills","remove","counterPill","cloneNode","classList","add","second","additional","initPills","toggleButton","getElementById","contains"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QAKfF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,qBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,K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n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/packs/\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 196);\n","import \"../src/document_templates\";\n","(function () {\n // Filtering\n const cbox = document.querySelectorAll(\".filterable > input[type=checkbox]\");\n const allBox = document.querySelector(\".document-all-contracts\");\n const docRoute = \"/legal-and-business-documents\";\n const addCategory = document.querySelector(\"input[name=document_additional_category]\");\n let filterParams = [];\n let timeOut;\n\n const initQuery = () => {\n const urlSearchParams = new URLSearchParams(window.location.search);\n filterParams = urlSearchParams.getAll('category_name[]');\n\n if (filterParams.length > 0) {\n for (let i in filterParams) {\n document.querySelector(\"[data-url='\" + filterParams[i] + \"']\").checked = true;\n };\n\n allBox.checked = false;\n };\n\n if (addCategory.value) {\n const urlCheckbox = document.querySelector(\"[data-url='\" + addCategory.value + \"']\");\n if (urlCheckbox) {\n urlCheckbox.checked = true;\n allBox.checked = false;\n };\n };\n }\n initQuery();\n\n const showOverlay = () => {\n document.querySelector(\".filter-overlay-body\").style.display = 'block';\n document.querySelector(\".filter-overlay-text\").style.display = 'block';\n };\n\n const filterQuery = () => {\n let parameters = [];\n filterParams = filterParams.filter((v, i, a) => a.indexOf(v) == i);\n for (let property in filterParams) {\n parameters.push(encodeURI('category_name[]=' + filterParams[property]));\n };\n allBox.checked = false;\n\n if (parameters.length >= 0) {\n showOverlay();\n timeOut = setTimeout(function () {\n if (parameters.length == 1) {\n const url = window.location.origin + docRoute + '/' + filterParams[0];\n\n window.location.href = url + \"?\" + parameters.join('&');\n } else {\n window.location.href = window.location.origin + docRoute + \"?\" + parameters.join('&');\n }\n }, 1000);\n }\n };\n\n const addToFilter = (value) => {\n filterParams.push(value);\n }\n\n const removeFromFilter = (value) => {\n filterParams = filterParams.filter(item => item !== value)\n }\n\n for (let i = 0; i < cbox.length; i++) {\n cbox[i].addEventListener(\"click\", function () {\n clearTimeout(timeOut);\n if (this.checked) {\n addToFilter(this.getAttribute('data-url'));\n } else {\n removeFromFilter(this.getAttribute('data-url'));\n }\n filterQuery();\n });\n };\n\n allBox.addEventListener(\"click\", function () {\n showOverlay();\n window.location.href = \"/legal-and-business-documents\";\n });\n\n// Sorting\n const sortDropdowns = document.querySelectorAll(\".documents-sorting .dropdown-item\");\n const sortForm = document.querySelector(\".document-sorting-form\");\n\n const switchSortingTitle = (value) => {\n switch (value) {\n case 'title':\n return 'Document Name';\n case 'position':\n return 'Most downloaded';\n default:\n return 'Most downloaded';\n };\n };\n\n const initSorting = () => {\n const input = document.querySelector(\".document-sorting-form .dropdown-toggle input\");\n const span = document.querySelector(\".document-sorting-form .dropdown-toggle span\");\n span.innerHTML = switchSortingTitle(input.value);\n };\n initSorting();\n\n if (sortDropdowns) {\n sortDropdowns.forEach(link => {\n link.addEventListener(\"click\", function (event) {\n event.preventDefault();\n\n const hiddenField = document.createElement('input');\n hiddenField.type = 'hidden';\n hiddenField.name = 'sort';\n hiddenField.value = this.getAttribute('data-href');\n\n showOverlay();\n sortForm.appendChild(hiddenField);\n sortForm.submit();\n });\n });\n }\n\n const MAX_HEIGHT = 30;\n // init pills by size\n const initPills = () => {\n const categories = document.querySelectorAll(\".categories\");\n let counter = 0;\n\n const checkCatHeight = (category) => {\n if (category.offsetHeight > MAX_HEIGHT) {\n const pills = category.querySelectorAll(\".document-category\");\n const pillCount = pills.length;\n\n pills[pillCount-1].remove();\n counter++;\n }\n };\n\n for (let i = 0; i < categories.length; i++) {\n while (categories[i].offsetHeight > MAX_HEIGHT) {\n checkCatHeight(categories[i]);\n };\n if (counter > 0) {\n const pill = categories[i].querySelector(\".document-category\");\n const counterPill = pill.cloneNode(true);\n counterPill.classList.add('additional');\n counterPill.querySelector('span').innerHTML = '+' + counter;\n categories[i].appendChild(counterPill);\n if (categories[i].offsetHeight > MAX_HEIGHT) {\n counter++;\n const second = categories[i].querySelector(\".object-1\");\n const additional = categories[i].querySelector(\".additional\");\n if (second) {\n second.remove();\n if (additional) {\n additional.querySelector('span').innerHTML = '+' + counter;\n }\n };\n }\n counter = 0;\n }\n };\n };\n initPills();\n\n const toggleFilters = () => {\n const toggleButton = document.getElementById(\"filter-toggle\");\n\n toggleButton.addEventListener('click', function () {\n if (toggleButton.classList.contains('collapsed')) {\n toggleButton.innerHTML = 'Hide document filters';\n } else {\n toggleButton.innerHTML = 'Show document filters';\n }\n });\n };\n toggleFilters();\n})();\n"],"sourceRoot":""}