moodle_local_treestudyplan/amd/build/util/psidebar-vue.min.js.map

1 line
8.9 KiB
Plaintext
Raw Permalink Normal View History

{"version":3,"file":"psidebar-vue.min.js","sources":["../../src/util/psidebar-vue.js"],"sourcesContent":["/* eslint no-unused-vars: warn */\n/* eslint max-len: [\"error\", { \"code\": 160 }] */\n/* eslint-disable no-trailing-spaces */\n/* eslint-disable no-console */\n/* eslint-env es6*/\nimport PortalVue from '../portal-vue/portal-vue.esm';\nimport Debugger from './debugger';\nlet debug = new Debugger(\"p-sidebar\");\n\n\nlet wrapper;\nlet contentwrapper;\nlet resizeObserver;\n/**\n * Create a new wrapper Around the \n * @param {String} target Query string to select root element next to which the sidebar will be placed. \n * Defaults to body\n * @param {String} offsetref Query string to select element that should appear above the sidebar. \n * Defaults to none\n */\nfunction createPortalTarget(target, offsetref) {\n let initializeWrapperContent = false;\n debug.info(\"Creating portal target\");\n // First check if the sidebar wrapper already exists. \n // Creating the wrappers over and over again is a recipe for disaster.\n wrapper = document.querySelector(\"#p-sidebar-wrapper\");\n if (!wrapper) {\n initializeWrapperContent = true;\n // Otherwise, create it.\n wrapper = document.createElement(\"div\");\n wrapper.setAttribute(\"id\", \"p-sidebar-wrapper\");\n }\n // First check if the contentwrapper already exists\n contentwrapper = document.querySelector(\"#p-sidebar-contentwrapper\");\n if (!contentwrapper) {\n initializeWrapperContent = true;\n // Otherwise, create it.\n contentwrapper = document.createElement(\"div\");\n contentwrapper.setAttribute(\"id\", \"p-sidebar-contentwrapper\");\n wrapper.appendChild(contentwrapper);\n }\n\n if (initializeWrapperContent) {\n // Find containing target (otherwise use body)\n let targetEl = document.querySelector(target);\n if (!targetEl || targetEl.nodeType == \"HTML\") {\n targetEl = document.querySelector(\"body\");\n }\n console.info(`Targeting '${target}' to `, targetEl);\n \n // Move all target content parts to content wrapper....\n while (targetEl.childNodes.length > 0) {\n contentwrapper.appendChild(targetEl.childNodes[0]);\n }\n // Add sidebar wrapper to target Element\n targetEl.appendChild(wrapper);\n }\n // The actual target is created in a reposition call\n rePosition(false);\n // The \n setOffset(offsetref);\n}\n\n/**\n * Position a (new) sidebar element on the left or right \n * @param {Boolean} right Set to true to put the sidebar on the right\n */\nfunction rePosition(right) {\n // Place the portal target on the right place in the DOM.\n // Find or create the portal target.\n let el = document.querySelector(`#p-sidebar-mount`);\n if (!el) {\n el = document.createElement(\"div\");\n el.setAttribute(\"id\", `p-sidebar-mount`);\n\n // Initialize a resizeObser\n resizeObserver = new ResizeObserver(() => {\n let wx = 0 - el.getBoundingClientRect().width;\n wx += (wx != 0) ? \"px\" : \"\";\n el.style.setProperty(\"--p-sidebar-hideoffset\", wx);\n });\n resizeObserver.observe(el);\n\n }\n if (right) {\n wrapper.insertBefore(el, contentwrapper.nextSibling);\n } else {\n wrapper.insertBefore(el, contentwrapper);\n }\n}\n\n/**\n * Set the proper offset from the top on the sidebar related to the reference element \n * @param {String} reference Reference target for setting view height\n */\nfunction setOffset(reference) {\n const ref = reference ? document.querySelector(reference) : null;\n if (ref) {\n let offsetTop = (ref ? ref.offsetTop : 0);\n offsetTop += (offsetTop != 0) ? \"px\" : \"\";\n const el = document.querySelector(`#p-sidebar-mount`);\n if (el) {\n el.style.height = `calc( 100vh - ${offsetTop})`;\n el.style.marginTop = offsetTop;\n }\n }\n}\n\nexport default {\n instal