[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/com_menus/js/ -> admin-item-edit_modules.js (source)

   1  /**
   2   * @copyright  (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
   3   * @license    GNU General Public License version 2 or later; see LICENSE.txt
   4   */
   5  Joomla = window.Joomla || {};
   6  
   7  (() => {
   8  
   9    const options = Joomla.getOptions('menus-edit-modules');
  10  
  11    if (options) {
  12      window.viewLevels = options.viewLevels;
  13      window.menuId = parseInt(options.itemId, 10);
  14    }
  15  
  16    const baseLink = 'index.php?option=com_modules&client_id=0&task=module.edit&tmpl=component&view=module&layout=modal&id=';
  17    const assigned1 = document.getElementById('jform_toggle_modules_assigned1');
  18    const assigned0 = document.getElementById('jform_toggle_modules_assigned0');
  19    const published1 = document.getElementById('jform_toggle_modules_published1');
  20    const published0 = document.getElementById('jform_toggle_modules_published0');
  21    const linkElements = [].slice.call(document.getElementsByClassName('module-edit-link'));
  22    const elements = [].slice.call(document.querySelectorAll('#moduleEditModal .modal-footer .btn'));
  23  
  24    if (assigned1) {
  25      assigned1.addEventListener('click', () => {
  26        const list = [].slice.call(document.querySelectorAll('tr.no'));
  27        list.forEach(item => {
  28          item.classList.add('table-row');
  29          item.classList.remove('hidden');
  30        });
  31      });
  32    }
  33  
  34    if (assigned0) {
  35      assigned0.addEventListener('click', () => {
  36        const list = [].slice.call(document.querySelectorAll('tr.no'));
  37        list.forEach(item => {
  38          item.classList.add('hidden');
  39          item.classList.remove('table-row');
  40        });
  41      });
  42    }
  43  
  44    if (published1) {
  45      published1.addEventListener('click', () => {
  46        const list = [].slice.call(document.querySelectorAll('.table tr.unpublished'));
  47        list.forEach(item => {
  48          item.classList.add('table-row');
  49          item.classList.remove('hidden');
  50        });
  51      });
  52    }
  53  
  54    if (published0) {
  55      published0.addEventListener('click', () => {
  56        const list = [].slice.call(document.querySelectorAll('.table tr.unpublished'));
  57        list.forEach(item => {
  58          item.classList.add('hidden');
  59          item.classList.remove('table-row');
  60        });
  61      });
  62    }
  63  
  64    if (linkElements.length) {
  65      linkElements.forEach(linkElement => {
  66        linkElement.addEventListener('click', ({
  67          target
  68        }) => {
  69          const link = baseLink + target.getAttribute('data-module-id');
  70          const modal = document.getElementById('moduleEditModal');
  71          const body = modal.querySelector('.modal-body');
  72          const iFrame = document.createElement('iframe');
  73          iFrame.src = link;
  74          iFrame.setAttribute('class', 'class="iframe jviewport-height70"');
  75          body.innerHTML = '';
  76          body.appendChild(iFrame);
  77          modal.open();
  78        });
  79      });
  80    }
  81  
  82    if (elements.length) {
  83      elements.forEach(element => {
  84        element.addEventListener('click', ({
  85          target
  86        }) => {
  87          const dataTarget = target.getAttribute('data-bs-target');
  88  
  89          if (dataTarget) {
  90            const iframe = document.querySelector('#moduleEditModal iframe');
  91            const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
  92            iframeDocument.querySelector(dataTarget).click();
  93          }
  94        });
  95      });
  96    }
  97  })();


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer