HEX
Server: LiteSpeed
System: Linux s3604.bom1.stableserver.net 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64
User: dmstechonline (1480)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /home/dmstechonline/businessclub.dmstech.online/wp-content/themes/rishi/customizer/src/builder.js
class Builder {
	constructor(panel, args = {}) {
		this.args = {
			container: '.rishi-layout-composer',
			parentEl: '.wp-full-overlay',
			activeClass: 'rishi-builder-open',
			...args,
		}
		this.panel = panel
		// this.settingKey = settingKey;
		this.container = document.querySelector(this.args.container)
		this.parentEl = document.querySelector(this.args.parentEl)

		if (!this.container) {
			const root = document.createElement('div')
			root.classList.add(this.args.container.replace(/^\W/, ''))
			this.container = root
			this.parentEl.appendChild(root)
		}

		this.toggle = this.toggle.bind(this)
		this.getPanelInstance = this.getPanelInstance.bind(this)
		this.setupPanel = this.setupPanel.bind(this)
		this.setupPanel()
	}

	getPanelInstance() {
		return wp.customize.panel(this.panel) ? wp.customize.panel : wp.customize.section
	}

	toggle(open) {
		this.parentEl.classList.toggle(this.args.activeClass, open)
		if (!open) setTimeout(() => (this.container.innerHTML = ''))
		if (open) this.container.dataset.builder = this.panel
		else this.container.dataset.builder = ''
	}

	setupPanel() {
		this.getPanelInstance()(this.panel, (section) => section.expanded.bind(this.toggle))
	}
}

export default Builder