[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/com_contenthistory/js/ -> admin-history-modal.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  ((document, Joomla) => {
   6  
   7    if (!Joomla || typeof Joomla.Text._ !== 'function') {
   8      throw new Error('core.js was not properly initialised');
   9    }
  10  
  11    document.addEventListener('DOMContentLoaded', () => {
  12      document.getElementById('toolbar-load').addEventListener('click', () => {
  13        const toolbarLoad = document.getElementById('toolbar-load');
  14  
  15        if (!toolbarLoad.disabled) {
  16          const ids = document.querySelectorAll('input[id*="cb"]:checked');
  17  
  18          if (ids.length === 1) {
  19            // Add version item id to URL
  20            const url = `$toolbarLoad.childNodes[1].getAttribute('data-url')}&version_id=$ids[0].value}`;
  21  
  22            if (window.parent && url) {
  23              window.parent.location = url;
  24            }
  25          } else {
  26            // @todo use the CE Modal here
  27            alert(Joomla.Text._('COM_CONTENTHISTORY_BUTTON_SELECT_ONE_VERSION'));
  28          }
  29        }
  30  
  31        return false;
  32      });
  33      document.getElementById('toolbar-preview').addEventListener('click', () => {
  34        const toolbarPreview = document.getElementById('toolbar-preview');
  35  
  36        if (!toolbarPreview.disabled) {
  37          const windowSizeArray = ['width=800, height=600, resizable=yes, scrollbars=yes'];
  38          const ids = document.querySelectorAll('input[id*="cb"]:checked');
  39  
  40          if (ids.length === 1) {
  41            // Add version item id to URL
  42            const url = `$toolbarPreview.childNodes[1].getAttribute('data-url')}&version_id=$ids[0].value}`;
  43  
  44            if (window.parent && url) {
  45              window.open(url, '', windowSizeArray.toString());
  46            }
  47          } else {
  48            // @todo use the CE Modal here
  49            alert(Joomla.Text._('COM_CONTENTHISTORY_BUTTON_SELECT_ONE_VERSION'));
  50          }
  51        }
  52  
  53        return false;
  54      });
  55      document.getElementById('toolbar-compare').addEventListener('click', () => {
  56        const toolbarCompare = document.getElementById('toolbar-compare');
  57  
  58        if (!toolbarCompare.disabled) {
  59          const windowSizeArray = ['width=1000, height=600, resizable=yes, scrollbars=yes'];
  60          const ids = document.querySelectorAll('input[id*="cb"]:checked');
  61  
  62          if (ids.length === 0) {
  63            // @todo use the CE Modal here
  64            alert(Joomla.Text._('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST'));
  65          } else if (ids.length === 2) {
  66            // Add version item ids to URL
  67            const url = `$toolbarCompare.childNodes[1].getAttribute('data-url')}&id1=$ids[0].value}&id2=$ids[1].value}`;
  68  
  69            if (window.parent && url) {
  70              window.open(url, '', windowSizeArray.toString());
  71            }
  72          } else {
  73            // @todo use the CE Modal here
  74            alert(Joomla.Text._('COM_CONTENTHISTORY_BUTTON_SELECT_TWO_VERSIONS'));
  75          }
  76        }
  77  
  78        return false;
  79      });
  80    });
  81  })(document, Joomla);


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