CoreFiles by mySites.guru
admin-add_module.js82 lines, 2,583 bytes, from Joomla_4.0.0-beta3-Beta-Full_Package.zip
Raw History Compare with 4.0.0-beta2
md5
e9c0b1cac4c37dbc5b399ade12b70f10
sha1
d2c1991c301527a04529219d656e8f412efc7f45
sha256
40e1941334623b257ee4ab2c66b4af80af517dcbaa05ec85c4ebedd5547433c6
/**
* 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 || {};

(function (document) {
  'use strict';

  document.addEventListener('DOMContentLoaded', function () {
    window.jSelectModuleType = function () {
      var elements = document.querySelectorAll('#moduleDashboardAddModal .modal-footer .btn.hidden');

      if (elements.length) {
        setTimeout(function () {
          elements.forEach(function (button) {
            button.classList.remove('hidden');
          });
        }, 1000);
      }
    };

    var buttons = document.querySelectorAll('#moduleDashboardAddModal .modal-footer .btn');
    var hideButtons = [];
    var isSaving = false;

    if (buttons.length) {
      buttons.forEach(function (button) {
        if (button.classList.contains('hidden')) {
          hideButtons.push(button);
        }

        button.addEventListener('click', function (event) {
          var elem = event.currentTarget; // There is some bug with events in iframe where currentTarget is "null"
          // => prevent this here by bubble up

          if (!elem) {
            elem = event.target;
          }

          if (elem) {
            var clickTarget = elem.getAttribute('data-target'); // We remember to be in the saving process

            isSaving = clickTarget === '#saveBtn'; // Reset saving process, if e.g. the validation of the form fails

            setTimeout(function () {
              isSaving = false;
            }, 1500);
            var iframe = document.querySelector('#moduleDashboardAddModal iframe');
            var content = iframe.contentDocument || iframe.contentWindow.document;
            var targetBtn = content.querySelector(clickTarget);

            if (targetBtn) {
              targetBtn.click();
            }
          }
        });
      });
    } // @TODO remove jQuery dependency, when the modal is not bootstrap anymore

    /* global jQuery */


    jQuery('#moduleDashboardAddModal').on('hide.bs.modal', function () {
      hideButtons.forEach(function (button) {
        button.classList.add('hidden');
      });
    });
    jQuery('#moduleDashboardAddModal').on('hidden.bs.modal', function () {
      if (isSaving) {
        setTimeout(function () {
          window.parent.location.reload();
        }, 1000);
      }
    });
  });
})(document);

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