[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-messages/js/ -> sitewide-notices.js (source)

   1  // modules are defined as an array
   2  // [ module function, map of requires ]
   3  //
   4  // map of requires is short require name -> numeric require
   5  //
   6  // anything defined in a previous bundle is accessed via the
   7  // orig method which is the require for previous bundles
   8  parcelRequire = (function (modules, cache, entry, globalName) {
   9    // Save the require from previous bundle to this closure if any
  10    var previousRequire = typeof parcelRequire === 'function' && parcelRequire;
  11    var nodeRequire = typeof require === 'function' && require;
  12  
  13    function newRequire(name, jumped) {
  14      if (!cache[name]) {
  15        if (!modules[name]) {
  16          // if we cannot find the module within our internal map or
  17          // cache jump to the current global require ie. the last bundle
  18          // that was added to the page.
  19          var currentRequire = typeof parcelRequire === 'function' && parcelRequire;
  20          if (!jumped && currentRequire) {
  21            return currentRequire(name, true);
  22          }
  23  
  24          // If there are other bundles on this page the require from the
  25          // previous one is saved to 'previousRequire'. Repeat this as
  26          // many times as there are bundles until the module is found or
  27          // we exhaust the require chain.
  28          if (previousRequire) {
  29            return previousRequire(name, true);
  30          }
  31  
  32          // Try the node require function if it exists.
  33          if (nodeRequire && typeof name === 'string') {
  34            return nodeRequire(name);
  35          }
  36  
  37          var err = new Error('Cannot find module \'' + name + '\'');
  38          err.code = 'MODULE_NOT_FOUND';
  39          throw err;
  40        }
  41  
  42        localRequire.resolve = resolve;
  43        localRequire.cache = {};
  44  
  45        var module = cache[name] = new newRequire.Module(name);
  46  
  47        modules[name][0].call(module.exports, localRequire, module, module.exports, this);
  48      }
  49  
  50      return cache[name].exports;
  51  
  52      function localRequire(x){
  53        return newRequire(localRequire.resolve(x));
  54      }
  55  
  56      function resolve(x){
  57        return modules[name][1][x] || x;
  58      }
  59    }
  60  
  61    function Module(moduleName) {
  62      this.id = moduleName;
  63      this.bundle = newRequire;
  64      this.exports = {};
  65    }
  66  
  67    newRequire.isParcelRequire = true;
  68    newRequire.Module = Module;
  69    newRequire.modules = modules;
  70    newRequire.cache = cache;
  71    newRequire.parent = previousRequire;
  72    newRequire.register = function (id, exports) {
  73      modules[id] = [function (require, module) {
  74        module.exports = exports;
  75      }, {}];
  76    };
  77  
  78    var error;
  79    for (var i = 0; i < entry.length; i++) {
  80      try {
  81        newRequire(entry[i]);
  82      } catch (e) {
  83        // Save first error but execute all entries
  84        if (!error) {
  85          error = e;
  86        }
  87      }
  88    }
  89  
  90    if (entry.length) {
  91      // Expose entry point to Node, AMD or browser globals
  92      // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js
  93      var mainExports = newRequire(entry[entry.length - 1]);
  94  
  95      // CommonJS
  96      if (typeof exports === "object" && typeof module !== "undefined") {
  97        module.exports = mainExports;
  98  
  99      // RequireJS
 100      } else if (typeof define === "function" && define.amd) {
 101       define(function () {
 102         return mainExports;
 103       });
 104  
 105      // <script>
 106      } else if (globalName) {
 107        this[globalName] = mainExports;
 108      }
 109    }
 110  
 111    // Override the current require with this new one
 112    parcelRequire = newRequire;
 113  
 114    if (error) {
 115      // throw error from earlier, _after updating parcelRequire_
 116      throw error;
 117    }
 118  
 119    return newRequire;
 120  })({"nIsC":[function(require,module,exports) {
 121  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
 122  
 123  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
 124  
 125  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
 126  
 127  /**
 128   * Front-end Sitewide notices block class.
 129   *
 130   * @since 9.0.0
 131   */
 132  var bpSitewideNoticeBlock = /*#__PURE__*/function () {
 133    function bpSitewideNoticeBlock(settings) {
 134      _classCallCheck(this, bpSitewideNoticeBlock);
 135  
 136      var path = settings.path,
 137          dismissPath = settings.dismissPath,
 138          root = settings.root,
 139          nonce = settings.nonce;
 140      this.path = path;
 141      this.dismissPath = dismissPath;
 142      this.root = root;
 143      this.nonce = nonce;
 144    }
 145  
 146    _createClass(bpSitewideNoticeBlock, [{
 147      key: "start",
 148      value: function start() {
 149        var _this = this;
 150  
 151        // Listen to each Block's dismiss button clicks
 152        document.querySelectorAll('.bp-sitewide-notice-block a.dismiss-notice').forEach(function (dismissButton) {
 153          dismissButton.addEventListener('click', function (event) {
 154            event.preventDefault();
 155            fetch(_this.root + _this.dismissPath, {
 156              method: 'POST',
 157              headers: {
 158                'X-WP-Nonce': _this.nonce
 159              }
 160            }).then(function (response) {
 161              return response.json();
 162            }).then(function (data) {
 163              if ('undefined' !== typeof data && 'undefined' !== typeof data.dismissed && data.dismissed) {
 164                document.querySelectorAll('.bp-sitewide-notice-block').forEach(function (elem) {
 165                  elem.remove();
 166                });
 167              }
 168            });
 169          });
 170        });
 171      }
 172    }]);
 173  
 174    return bpSitewideNoticeBlock;
 175  }(); // widget_bp_core_sitewide_messages buddypress widget wp-block-bp-sitewide-notices > bp-sitewide-notice > a.dismiss-notice
 176  
 177  
 178  var settings = window.bpSitewideNoticeBlockSettings || {};
 179  var bpSitewideNotice = new bpSitewideNoticeBlock(settings);
 180  
 181  if ('loading' === document.readyState) {
 182    document.addEventListener('DOMContentLoaded', bpSitewideNotice.start());
 183  } else {
 184    bpSitewideNotice.start();
 185  }
 186  },{}]},{},["nIsC"], null)


Generated: Wed Oct 27 01:00:59 2021 Cross-referenced by PHPXref 0.7.1