[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-activity/js/blocks/ -> latest-activities.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  })({"DIzr":[function(require,module,exports) {
 121  "use strict";
 122  
 123  Object.defineProperty(exports, "__esModule", {
 124    value: true
 125  });
 126  exports.default = void 0;
 127  
 128  /**
 129   * WordPress dependencies.
 130   */
 131  const {
 132    blockEditor: {
 133      InspectorControls
 134    },
 135    components: {
 136      Disabled,
 137      PanelBody,
 138      RangeControl,
 139      SelectControl,
 140      TextControl
 141    },
 142    element: {
 143      Fragment,
 144      createElement
 145    },
 146    i18n: {
 147      __
 148    },
 149    serverSideRender: ServerSideRender
 150  } = wp;
 151  /**
 152   * BuddyPress dependencies.
 153   */
 154  
 155  const {
 156    blockData: {
 157      currentPostId,
 158      activityTypes
 159    }
 160  } = bp;
 161  
 162  const editDynamicActivitiesBlock = ({
 163    attributes,
 164    setAttributes
 165  }) => {
 166    const {
 167      postId,
 168      maxActivities,
 169      type,
 170      title
 171    } = attributes;
 172    const post = currentPostId();
 173    const types = activityTypes();
 174  
 175    if (!postId && post) {
 176      setAttributes({
 177        postId: post
 178      });
 179  
 180      if (!attributes.postId) {
 181        attributes.postId = post;
 182      }
 183    }
 184  
 185    return createElement(Fragment, null, createElement(InspectorControls, null, createElement(PanelBody, {
 186      title: __('Settings', 'buddypress'),
 187      initialOpen: true,
 188      className: "bp-latest-activities"
 189    }, createElement(TextControl, {
 190      label: __('Title', 'buddypress'),
 191      value: title,
 192      onChange: text => {
 193        setAttributes({
 194          title: text
 195        });
 196      }
 197    }), createElement(RangeControl, {
 198      label: __('Maximum amount to display', 'buddypress'),
 199      value: maxActivities,
 200      onChange: value => setAttributes({
 201        maxActivities: value
 202      }),
 203      min: 1,
 204      max: 10,
 205      required: true
 206    }), createElement(SelectControl, {
 207      multiple: true,
 208      label: __('Type', 'buddypress'),
 209      value: type,
 210      options: types,
 211      onChange: option => {
 212        setAttributes({
 213          type: option
 214        });
 215      }
 216    }))), createElement(Disabled, null, createElement(ServerSideRender, {
 217      block: "bp/latest-activities",
 218      attributes: attributes
 219    })));
 220  };
 221  
 222  var _default = editDynamicActivitiesBlock;
 223  exports.default = _default;
 224  },{}],"yqpU":[function(require,module,exports) {
 225  "use strict";
 226  
 227  Object.defineProperty(exports, "__esModule", {
 228    value: true
 229  });
 230  exports.default = void 0;
 231  
 232  /**
 233   * WordPress dependencies.
 234   */
 235  const {
 236    blocks: {
 237      createBlock
 238    }
 239  } = wp;
 240  /**
 241   * Transforms Nouveau Activity Widget to Activity Block.
 242   *
 243   * @type {Object}
 244   */
 245  
 246  const transforms = {
 247    from: [{
 248      type: 'block',
 249      blocks: ['core/legacy-widget'],
 250      isMatch: ({
 251        idBase,
 252        instance
 253      }) => {
 254        if (!(instance !== null && instance !== void 0 && instance.raw)) {
 255          return false;
 256        }
 257  
 258        return idBase === 'bp_latest_activities';
 259      },
 260      transform: ({
 261        instance
 262      }) => {
 263        const regex = /i:\d*;s:\d*:"(.*?)";/gmi;
 264        let types = [];
 265        let matches;
 266  
 267        while ((matches = regex.exec(instance.raw.type)) !== null) {
 268          if (matches.index === regex.lastIndex) {
 269            regex.lastIndex++;
 270          }
 271  
 272          matches.forEach((match, groupIndex) => {
 273            if (1 === groupIndex) {
 274              types.push(match);
 275            }
 276          });
 277        }
 278  
 279        return createBlock('bp/latest-activities', {
 280          title: instance.raw.title,
 281          maxActivities: parseInt(instance.raw.max, 10),
 282          type: types
 283        });
 284      }
 285    }]
 286  };
 287  var _default = transforms;
 288  exports.default = _default;
 289  },{}],"q3eE":[function(require,module,exports) {
 290  "use strict";
 291  
 292  var _edit = _interopRequireDefault(require("./latest-activities/edit"));
 293  
 294  var _transforms = _interopRequireDefault(require("./latest-activities/transforms"));
 295  
 296  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 297  
 298  /**
 299   * WordPress dependencies.
 300   */
 301  const {
 302    blocks: {
 303      registerBlockType
 304    },
 305    i18n: {
 306      __
 307    }
 308  } = wp;
 309  /**
 310   * Internal dependencies.
 311   */
 312  
 313  registerBlockType('bp/latest-activities', {
 314    title: __('Latest Activities', 'buddypress'),
 315    description: __('Display the latest updates of the post author (when used into a page or post), of the displayed user (when viewing their profile) or of your community.', 'buddypress'),
 316    icon: {
 317      background: '#fff',
 318      foreground: '#d84800',
 319      src: 'buddicons-activity'
 320    },
 321    category: 'buddypress',
 322    attributes: {
 323      title: {
 324        type: 'string',
 325        default: __('Latest updates', 'buddypress')
 326      },
 327      maxActivities: {
 328        type: 'number',
 329        default: 5
 330      },
 331      type: {
 332        type: 'array',
 333        default: ['activity_update']
 334      },
 335      postId: {
 336        type: 'number',
 337        default: 0
 338      }
 339    },
 340    edit: _edit.default,
 341    transforms: _transforms.default
 342  });
 343  },{"./latest-activities/edit":"DIzr","./latest-activities/transforms":"yqpU"}]},{},["q3eE"], null)


Generated: Wed Jan 19 01:01:00 2022 Cross-referenced by PHPXref 0.7.1