CoreFiles by mySites.guru
modal-content-select.js49 lines, 1,265 bytes, from Joomla_5.2.0-alpha2-Alpha-Full_Package.zip
Raw History Compare with 5.2.0-alpha1
md5
114057a8ca3d9e86ffb7dca64f13fe3e
sha1
f1dba02235b89c9aba7f71ff65fb3100459e0484
sha256
dee576bf09c14e5d9bce559d5f03ed186422fa3273389e9f73e7d9b918c883b6
function _extends() {
  _extends = Object.assign ? Object.assign.bind() : function (target) {
    for (var i = 1; i < arguments.length; i++) {
      var source = arguments[i];
      for (var key in source) {
        if (Object.prototype.hasOwnProperty.call(source, key)) {
          target[key] = source[key];
        }
      }
    }
    return target;
  };
  return _extends.apply(this, arguments);
}

/**
 * @copyright  (C) 2023 Open Source Matters, Inc. <https://www.joomla.org>
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */

/**
 * A helper to Post a Message
 * @param {Object} data
 */
const send = data => {
  // Set the message type and send it
  data.messageType = data.messageType || 'joomla:content-select';
  window.parent.postMessage(data);
};

// Bind the buttons
document.addEventListener('click', event => {
  const button = event.target.closest('[data-content-select]');
  if (!button) return;
  event.preventDefault();

  // Extract the data and send
  const data = _extends({}, button.dataset);
  delete data.contentSelect;
  send(data);
});

// Check for "select on load"
window.addEventListener('load', () => {
  const data = Joomla.getOptions('content-select-on-load');
  if (data) {
    send(data);
  }
});

The same content is in 37 releases, Joomla 5.0.0-beta1 to 5.2.0-alpha3. See them all, or every version of this file.