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K,MAAM;UAC9C;QACJ;MACJ,CAAC,CAAC;IACN;EAAC;AAAA","sources":["webpack://erfgoedhuis-zuid-holland-frontend/./scripts/controllers/readMore/controller.js","webpack://erfgoedhuis-zuid-holland-frontend/./scripts/controllers/readMore/readMore.js","webpack://erfgoedhuis-zuid-holland-frontend/./scripts/libraries/settings.js"],"sourcesContent":["import ReadMore from './readMore';\n\nexport default class ReadMoreController {\n constructor() {\n this.selector = '.readMoreContainer';\n this.instances = [];\n\n this.init();\n console.log('ReadMore loaded');\n }\n\n init() {\n if (document.querySelectorAll(this.selector).length) {\n document.querySelectorAll(this.selector).forEach(container => {\n const readMore = new ReadMore(container);\n this.instances.push(readMore);\n\n readMore.init();\n })\n }\n }\n}","import Settings from '../../libraries/settings';\n\nexport default class ReadMore {\n constructor(element) {\n this.element = element;\n\n this.settings = new Settings({\n maxHeight: 300,\n buttonText: 'Lees meer',\n }, {\n element: this.element,\n prefix: 'readMore',\n });\n }\n\n init() {\n if (this.element.clientHeight > this.settings.maxHeight) {\n const buttonContainer = document.createElement('div');\n buttonContainer.classList.add('buttonContainer');\n const showAllButton = document.createElement('button');\n showAllButton.classList.add('button');\n showAllButton.innerText = this.settings.buttonText;\n showAllButton.addEventListener('click', e => {\n showAllButton.remove();\n buttonContainer.remove();\n this.element.removeAttribute(\"style\");\n this.element.classList.remove('readMoreActive');\n });\n buttonContainer.appendChild(showAllButton);\n\n this.element.parentNode.insertBefore(buttonContainer, this.element.nextSibling);\n this.element.style.maxHeight = `${this.settings.maxHeight}px`;\n this.element.classList.add('readMoreActive');\n }\n }\n}","export default class Settings {\n /**\n * @param {Object} properties Flat object with properties containing settings\n * @param {Object} options Options for the Settings object \n * @param {Element} options.element Element to read data attributes from \n * @param {String} options.prefix Prefix for data attributes \n * @param {Boolean} options.errorOnNotFound Wether to throw an error or not if an unrecognized setting is accessed \n */\n constructor(properties = {}, options = {}) {\n this.options = {\n element: null,\n prefix: '',\n errorOnNotFound: false,\n };\n this.properties = properties; // The actual settings to get/set/return\n \n // Merge supplied options into default options\n Object.assign(this.options, options);\n\n if (this.options.element) {\n this.getSettingsFromElement();\n }\n\n return new Proxy(this, {\n get: (settings, prop) => {\n if (settings.properties.hasOwnProperty(prop)) {\n return settings.properties[prop];\n } else if (settings.options.errorOnNotFound) {\n throw new Error(`Setting \"${prop}\" not found`);\n } else {\n return undefined;\n }\n },\n\n set: (settings, prop, val) => {\n if (!settings.properties.hasOwnProperty(prop) && settings.options.errorOnNotFound) {\n throw new Error(`Setting \"${prop}\" not found`);\n } else if (settings.options.errorOnNotFound) {\n settings.properties[prop] = val;\n }\n },\n });\n }\n\n getSettingsFromElement() {\n const element = this.options.element;\n\n // Loop through all settings, see if there's a matching data-attribute\n Object.keys(this.properties).forEach(property => {\n let originalProperty = property;\n if (this.options.prefix) {\n property = `${this.options.prefix}${property.charAt(0).toUpperCase() + property.slice(1)}`;\n }\n if (property in element.dataset) {\n let elProp = element.dataset[property];\n\n if (Number.isInteger(parseInt(elProp))) {\n this.properties[originalProperty] = parseInt(elProp);\n } else if (['true', 'false'].includes(elProp)) {\n this.properties[originalProperty] = (elProp == true);\n } else {\n this.properties[originalProperty] = elProp;\n }\n }\n });\n }\n}"],"names":["ReadMore","ReadMoreController","_classCallCheck","selector","instances","init","console","log","_createClass","key","value","_this","document","querySelectorAll","length","forEach","container","readMore","push","default","Settings","element","settings","maxHeight","buttonText","prefix","clientHeight","buttonContainer","createElement","classList","add","showAllButton","innerText","addEventListener","e","remove","removeAttribute","appendChild","parentNode","insertBefore","nextSibling","style","concat","properties","arguments","undefined","options","errorOnNotFound","Object","assign","getSettingsFromElement","Proxy","get","prop","hasOwnProperty","Error","set","val","keys","property","originalProperty","charAt","toUpperCase","slice","dataset","elProp","Number","isInteger","parseInt","includes"],"sourceRoot":""}