CoreFiles by mySites.guru
admin-item-edit_modules.es6.js103 lines, 3,384 bytes, from Joomla_4.0.0-beta2-Beta-Full_Package.zip
Raw History Compare with 4.0.0-beta
md5
f509c7620a5ec623b2686ca1ed1ec73a
sha1
e2c11f2c9a42a3908840a045dd40873636aeb4e6
sha256
05645850279ce21af6e195d6e1303ef03b492e751d7ddaa9e481d0d4f34640b6
/**
* PLEASE DO NOT MODIFY THIS FILE. WORK ON THE ES6 VERSION.
* OTHERWISE YOUR CHANGES WILL BE REPLACED ON THE NEXT BUILD.
**/

/**
 * @copyright  Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */
Joomla = window.Joomla || {};

(() => {
  'use strict';

  const options = Joomla.getOptions('menus-edit-modules');

  if (options) {
    window.viewLevels = options.viewLevels;
    window.menuId = parseInt(options.itemId, 10);
  }

  const baseLink = 'index.php?option=com_modules&client_id=0&task=module.edit&tmpl=component&view=module&layout=modal&id=';
  const assigned1 = document.getElementById('jform_toggle_modules_assigned1');
  const assigned0 = document.getElementById('jform_toggle_modules_assigned0');
  const published1 = document.getElementById('jform_toggle_modules_published1');
  const published0 = document.getElementById('jform_toggle_modules_published0');
  const linkElements = [].slice.call(document.getElementsByClassName('module-edit-link'));
  const elements = [].slice.call(document.querySelectorAll('#moduleEditModal .modal-footer .btn'));

  if (assigned1) {
    assigned1.addEventListener('click', () => {
      const list = [].slice.call(document.querySelectorAll('tr.no'));
      list.forEach(item => {
        item.classList.add('table-row');
        item.classList.remove('hidden');
      });
    });
  }

  if (assigned0) {
    assigned0.addEventListener('click', () => {
      const list = [].slice.call(document.querySelectorAll('tr.no'));
      list.forEach(item => {
        item.classList.add('hidden');
        item.classList.remove('table-row');
      });
    });
  }

  if (published1) {
    published1.addEventListener('click', () => {
      const list = [].slice.call(document.querySelectorAll('.table tr.unpublished'));
      list.forEach(item => {
        item.classList.add('table-row');
        item.classList.remove('hidden');
      });
    });
  }

  if (published0) {
    published0.addEventListener('click', () => {
      const list = [].slice.call(document.querySelectorAll('.table tr.unpublished'));
      list.forEach(item => {
        item.classList.add('hidden');
        item.classList.remove('table-row');
      });
    });
  }

  if (linkElements.length) {
    linkElements.forEach(linkElement => {
      linkElement.addEventListener('click', ({
        target
      }) => {
        const link = baseLink + target.getAttribute('data-module-id');
        const modal = document.getElementById('moduleEditModal');
        const body = modal.querySelector('.modal-body');
        const iFrame = document.createElement('iframe');
        iFrame.src = link;
        iFrame.setAttribute('class', 'class="iframe jviewport-height70"');
        body.innerHTML = '';
        body.appendChild(iFrame);
        modal.open();
      });
    });
  }

  if (elements.length) {
    elements.forEach(element => {
      element.addEventListener('click', ({
        target
      }) => {
        const dataTarget = target.getAttribute('data-target');

        if (dataTarget) {
          const iframe = document.querySelector('#moduleEditModal iframe');
          const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
          iframeDocument.querySelector(dataTarget).click();
        }
      });
    });
  }
})();

The same content is in 5 releases, Joomla 4.0.0-beta to 4.0.0-beta5. See them all, or every version of this file.