1 line
7.5 KiB
Plaintext
1 line
7.5 KiB
Plaintext
{"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*/\n\nimport Debugger from './debugger';\nlet debug = new Debugger(\"p-sidebar\");\n\nexport default {\n install(Vue /* ,options */) {\n Vue.component('p-sidebar', {\n props: {\n value: {\n type: Boolean,\n 'default': true,\n },\n right: {\n type: Boolean,\n 'default': false,\n },\n shadow: {\n type: Boolean,\n 'default': false,\n },\n target: {\n type: String,\n 'default': 'body',\n },\n offsetRef: {\n type: String,\n 'default': '',\n }\n },\n data() {\n return {\n wrapper: null,\n contentwrapper: null,\n resizeobserver: null,\n };\n },\n computed: {\n },\n methods: {\n initWrappers(target) {\n let initializeWrapperContent = false;\n // First check if the sidebar wrapper already exists. \n // Creating the wrappers over and over again is a recipe for disaster.\n this.wrapper = document.querySelector(\"#p-sidebar-wrapper\");\n if (!this.wrapper) {\n initializeWrapperContent = true;\n // Otherwise, create it.\n this.wrapper = document.createElement(\"div\");\n this.wrapper.setAttribute(\"id\", \"p-sidebar-wrapper\");\n }\n // First check if the contentwrapper already exists\n this.contentwrapper = document.querySelector(\"#p-sidebar-contentwrapper\");\n if (!this.contentwrapper) {\n initializeWrapperContent = true;\n // Otherwise, create it.\n this.contentwrapper = document.createElement(\"div\");\n this.contentwrapper.setAttribute(\"id\", \"p-sidebar-contentwrapper\");\n this.wrapper.appendChild(this.contentwrapper);\n }\n\n if (initializeWrapperContent) {\n // Find containing target (otherwise use body)\n let targetEl = document.querySelector(target);\n console.info(`Targeting '${target}' to `, targetEl);\n if (!targetEl || targetEl.nodeType == \"HTML\") {\n targetEl = document.querySelector(\"body\");\n }\n debug.warn(`Initializing wrappers with content of target `, targetEl);\n // Move all target content parts to content wrapper....\n while (targetEl.childNodes.length > 0) {\n this.contentwrapper.appendChild(targetEl.childNodes[0]);\n }\n // Add sidebar wrapper to target Element\n targetEl.appendChild(this.wrapper);\n }\n \n },\n rePosition(right) {\n // Place the container elsewhere in the DOM.\n const el = this.$refs.container;\n if (right) {\n this.wrapper.insertBefore(el, this.contentwrapper.nextSibling);\n } else {\n this.wrapper.insertBefore(el, this.contentwrapper);\n }\n },\n setOffset(reference) {\n const ref = reference ? document.querySelector(reference) : null;\n console.info(`Setting offset from '${reference}'`, ref);\n let offsetTop = (ref ? ref.offsetTop : 0);\n offsetTop += (offsetTop != 0) ? \"px\" : \"\";\n const el = this.$refs.container;\n el.style.height = `calc( 100vh - ${offsetTop})`;\n el.style.marginTop = offsetTop;\n }\n\n },\n watch: {\n right(newVal) {\n this.rePosition(newVal);\n },\n offsetRef(reference) {\n this.setOffset(reference);\n }\n },\n mounted() {\n const self = this;\n const el = self.$refs.container;\n this.initWrappers(this.target);\n this.setOffset(this.offsetRef);\n this.rePosition(this.right, this.besides);\n this.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 this.resizeObserver.observe(el);\n },\n unmounted() {\n if (this.resizeObserver) {\n this.resizeObserver.disconnect();\n }\n },\n template: `\n <div>\n <div ref='container' \n :class=\"'p-sidebar ' + (right?'p-sidebar-right ':'') + (shadow?'p-sidebar-shadow ':'') + (value?'shown ':'hidden ')\"\n ><slot></slot></div>\n </div>\n `,\n });\n },\n};"],"names":["debug","install","Vue","component","props","value","type","Boolean","right","shadow","target","String","offsetRef","data","wrapper","contentwrapper","resizeobserver","computed","methods","initWrappers","initializeWrapperContent","document","querySelector","this","createElement","setAttribute","appendChild","targetEl","console","info","nodeType","warn","childNodes","length","rePosition","el","$refs","container","insertBefore","nextSibling","setOffset","reference","ref","offsetTop","style","height","marginTop","watch","newVal","mounted","besides","resizeObserver","ResizeObserver","wx","getBoundingClientRect","width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