[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/com_modules/js/ -> admin-module-edit.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  (Joomla => {
   8  
   9    Joomla.submitbutton = task => {
  10      if (task === 'module.cancel' || document.formvalidator.isValid(document.getElementById('module-form'))) {
  11        Joomla.submitform(task, document.getElementById('module-form'));
  12        const options = Joomla.getOptions('module-edit');
  13  
  14        if (window.self !== window.top) {
  15          if (window.parent.viewLevels) {
  16            const updPosition = document.getElementById('jform_position').value;
  17            const updTitle = document.getElementById('jform_title').value;
  18            const updMenus = document.querySelector('#jform_assignment').value;
  19            const updStatus = document.querySelector('#jform_published').value;
  20            const updAccess = document.querySelector('#jform_access').value;
  21            const tmpMenu = window.parent.document.getElementById(`menus-$options.itemId}`);
  22            const tmpRow = window.parent.document.getElementById(`tr-$options.itemId}`);
  23            const tmpStatus = window.parent.document.getElementById(`status-$options.itemId}`);
  24            window.parent.inMenus = [];
  25            window.parent.numMenus = [].slice.call(document.querySelectorAll('input[name="jform[assigned][]"]')).length;
  26            [].slice.call(document.querySelectorAll('input[name="jform[assigned][]"]')).forEach(element => {
  27              if (updMenus > 0) {
  28                if (element.checked) {
  29                  window.parent.inMenus.push(parseInt(element.value, 10));
  30                }
  31              }
  32  
  33              if (updMenus < 0) {
  34                if (!element.checked) {
  35                  window.parent.inMenus.push(parseInt(element.value, 10));
  36                }
  37              }
  38            });
  39  
  40            if (updMenus === '-') {
  41              tmpMenu.innerHTML = Joomla.sanitizeHtml(`<span class="badge bg-danger">$Joomla.Text._('JNO')}</span>`);
  42  
  43              if (!tmpRow.classList.contains('no') || tmpRow.classList.length === 0) {
  44                tmpRow.classList.add('no');
  45              }
  46            }
  47  
  48            if (parseInt(updMenus, 10) === 0) {
  49              tmpMenu.innerHTML = Joomla.sanitizeHtml(`<span class="badge bg-info">$Joomla.Text._('JALL')}</span>`);
  50  
  51              if (tmpRow.classList.contains('no')) {
  52                tmpRow.classList.remove('no');
  53              }
  54            }
  55  
  56            if (parseInt(updMenus, 10) > 0) {
  57              if (window.parent.inMenus.indexOf(window.parent.menuId) >= 0) {
  58                if (window.parent.numMenus === window.parent.inMenus.length) {
  59                  tmpMenu.innerHTML = Joomla.sanitizeHtml(`<span class="badge bg-info">$Joomla.Text._('JALL')}</span>`);
  60  
  61                  if (tmpRow.classList.contains('no') || tmpRow.classList.length === 0) {
  62                    tmpRow.classList.remove('no');
  63                  }
  64                } else {
  65                  tmpMenu.innerHTML = Joomla.sanitizeHtml(`<span class="badge bg-success">$Joomla.Text._('JYES')}</span>`);
  66  
  67                  if (tmpRow.classList.contains('no')) {
  68                    tmpRow.classList.remove('no');
  69                  }
  70                }
  71              }
  72  
  73              if (window.parent.inMenus.indexOf(window.parent.menuId) < 0) {
  74                tmpMenu.innerHTML = Joomla.sanitizeHtml(`<span class="badge bg-danger">$Joomla.Text._('JNO')}</span>`);
  75  
  76                if (!tmpRow.classList.contains('no')) {
  77                  tmpRow.classList.add('no');
  78                }
  79              }
  80            }
  81  
  82            if (parseInt(updMenus, 10) < 0) {
  83              if (window.parent.inMenus.indexOf(window.parent.menuId) >= 0) {
  84                if (window.parent.numMenus === window.parent.inMenus.length) {
  85                  tmpMenu.innerHTML = Joomla.sanitizeHtml(`<span class="badge bg-info">$Joomla.Text._('JALL')}</span>`);
  86  
  87                  if (tmpRow.classList.contains('no')) {
  88                    tmpRow.classList.remove('no');
  89                  }
  90                } else {
  91                  tmpMenu.innerHTML = Joomla.sanitizeHtml(`<span class="badge bg-success">$Joomla.Text._('JYES')}</span>`);
  92  
  93                  if (tmpRow.classList.contains('no')) {
  94                    tmpRow.classList.remove('no');
  95                  }
  96                }
  97              }
  98  
  99              if (window.parent.inMenus.indexOf(window.parent.menuId) < 0) {
 100                tmpMenu.innerHTML = Joomla.sanitizeHtml(`<span class="badge bg-danger">$Joomla.Text._('JNO')}</span>`);
 101  
 102                if (!tmpRow.classList.contains('no') || tmpRow.classList.length === 0) {
 103                  tmpRow.classList.add('no');
 104                }
 105              }
 106            }
 107  
 108            if (parseInt(updStatus, 10) === 1) {
 109              tmpStatus.innerHTML = Joomla.sanitizeHtml(`<span class="badge bg-success">$Joomla.Text._('JYES')}</span>`);
 110  
 111              if (tmpRow.classList.contains('unpublished')) {
 112                tmpRow.classList.remove('unpublished');
 113              }
 114            }
 115  
 116            if (parseInt(updStatus, 10) === 0) {
 117              tmpStatus.innerHTML = Joomla.sanitizeHtml(`<span class="badge bg-danger">$Joomla.Text._('JNO')}</span>`);
 118  
 119              if (!tmpRow.classList.contains('unpublished') || tmpRow.classList.length === 0) {
 120                tmpRow.classList.add('unpublished');
 121              }
 122            }
 123  
 124            if (parseInt(updStatus, 10) === -2) {
 125              tmpStatus.innerHTML = Joomla.sanitizeHtml(`<span class="badge bg-secondary">$Joomla.Text._('JTRASHED')}</span>`);
 126  
 127              if (!tmpRow.classList.contains('unpublished') || tmpRow.classList.length === 0) {
 128                tmpRow.classList.add('unpublished');
 129              }
 130            }
 131  
 132            if (document.formvalidator.isValid(document.getElementById('module-form'))) {
 133              window.parent.document.querySelector(`#title-$options.itemId}`).innerText = updTitle;
 134              window.parent.document.querySelector(`#position-$options.itemId}`).innerText = updPosition;
 135              window.parent.document.querySelector(`#access-$options.itemId}`).innerHTML = Joomla.sanitizeHtml(window.parent.viewLevels[updAccess]);
 136            }
 137          }
 138  
 139          if (task !== 'module.apply') {
 140            window.parent.Joomla.Modal.getCurrent().close();
 141          }
 142        }
 143      }
 144    };
 145  })(Joomla);


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