# merchant/2.3.0/assets/js/modal.js

Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together &amp; More for WooCommerce – Merchant, version 2.3.0. 51 lines.

- Page: https://pluginprobe.com/plugins/merchant/2.3.0/code/assets/js/modal.js
- Raw: https://pluginprobe.com/plugins/merchant/2.3.0/raw/assets/js/modal.js
- Modified: 2026-07-21T16:38:56+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/merchant/2.3.0/code/assets/js/modal.js#L10-L20`.

```javascript
/**
 * Merchant Modal.
 * 
 */

'use strict';

var merchant = merchant || {};
merchant.modal = {
  init: function init() {
    var self = this,
      els = document.querySelectorAll('[data-merchant-modal-trigger]');
    if (!els.length) {
      return;
    }
    els.forEach(function (el) {
      el.addEventListener('click', self.openModal);
    });
    document.querySelectorAll('[data-merchant-modal-close]').forEach(function (el) {
      el.addEventListener('click', self.buttonCloseModal);
    });
  },
  toggleBodyClass: function toggleBodyClass() {
    document.body.classList.toggle('merchant-modal-opened');
  },
  openModal: function openModal(event) {
    event.preventDefault();
    event.stopPropagation();
    var popupId = this.getAttribute('data-merchant-modal'),
      popup = document.querySelector('.merchant-modal[data-merchant-modal="' + popupId + '"]');
    merchant.modal.toggleBodyClass();
    popup.classList.add('show');
    popup.addEventListener('click', merchant.modal.closeModal);
  },
  closeModal: function closeModal(event) {
    if (event.target.closest('.merchant-modal-body') === null) {
      merchant.modal.toggleBodyClass();
      this.classList.remove('show');
    }
  },
  buttonCloseModal: function buttonCloseModal(event) {
    event.preventDefault();
    event.stopPropagation();
    var popup = this.closest('.merchant-modal');
    merchant.modal.toggleBodyClass();
    popup.classList.remove('show');
  }
};
document.addEventListener('DOMContentLoaded', function () {
  merchant.modal.init();
});
```
