[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-friends/js/blocks/ -> friends.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  })({"CSIX":[function(require,module,exports) {
 121  "use strict";
 122  
 123  Object.defineProperty(exports, "__esModule", {
 124    value: true
 125  });
 126  exports.TYPES = void 0;
 127  
 128  /**
 129   * WordPress dependencies.
 130   */
 131  const {
 132    i18n: {
 133      __
 134    }
 135  } = wp;
 136  /**
 137   * Friends ordering types.
 138   *
 139   * @type {Array}
 140   */
 141  
 142  const TYPES = [{
 143    label: __('Newest', 'buddypress'),
 144    value: 'newest'
 145  }, {
 146    label: __('Active', 'buddypress'),
 147    value: 'active'
 148  }, {
 149    label: __('Popular', 'buddypress'),
 150    value: 'popular'
 151  }];
 152  exports.TYPES = TYPES;
 153  },{}],"qXsY":[function(require,module,exports) {
 154  "use strict";
 155  
 156  Object.defineProperty(exports, "__esModule", {
 157    value: true
 158  });
 159  exports.default = void 0;
 160  
 161  var _constants = require("./constants");
 162  
 163  /**
 164   * WordPress dependencies.
 165   */
 166  const {
 167    blockEditor: {
 168      InspectorControls
 169    },
 170    components: {
 171      Disabled,
 172      PanelBody,
 173      RangeControl,
 174      SelectControl,
 175      ToggleControl
 176    },
 177    element: {
 178      Fragment,
 179      createElement
 180    },
 181    i18n: {
 182      __
 183    },
 184    serverSideRender: ServerSideRender
 185  } = wp;
 186  /**
 187   * BuddyPress dependencies.
 188   */
 189  
 190  const {
 191    blockData: {
 192      currentPostId
 193    }
 194  } = bp;
 195  /**
 196   * Internal dependencies.
 197   */
 198  
 199  const editDynamicFriendsBlock = ({
 200    attributes,
 201    setAttributes
 202  }) => {
 203    const {
 204      postId,
 205      maxFriends,
 206      friendDefault,
 207      linkTitle
 208    } = attributes;
 209    const post = currentPostId();
 210  
 211    if (!postId && post) {
 212      setAttributes({
 213        postId: post
 214      });
 215    }
 216  
 217    return createElement(Fragment, null, createElement(InspectorControls, null, createElement(PanelBody, {
 218      title: __('Settings', 'buddypress'),
 219      initialOpen: true
 220    }, createElement(RangeControl, {
 221      label: __('Max friends to show', 'buddypress'),
 222      value: maxFriends,
 223      onChange: value => setAttributes({
 224        maxFriends: value
 225      }),
 226      min: 1,
 227      max: 10,
 228      required: true
 229    }), createElement(SelectControl, {
 230      label: __('Default members to show', 'buddypress'),
 231      value: friendDefault,
 232      options: _constants.TYPES,
 233      onChange: option => {
 234        setAttributes({
 235          friendDefault: option
 236        });
 237      }
 238    }), createElement(ToggleControl, {
 239      label: __('Link block title to Member\'s profile friends page', 'buddypress'),
 240      checked: !!linkTitle,
 241      onChange: () => {
 242        setAttributes({
 243          linkTitle: !linkTitle
 244        });
 245      }
 246    }))), createElement(Disabled, null, createElement(ServerSideRender, {
 247      block: "bp/friends",
 248      attributes: attributes
 249    })));
 250  };
 251  
 252  var _default = editDynamicFriendsBlock;
 253  exports.default = _default;
 254  },{"./constants":"CSIX"}],"fch3":[function(require,module,exports) {
 255  "use strict";
 256  
 257  Object.defineProperty(exports, "__esModule", {
 258    value: true
 259  });
 260  exports.default = void 0;
 261  
 262  /**
 263   * WordPress dependencies.
 264   */
 265  const {
 266    blocks: {
 267      createBlock
 268    }
 269  } = wp;
 270  /**
 271   * Transforms Legacy Widget to Friends Block.
 272   *
 273   * @type {Object}
 274   */
 275  
 276  const transforms = {
 277    from: [{
 278      type: 'block',
 279      blocks: ['core/legacy-widget'],
 280      isMatch: ({
 281        idBase,
 282        instance
 283      }) => {
 284        if (!(instance !== null && instance !== void 0 && instance.raw)) {
 285          return false;
 286        }
 287  
 288        return idBase === 'bp_core_friends_widget';
 289      },
 290      transform: ({
 291        instance
 292      }) => {
 293        return createBlock('bp/friends', {
 294          maxFriends: instance.raw.max_friends,
 295          friendDefault: instance.raw.friend_default,
 296          linkTitle: instance.raw.link_title
 297        });
 298      }
 299    }]
 300  };
 301  var _default = transforms;
 302  exports.default = _default;
 303  },{}],"Z2R5":[function(require,module,exports) {
 304  "use strict";
 305  
 306  var _edit = _interopRequireDefault(require("./friends/edit"));
 307  
 308  var _transforms = _interopRequireDefault(require("./friends/transforms"));
 309  
 310  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 311  
 312  /**
 313   * WordPress dependencies.
 314   */
 315  const {
 316    blocks: {
 317      registerBlockType
 318    },
 319    i18n: {
 320      __
 321    }
 322  } = wp;
 323  /**
 324   * Internal dependencies.
 325   */
 326  
 327  registerBlockType('bp/friends', {
 328    title: __('Friends List', 'buddypress'),
 329    description: __('A dynamic list of recently active, popular, and newest friends of the post author (when used into a page or post) or of the displayed member (when used in a widgetized area). If author/member data is not available the block is not displayed.', 'buddypress'),
 330    icon: {
 331      background: '#fff',
 332      foreground: '#d84800',
 333      src: 'buddicons-friends'
 334    },
 335    category: 'buddypress',
 336    attributes: {
 337      maxFriends: {
 338        type: 'number',
 339        default: 5
 340      },
 341      friendDefault: {
 342        type: 'string',
 343        default: 'active'
 344      },
 345      linkTitle: {
 346        type: 'boolean',
 347        default: false
 348      },
 349      postId: {
 350        type: 'number',
 351        default: 0
 352      }
 353    },
 354    edit: _edit.default,
 355    transforms: _transforms.default
 356  });
 357  },{"./friends/edit":"qXsY","./friends/transforms":"fch3"}]},{},["Z2R5"], null)


Generated: Fri Apr 19 01:01:08 2024 Cross-referenced by PHPXref 0.7.1