[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/js/dist/ -> token-list.js (source)

   1  this["wp"] = this["wp"] || {}; this["wp"]["tokenList"] =
   2  /******/ (function(modules) { // webpackBootstrap
   3  /******/     // The module cache
   4  /******/     var installedModules = {};
   5  /******/
   6  /******/     // The require function
   7  /******/ 	function __webpack_require__(moduleId) {
   8  /******/
   9  /******/         // Check if module is in cache
  10  /******/         if(installedModules[moduleId]) {
  11  /******/             return installedModules[moduleId].exports;
  12  /******/         }
  13  /******/         // Create a new module (and put it into the cache)
  14  /******/         var module = installedModules[moduleId] = {
  15  /******/             i: moduleId,
  16  /******/             l: false,
  17  /******/             exports: {}
  18  /******/         };
  19  /******/
  20  /******/         // Execute the module function
  21  /******/         modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22  /******/
  23  /******/         // Flag the module as loaded
  24  /******/         module.l = true;
  25  /******/
  26  /******/         // Return the exports of the module
  27  /******/         return module.exports;
  28  /******/     }
  29  /******/
  30  /******/
  31  /******/     // expose the modules object (__webpack_modules__)
  32  /******/     __webpack_require__.m = modules;
  33  /******/
  34  /******/     // expose the module cache
  35  /******/     __webpack_require__.c = installedModules;
  36  /******/
  37  /******/     // define getter function for harmony exports
  38  /******/     __webpack_require__.d = function(exports, name, getter) {
  39  /******/         if(!__webpack_require__.o(exports, name)) {
  40  /******/             Object.defineProperty(exports, name, { enumerable: true, get: getter });
  41  /******/         }
  42  /******/     };
  43  /******/
  44  /******/     // define __esModule on exports
  45  /******/     __webpack_require__.r = function(exports) {
  46  /******/         if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  47  /******/             Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  48  /******/         }
  49  /******/         Object.defineProperty(exports, '__esModule', { value: true });
  50  /******/     };
  51  /******/
  52  /******/     // create a fake namespace object
  53  /******/     // mode & 1: value is a module id, require it
  54  /******/     // mode & 2: merge all properties of value into the ns
  55  /******/     // mode & 4: return value when already ns object
  56  /******/     // mode & 8|1: behave like require
  57  /******/     __webpack_require__.t = function(value, mode) {
  58  /******/         if(mode & 1) value = __webpack_require__(value);
  59  /******/         if(mode & 8) return value;
  60  /******/         if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  61  /******/         var ns = Object.create(null);
  62  /******/         __webpack_require__.r(ns);
  63  /******/         Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  64  /******/         if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  65  /******/         return ns;
  66  /******/     };
  67  /******/
  68  /******/     // getDefaultExport function for compatibility with non-harmony modules
  69  /******/     __webpack_require__.n = function(module) {
  70  /******/         var getter = module && module.__esModule ?
  71  /******/ 			function getDefault() { return module['default']; } :
  72  /******/ 			function getModuleExports() { return module; };
  73  /******/         __webpack_require__.d(getter, 'a', getter);
  74  /******/         return getter;
  75  /******/     };
  76  /******/
  77  /******/     // Object.prototype.hasOwnProperty.call
  78  /******/     __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  79  /******/
  80  /******/     // __webpack_public_path__
  81  /******/     __webpack_require__.p = "";
  82  /******/
  83  /******/
  84  /******/     // Load entry module and return exports
  85  /******/     return __webpack_require__(__webpack_require__.s = "./node_modules/@wordpress/token-list/build-module/index.js");
  86  /******/ })
  87  /************************************************************************/
  88  /******/ ({
  89  
  90  /***/ "./node_modules/@babel/runtime/helpers/esm/classCallCheck.js":
  91  /*!*******************************************************************!*\
  92    !*** ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js ***!
  93    \*******************************************************************/
  94  /*! exports provided: default */
  95  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96  
  97  "use strict";
  98  __webpack_require__.r(__webpack_exports__);
  99  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return _classCallCheck; });
 100  function _classCallCheck(instance, Constructor) {
 101    if (!(instance instanceof Constructor)) {
 102      throw new TypeError("Cannot call a class as a function");
 103    }
 104  }
 105  
 106  /***/ }),
 107  
 108  /***/ "./node_modules/@babel/runtime/helpers/esm/createClass.js":
 109  /*!****************************************************************!*\
 110    !*** ./node_modules/@babel/runtime/helpers/esm/createClass.js ***!
 111    \****************************************************************/
 112  /*! exports provided: default */
 113  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 114  
 115  "use strict";
 116  __webpack_require__.r(__webpack_exports__);
 117  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return _createClass; });
 118  function _defineProperties(target, props) {
 119    for (var i = 0; i < props.length; i++) {
 120      var descriptor = props[i];
 121      descriptor.enumerable = descriptor.enumerable || false;
 122      descriptor.configurable = true;
 123      if ("value" in descriptor) descriptor.writable = true;
 124      Object.defineProperty(target, descriptor.key, descriptor);
 125    }
 126  }
 127  
 128  function _createClass(Constructor, protoProps, staticProps) {
 129    if (protoProps) _defineProperties(Constructor.prototype, protoProps);
 130    if (staticProps) _defineProperties(Constructor, staticProps);
 131    return Constructor;
 132  }
 133  
 134  /***/ }),
 135  
 136  /***/ "./node_modules/@wordpress/token-list/build-module/index.js":
 137  /*!******************************************************************!*\
 138    !*** ./node_modules/@wordpress/token-list/build-module/index.js ***!
 139    \******************************************************************/
 140  /*! exports provided: default */
 141  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 142  
 143  "use strict";
 144  __webpack_require__.r(__webpack_exports__);
 145  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return TokenList; });
 146  /* harmony import */ var _babel_runtime_helpers_esm_classCallCheck__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/classCallCheck */ "./node_modules/@babel/runtime/helpers/esm/classCallCheck.js");
 147  /* harmony import */ var _babel_runtime_helpers_esm_createClass__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @babel/runtime/helpers/esm/createClass */ "./node_modules/@babel/runtime/helpers/esm/createClass.js");
 148  /* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! lodash */ "lodash");
 149  /* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_2__);
 150  
 151  
 152  
 153  /**
 154   * External dependencies
 155   */
 156  
 157  /**
 158   * A set of tokens.
 159   *
 160   * @link https://dom.spec.whatwg.org/#domtokenlist
 161   */
 162  
 163  var TokenList =
 164  /*#__PURE__*/
 165  function () {
 166    /**
 167     * Constructs a new instance of TokenList.
 168     *
 169     * @param {string} initialValue Initial value to assign.
 170     */
 171    function TokenList() {
 172      var _this = this;
 173  
 174      var initialValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
 175  
 176      Object(_babel_runtime_helpers_esm_classCallCheck__WEBPACK_IMPORTED_MODULE_0__["default"])(this, TokenList);
 177  
 178      this.value = initialValue;
 179      ['entries', 'forEach', 'keys', 'values'].forEach(function (fn) {
 180        _this[fn] = function () {
 181          var _this$_valueAsArray;
 182  
 183          return (_this$_valueAsArray = this._valueAsArray)[fn].apply(_this$_valueAsArray, arguments);
 184        }.bind(_this);
 185      });
 186    }
 187    /**
 188     * Returns the associated set as string.
 189     *
 190     * @link https://dom.spec.whatwg.org/#dom-domtokenlist-value
 191     *
 192     * @return {string} Token set as string.
 193     */
 194  
 195  
 196    Object(_babel_runtime_helpers_esm_createClass__WEBPACK_IMPORTED_MODULE_1__["default"])(TokenList, [{
 197      key: "item",
 198  
 199      /**
 200       * Returns the token with index `index`.
 201       *
 202       * @link https://dom.spec.whatwg.org/#dom-domtokenlist-item
 203       *
 204       * @param {number} index Index at which to return token.
 205       *
 206       * @return {?string} Token at index.
 207       */
 208      value: function item(index) {
 209        return this._valueAsArray[index];
 210      }
 211      /**
 212       * Returns true if `token` is present, and false otherwise.
 213       *
 214       * @link https://dom.spec.whatwg.org/#dom-domtokenlist-contains
 215       *
 216       * @param {string} item Token to test.
 217       *
 218       * @return {boolean} Whether token is present.
 219       */
 220  
 221    }, {
 222      key: "contains",
 223      value: function contains(item) {
 224        return this._valueAsArray.indexOf(item) !== -1;
 225      }
 226      /**
 227       * Adds all arguments passed, except those already present.
 228       *
 229       * @link https://dom.spec.whatwg.org/#dom-domtokenlist-add
 230       *
 231       * @param {...string} items Items to add.
 232       */
 233  
 234    }, {
 235      key: "add",
 236      value: function add() {
 237        for (var _len = arguments.length, items = new Array(_len), _key = 0; _key < _len; _key++) {
 238          items[_key] = arguments[_key];
 239        }
 240  
 241        this.value += ' ' + items.join(' ');
 242      }
 243      /**
 244       * Removes arguments passed, if they are present.
 245       *
 246       * @link https://dom.spec.whatwg.org/#dom-domtokenlist-remove
 247       *
 248       * @param {...string} items Items to remove.
 249       */
 250  
 251    }, {
 252      key: "remove",
 253      value: function remove() {
 254        for (var _len2 = arguments.length, items = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
 255          items[_key2] = arguments[_key2];
 256        }
 257  
 258        this.value = lodash__WEBPACK_IMPORTED_MODULE_2__["without"].apply(void 0, [this._valueAsArray].concat(items)).join(' ');
 259      }
 260      /**
 261       * If `force` is not given, "toggles" `token`, removing it if it’s present
 262       * and adding it if it’s not present. If `force` is true, adds token (same
 263       * as add()). If force is false, removes token (same as remove()). Returns
 264       * true if `token` is now present, and false otherwise.
 265       *
 266       * @link https://dom.spec.whatwg.org/#dom-domtokenlist-toggle
 267       *
 268       * @param {string}   token Token to toggle.
 269       * @param {?boolean} force Presence to force.
 270       *
 271       * @return {boolean} Whether token is present after toggle.
 272       */
 273  
 274    }, {
 275      key: "toggle",
 276      value: function toggle(token, force) {
 277        if (undefined === force) {
 278          force = !this.contains(token);
 279        }
 280  
 281        if (force) {
 282          this.add(token);
 283        } else {
 284          this.remove(token);
 285        }
 286  
 287        return force;
 288      }
 289      /**
 290       * Replaces `token` with `newToken`. Returns true if `token` was replaced
 291       * with `newToken`, and false otherwise.
 292       *
 293       * @link https://dom.spec.whatwg.org/#dom-domtokenlist-replace
 294       *
 295       * @param {string} token    Token to replace with `newToken`.
 296       * @param {string} newToken Token to use in place of `token`.
 297       *
 298       * @return {boolean} Whether replacement occurred.
 299       */
 300  
 301    }, {
 302      key: "replace",
 303      value: function replace(token, newToken) {
 304        if (!this.contains(token)) {
 305          return false;
 306        }
 307  
 308        this.remove(token);
 309        this.add(newToken);
 310        return true;
 311      }
 312      /**
 313       * Returns true if `token` is in the associated attribute’s supported
 314       * tokens. Returns false otherwise.
 315       *
 316       * Always returns `true` in this implementation.
 317       *
 318       * @link https://dom.spec.whatwg.org/#dom-domtokenlist-supports
 319       *
 320       * @return {boolean} Whether token is supported.
 321       */
 322  
 323    }, {
 324      key: "supports",
 325      value: function supports() {
 326        return true;
 327      }
 328    }, {
 329      key: "value",
 330      get: function get() {
 331        return this._currentValue;
 332      }
 333      /**
 334       * Replaces the associated set with a new string value.
 335       *
 336       * @link https://dom.spec.whatwg.org/#dom-domtokenlist-value
 337       *
 338       * @param {string} value New token set as string.
 339       */
 340      ,
 341      set: function set(value) {
 342        value = String(value);
 343        this._valueAsArray = Object(lodash__WEBPACK_IMPORTED_MODULE_2__["uniq"])(Object(lodash__WEBPACK_IMPORTED_MODULE_2__["compact"])(value.split(/\s+/g)));
 344        this._currentValue = this._valueAsArray.join(' ');
 345      }
 346      /**
 347       * Returns the number of tokens.
 348       *
 349       * @link https://dom.spec.whatwg.org/#dom-domtokenlist-length
 350       *
 351       * @return {number} Number of tokens.
 352       */
 353  
 354    }, {
 355      key: "length",
 356      get: function get() {
 357        return this._valueAsArray.length;
 358      }
 359    }]);
 360  
 361    return TokenList;
 362  }();
 363  
 364  
 365  
 366  
 367  /***/ }),
 368  
 369  /***/ "lodash":
 370  /*!*************************!*\
 371    !*** external "lodash" ***!
 372    \*************************/
 373  /*! no static exports found */
 374  /***/ (function(module, exports) {
 375  
 376  (function() { module.exports = this["lodash"]; }());
 377  
 378  /***/ })
 379  
 380  /******/ });
 381  //# sourceMappingURL=token-list.js.map


Generated: Mon Jan 7 01:00:05 2019 Cross-referenced by PHPXref 0.7.1