CoreFiles by mySites.guru
stats-message.js98 lines, 3,046 bytes, from Joomla_4.0.0-beta6-Beta-Full_Package.zip
Raw History Compare with 4.0.0-beta5
md5
ae6b6b50e990f8ae30b6ad719f96c795
sha1
bdb5d14e0070c9d714a5a44724c223e7e08469f3
sha256
821ffaedb5f21a8cd374c2db3508642e0f1387141e90a31e47761fc858fa7c04
/**
* PLEASE DO NOT MODIFY THIS FILE. WORK ON THE ES6 VERSION.
* OTHERWISE YOUR CHANGES WILL BE REPLACED ON THE NEXT BUILD.
**/

/**
 * @copyright  (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 * @since      3.5.0
 */
Joomla = window.Joomla || {};

(function (Joomla, document) {
  'use strict';

  var initStatsEvents = function initStatsEvents(callback) {
    var messageContainer = document.getElementById('system-message-container');
    var joomlaAlert = messageContainer.querySelector('.js-pstats-alert');
    var detailsContainer = messageContainer.querySelector('#js-pstats-data-details'); // Show details about the information being sent

    document.addEventListener('click', function (event) {
      if (event.target.classList.contains('js-pstats-btn-details')) {
        event.preventDefault();
        detailsContainer.classList.toggle('d-none');
      }
    }); // Always allow

    document.addEventListener('click', function (event) {
      if (event.target.classList.contains('js-pstats-btn-allow-always')) {
        event.preventDefault(); // Remove message

        joomlaAlert.close();
        callback({
          plugin: 'sendAlways'
        });
      }
    }); // Allow once

    document.addEventListener('click', function (event) {
      if (event.target.classList.contains('js-pstats-btn-allow-once')) {
        event.preventDefault(); // Remove message

        joomlaAlert.close();
        callback({
          plugin: 'sendOnce'
        });
      }
    }); // Never allow

    document.addEventListener('click', function (event) {
      if (event.target.classList.contains('js-pstats-btn-allow-never')) {
        event.preventDefault(); // Remove message

        joomlaAlert.close();
        callback({
          plugin: 'sendNever'
        });
      }
    });
  };

  var getJson = function getJson() {
    var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
        _ref$plugin = _ref.plugin,
        plugin = _ref$plugin === void 0 ? 'sendStats' : _ref$plugin;

    var url = "index.php?option=com_ajax&group=system&plugin=".concat(plugin, "&format=raw");
    var messageContainer = document.getElementById('system-message-container');
    Joomla.request({
      url: url,
      headers: {
        'Content-Type': 'application/json'
      },
      onSuccess: function onSuccess(response) {
        try {
          var json = JSON.parse(response);

          if (json && json.html) {
            messageContainer.innerHTML = json.html;
            messageContainer.querySelector('.js-pstats-alert').classList.remove('hidden');
            initStatsEvents(getJson);
          }
        } catch (e) {
          throw new Error(e);
        }
      },
      onError: function onError(xhr) {
        Joomla.renderMessages({
          error: [xhr.response]
        });
      }
    });
  };

  document.addEventListener('DOMContentLoaded', function () {
    getJson();
  });
})(Joomla, document);

No other release has this exact content. See every version of this file.