[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/js/ -> clipboard.js (source)

   1  /*!
   2   * clipboard.js v2.0.11
   3   * https://clipboardjs.com/
   4   *
   5   * Licensed MIT © Zeno Rocha
   6   */
   7  (function webpackUniversalModuleDefinition(root, factory) {
   8      if(typeof exports === 'object' && typeof module === 'object')
   9          module.exports = factory();
  10      else if(typeof define === 'function' && define.amd)
  11          define([], factory);
  12      else if(typeof exports === 'object')
  13          exports["ClipboardJS"] = factory();
  14      else
  15          root["ClipboardJS"] = factory();
  16  })(this, function() {
  17  return /******/ (function() { // webpackBootstrap
  18  /******/     var __webpack_modules__ = ({
  19  
  20  /***/ 686:
  21  /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  22  
  23  "use strict";
  24  
  25  // EXPORTS
  26  __webpack_require__.d(__webpack_exports__, {
  27    "default": function() { return /* binding */ clipboard; }
  28  });
  29  
  30  // EXTERNAL MODULE: ./node_modules/tiny-emitter/index.js
  31  var tiny_emitter = __webpack_require__(279);
  32  var tiny_emitter_default = /*#__PURE__*/__webpack_require__.n(tiny_emitter);
  33  // EXTERNAL MODULE: ./node_modules/good-listener/src/listen.js
  34  var listen = __webpack_require__(370);
  35  var listen_default = /*#__PURE__*/__webpack_require__.n(listen);
  36  // EXTERNAL MODULE: ./node_modules/select/src/select.js
  37  var src_select = __webpack_require__(817);
  38  var select_default = /*#__PURE__*/__webpack_require__.n(src_select);
  39  ;// CONCATENATED MODULE: ./src/common/command.js
  40  /**
  41   * Executes a given operation type.
  42   * @param {String} type
  43   * @return {Boolean}
  44   */
  45  function command(type) {
  46    try {
  47      return document.execCommand(type);
  48    } catch (err) {
  49      return false;
  50    }
  51  }
  52  ;// CONCATENATED MODULE: ./src/actions/cut.js
  53  
  54  
  55  /**
  56   * Cut action wrapper.
  57   * @param {String|HTMLElement} target
  58   * @return {String}
  59   */
  60  
  61  var ClipboardActionCut = function ClipboardActionCut(target) {
  62    var selectedText = select_default()(target);
  63    command('cut');
  64    return selectedText;
  65  };
  66  
  67  /* harmony default export */ var actions_cut = (ClipboardActionCut);
  68  ;// CONCATENATED MODULE: ./src/common/create-fake-element.js
  69  /**
  70   * Creates a fake textarea element with a value.
  71   * @param {String} value
  72   * @return {HTMLElement}
  73   */
  74  function createFakeElement(value) {
  75    var isRTL = document.documentElement.getAttribute('dir') === 'rtl';
  76    var fakeElement = document.createElement('textarea'); // Prevent zooming on iOS
  77  
  78    fakeElement.style.fontSize = '12pt'; // Reset box model
  79  
  80    fakeElement.style.border = '0';
  81    fakeElement.style.padding = '0';
  82    fakeElement.style.margin = '0'; // Move element out of screen horizontally
  83  
  84    fakeElement.style.position = 'absolute';
  85    fakeElement.style[isRTL ? 'right' : 'left'] = '-9999px'; // Move element to the same position vertically
  86  
  87    var yPosition = window.pageYOffset || document.documentElement.scrollTop;
  88    fakeElement.style.top = "".concat(yPosition, "px");
  89    fakeElement.setAttribute('readonly', '');
  90    fakeElement.value = value;
  91    return fakeElement;
  92  }
  93  ;// CONCATENATED MODULE: ./src/actions/copy.js
  94  
  95  
  96  
  97  /**
  98   * Create fake copy action wrapper using a fake element.
  99   * @param {String} target
 100   * @param {Object} options
 101   * @return {String}
 102   */
 103  
 104  var fakeCopyAction = function fakeCopyAction(value, options) {
 105    var fakeElement = createFakeElement(value);
 106    options.container.appendChild(fakeElement);
 107    var selectedText = select_default()(fakeElement);
 108    command('copy');
 109    fakeElement.remove();
 110    return selectedText;
 111  };
 112  /**
 113   * Copy action wrapper.
 114   * @param {String|HTMLElement} target
 115   * @param {Object} options
 116   * @return {String}
 117   */
 118  
 119  
 120  var ClipboardActionCopy = function ClipboardActionCopy(target) {
 121    var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
 122      container: document.body
 123    };
 124    var selectedText = '';
 125  
 126    if (typeof target === 'string') {
 127      selectedText = fakeCopyAction(target, options);
 128    } else if (target instanceof HTMLInputElement && !['text', 'search', 'url', 'tel', 'password'].includes(target === null || target === void 0 ? void 0 : target.type)) {
 129      // If input type doesn't support `setSelectionRange`. Simulate it. https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
 130      selectedText = fakeCopyAction(target.value, options);
 131    } else {
 132      selectedText = select_default()(target);
 133      command('copy');
 134    }
 135  
 136    return selectedText;
 137  };
 138  
 139  /* harmony default export */ var actions_copy = (ClipboardActionCopy);
 140  ;// CONCATENATED MODULE: ./src/actions/default.js
 141  function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
 142  
 143  
 144  
 145  /**
 146   * Inner function which performs selection from either `text` or `target`
 147   * properties and then executes copy or cut operations.
 148   * @param {Object} options
 149   */
 150  
 151  var ClipboardActionDefault = function ClipboardActionDefault() {
 152    var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
 153    // Defines base properties passed from constructor.
 154    var _options$action = options.action,
 155        action = _options$action === void 0 ? 'copy' : _options$action,
 156        container = options.container,
 157        target = options.target,
 158        text = options.text; // Sets the `action` to be performed which can be either 'copy' or 'cut'.
 159  
 160    if (action !== 'copy' && action !== 'cut') {
 161      throw new Error('Invalid "action" value, use either "copy" or "cut"');
 162    } // Sets the `target` property using an element that will be have its content copied.
 163  
 164  
 165    if (target !== undefined) {
 166      if (target && _typeof(target) === 'object' && target.nodeType === 1) {
 167        if (action === 'copy' && target.hasAttribute('disabled')) {
 168          throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');
 169        }
 170  
 171        if (action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) {
 172          throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');
 173        }
 174      } else {
 175        throw new Error('Invalid "target" value, use a valid Element');
 176      }
 177    } // Define selection strategy based on `text` property.
 178  
 179  
 180    if (text) {
 181      return actions_copy(text, {
 182        container: container
 183      });
 184    } // Defines which selection strategy based on `target` property.
 185  
 186  
 187    if (target) {
 188      return action === 'cut' ? actions_cut(target) : actions_copy(target, {
 189        container: container
 190      });
 191    }
 192  };
 193  
 194  /* harmony default export */ var actions_default = (ClipboardActionDefault);
 195  ;// CONCATENATED MODULE: ./src/clipboard.js
 196  function clipboard_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { clipboard_typeof = function _typeof(obj) { return typeof obj; }; } else { clipboard_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return clipboard_typeof(obj); }
 197  
 198  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
 199  
 200  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); } }
 201  
 202  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
 203  
 204  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
 205  
 206  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
 207  
 208  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
 209  
 210  function _possibleConstructorReturn(self, call) { if (call && (clipboard_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
 211  
 212  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
 213  
 214  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
 215  
 216  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
 217  
 218  
 219  
 220  
 221  
 222  
 223  /**
 224   * Helper function to retrieve attribute value.
 225   * @param {String} suffix
 226   * @param {Element} element
 227   */
 228  
 229  function getAttributeValue(suffix, element) {
 230    var attribute = "data-clipboard-".concat(suffix);
 231  
 232    if (!element.hasAttribute(attribute)) {
 233      return;
 234    }
 235  
 236    return element.getAttribute(attribute);
 237  }
 238  /**
 239   * Base class which takes one or more elements, adds event listeners to them,
 240   * and instantiates a new `ClipboardAction` on each click.
 241   */
 242  
 243  
 244  var Clipboard = /*#__PURE__*/function (_Emitter) {
 245    _inherits(Clipboard, _Emitter);
 246  
 247    var _super = _createSuper(Clipboard);
 248  
 249    /**
 250     * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
 251     * @param {Object} options
 252     */
 253    function Clipboard(trigger, options) {
 254      var _this;
 255  
 256      _classCallCheck(this, Clipboard);
 257  
 258      _this = _super.call(this);
 259  
 260      _this.resolveOptions(options);
 261  
 262      _this.listenClick(trigger);
 263  
 264      return _this;
 265    }
 266    /**
 267     * Defines if attributes would be resolved using internal setter functions
 268     * or custom functions that were passed in the constructor.
 269     * @param {Object} options
 270     */
 271  
 272  
 273    _createClass(Clipboard, [{
 274      key: "resolveOptions",
 275      value: function resolveOptions() {
 276        var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
 277        this.action = typeof options.action === 'function' ? options.action : this.defaultAction;
 278        this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;
 279        this.text = typeof options.text === 'function' ? options.text : this.defaultText;
 280        this.container = clipboard_typeof(options.container) === 'object' ? options.container : document.body;
 281      }
 282      /**
 283       * Adds a click event listener to the passed trigger.
 284       * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
 285       */
 286  
 287    }, {
 288      key: "listenClick",
 289      value: function listenClick(trigger) {
 290        var _this2 = this;
 291  
 292        this.listener = listen_default()(trigger, 'click', function (e) {
 293          return _this2.onClick(e);
 294        });
 295      }
 296      /**
 297       * Defines a new `ClipboardAction` on each click event.
 298       * @param {Event} e
 299       */
 300  
 301    }, {
 302      key: "onClick",
 303      value: function onClick(e) {
 304        var trigger = e.delegateTarget || e.currentTarget;
 305        var action = this.action(trigger) || 'copy';
 306        var text = actions_default({
 307          action: action,
 308          container: this.container,
 309          target: this.target(trigger),
 310          text: this.text(trigger)
 311        }); // Fires an event based on the copy operation result.
 312  
 313        this.emit(text ? 'success' : 'error', {
 314          action: action,
 315          text: text,
 316          trigger: trigger,
 317          clearSelection: function clearSelection() {
 318            if (trigger) {
 319              trigger.focus();
 320            }
 321  
 322            window.getSelection().removeAllRanges();
 323          }
 324        });
 325      }
 326      /**
 327       * Default `action` lookup function.
 328       * @param {Element} trigger
 329       */
 330  
 331    }, {
 332      key: "defaultAction",
 333      value: function defaultAction(trigger) {
 334        return getAttributeValue('action', trigger);
 335      }
 336      /**
 337       * Default `target` lookup function.
 338       * @param {Element} trigger
 339       */
 340  
 341    }, {
 342      key: "defaultTarget",
 343      value: function defaultTarget(trigger) {
 344        var selector = getAttributeValue('target', trigger);
 345  
 346        if (selector) {
 347          return document.querySelector(selector);
 348        }
 349      }
 350      /**
 351       * Allow fire programmatically a copy action
 352       * @param {String|HTMLElement} target
 353       * @param {Object} options
 354       * @returns Text copied.
 355       */
 356  
 357    }, {
 358      key: "defaultText",
 359  
 360      /**
 361       * Default `text` lookup function.
 362       * @param {Element} trigger
 363       */
 364      value: function defaultText(trigger) {
 365        return getAttributeValue('text', trigger);
 366      }
 367      /**
 368       * Destroy lifecycle.
 369       */
 370  
 371    }, {
 372      key: "destroy",
 373      value: function destroy() {
 374        this.listener.destroy();
 375      }
 376    }], [{
 377      key: "copy",
 378      value: function copy(target) {
 379        var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
 380          container: document.body
 381        };
 382        return actions_copy(target, options);
 383      }
 384      /**
 385       * Allow fire programmatically a cut action
 386       * @param {String|HTMLElement} target
 387       * @returns Text cutted.
 388       */
 389  
 390    }, {
 391      key: "cut",
 392      value: function cut(target) {
 393        return actions_cut(target);
 394      }
 395      /**
 396       * Returns the support of the given action, or all actions if no action is
 397       * given.
 398       * @param {String} [action]
 399       */
 400  
 401    }, {
 402      key: "isSupported",
 403      value: function isSupported() {
 404        var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut'];
 405        var actions = typeof action === 'string' ? [action] : action;
 406        var support = !!document.queryCommandSupported;
 407        actions.forEach(function (action) {
 408          support = support && !!document.queryCommandSupported(action);
 409        });
 410        return support;
 411      }
 412    }]);
 413  
 414    return Clipboard;
 415  }((tiny_emitter_default()));
 416  
 417  /* harmony default export */ var clipboard = (Clipboard);
 418  
 419  /***/ }),
 420  
 421  /***/ 828:
 422  /***/ (function(module) {
 423  
 424  var DOCUMENT_NODE_TYPE = 9;
 425  
 426  /**
 427   * A polyfill for Element.matches()
 428   */
 429  if (typeof Element !== 'undefined' && !Element.prototype.matches) {
 430      var proto = Element.prototype;
 431  
 432      proto.matches = proto.matchesSelector ||
 433                      proto.mozMatchesSelector ||
 434                      proto.msMatchesSelector ||
 435                      proto.oMatchesSelector ||
 436                      proto.webkitMatchesSelector;
 437  }
 438  
 439  /**
 440   * Finds the closest parent that matches a selector.
 441   *
 442   * @param {Element} element
 443   * @param {String} selector
 444   * @return {Function}
 445   */
 446  function closest (element, selector) {
 447      while (element && element.nodeType !== DOCUMENT_NODE_TYPE) {
 448          if (typeof element.matches === 'function' &&
 449              element.matches(selector)) {
 450            return element;
 451          }
 452          element = element.parentNode;
 453      }
 454  }
 455  
 456  module.exports = closest;
 457  
 458  
 459  /***/ }),
 460  
 461  /***/ 438:
 462  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
 463  
 464  var closest = __webpack_require__(828);
 465  
 466  /**
 467   * Delegates event to a selector.
 468   *
 469   * @param {Element} element
 470   * @param {String} selector
 471   * @param {String} type
 472   * @param {Function} callback
 473   * @param {Boolean} useCapture
 474   * @return {Object}
 475   */
 476  function _delegate(element, selector, type, callback, useCapture) {
 477      var listenerFn = listener.apply(this, arguments);
 478  
 479      element.addEventListener(type, listenerFn, useCapture);
 480  
 481      return {
 482          destroy: function() {
 483              element.removeEventListener(type, listenerFn, useCapture);
 484          }
 485      }
 486  }
 487  
 488  /**
 489   * Delegates event to a selector.
 490   *
 491   * @param {Element|String|Array} [elements]
 492   * @param {String} selector
 493   * @param {String} type
 494   * @param {Function} callback
 495   * @param {Boolean} useCapture
 496   * @return {Object}
 497   */
 498  function delegate(elements, selector, type, callback, useCapture) {
 499      // Handle the regular Element usage
 500      if (typeof elements.addEventListener === 'function') {
 501          return _delegate.apply(null, arguments);
 502      }
 503  
 504      // Handle Element-less usage, it defaults to global delegation
 505      if (typeof type === 'function') {
 506          // Use `document` as the first parameter, then apply arguments
 507          // This is a short way to .unshift `arguments` without running into deoptimizations
 508          return _delegate.bind(null, document).apply(null, arguments);
 509      }
 510  
 511      // Handle Selector-based usage
 512      if (typeof elements === 'string') {
 513          elements = document.querySelectorAll(elements);
 514      }
 515  
 516      // Handle Array-like based usage
 517      return Array.prototype.map.call(elements, function (element) {
 518          return _delegate(element, selector, type, callback, useCapture);
 519      });
 520  }
 521  
 522  /**
 523   * Finds closest match and invokes callback.
 524   *
 525   * @param {Element} element
 526   * @param {String} selector
 527   * @param {String} type
 528   * @param {Function} callback
 529   * @return {Function}
 530   */
 531  function listener(element, selector, type, callback) {
 532      return function(e) {
 533          e.delegateTarget = closest(e.target, selector);
 534  
 535          if (e.delegateTarget) {
 536              callback.call(element, e);
 537          }
 538      }
 539  }
 540  
 541  module.exports = delegate;
 542  
 543  
 544  /***/ }),
 545  
 546  /***/ 879:
 547  /***/ (function(__unused_webpack_module, exports) {
 548  
 549  /**
 550   * Check if argument is a HTML element.
 551   *
 552   * @param {Object} value
 553   * @return {Boolean}
 554   */
 555  exports.node = function(value) {
 556      return value !== undefined
 557          && value instanceof HTMLElement
 558          && value.nodeType === 1;
 559  };
 560  
 561  /**
 562   * Check if argument is a list of HTML elements.
 563   *
 564   * @param {Object} value
 565   * @return {Boolean}
 566   */
 567  exports.nodeList = function(value) {
 568      var type = Object.prototype.toString.call(value);
 569  
 570      return value !== undefined
 571          && (type === '[object NodeList]' || type === '[object HTMLCollection]')
 572          && ('length' in value)
 573          && (value.length === 0 || exports.node(value[0]));
 574  };
 575  
 576  /**
 577   * Check if argument is a string.
 578   *
 579   * @param {Object} value
 580   * @return {Boolean}
 581   */
 582  exports.string = function(value) {
 583      return typeof value === 'string'
 584          || value instanceof String;
 585  };
 586  
 587  /**
 588   * Check if argument is a function.
 589   *
 590   * @param {Object} value
 591   * @return {Boolean}
 592   */
 593  exports.fn = function(value) {
 594      var type = Object.prototype.toString.call(value);
 595  
 596      return type === '[object Function]';
 597  };
 598  
 599  
 600  /***/ }),
 601  
 602  /***/ 370:
 603  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
 604  
 605  var is = __webpack_require__(879);
 606  var delegate = __webpack_require__(438);
 607  
 608  /**
 609   * Validates all params and calls the right
 610   * listener function based on its target type.
 611   *
 612   * @param {String|HTMLElement|HTMLCollection|NodeList} target
 613   * @param {String} type
 614   * @param {Function} callback
 615   * @return {Object}
 616   */
 617  function listen(target, type, callback) {
 618      if (!target && !type && !callback) {
 619          throw new Error('Missing required arguments');
 620      }
 621  
 622      if (!is.string(type)) {
 623          throw new TypeError('Second argument must be a String');
 624      }
 625  
 626      if (!is.fn(callback)) {
 627          throw new TypeError('Third argument must be a Function');
 628      }
 629  
 630      if (is.node(target)) {
 631          return listenNode(target, type, callback);
 632      }
 633      else if (is.nodeList(target)) {
 634          return listenNodeList(target, type, callback);
 635      }
 636      else if (is.string(target)) {
 637          return listenSelector(target, type, callback);
 638      }
 639      else {
 640          throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList');
 641      }
 642  }
 643  
 644  /**
 645   * Adds an event listener to a HTML element
 646   * and returns a remove listener function.
 647   *
 648   * @param {HTMLElement} node
 649   * @param {String} type
 650   * @param {Function} callback
 651   * @return {Object}
 652   */
 653  function listenNode(node, type, callback) {
 654      node.addEventListener(type, callback);
 655  
 656      return {
 657          destroy: function() {
 658              node.removeEventListener(type, callback);
 659          }
 660      }
 661  }
 662  
 663  /**
 664   * Add an event listener to a list of HTML elements
 665   * and returns a remove listener function.
 666   *
 667   * @param {NodeList|HTMLCollection} nodeList
 668   * @param {String} type
 669   * @param {Function} callback
 670   * @return {Object}
 671   */
 672  function listenNodeList(nodeList, type, callback) {
 673      Array.prototype.forEach.call(nodeList, function(node) {
 674          node.addEventListener(type, callback);
 675      });
 676  
 677      return {
 678          destroy: function() {
 679              Array.prototype.forEach.call(nodeList, function(node) {
 680                  node.removeEventListener(type, callback);
 681              });
 682          }
 683      }
 684  }
 685  
 686  /**
 687   * Add an event listener to a selector
 688   * and returns a remove listener function.
 689   *
 690   * @param {String} selector
 691   * @param {String} type
 692   * @param {Function} callback
 693   * @return {Object}
 694   */
 695  function listenSelector(selector, type, callback) {
 696      return delegate(document.body, selector, type, callback);
 697  }
 698  
 699  module.exports = listen;
 700  
 701  
 702  /***/ }),
 703  
 704  /***/ 817:
 705  /***/ (function(module) {
 706  
 707  function select(element) {
 708      var selectedText;
 709  
 710      if (element.nodeName === 'SELECT') {
 711          element.focus();
 712  
 713          selectedText = element.value;
 714      }
 715      else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
 716          var isReadOnly = element.hasAttribute('readonly');
 717  
 718          if (!isReadOnly) {
 719              element.setAttribute('readonly', '');
 720          }
 721  
 722          element.select();
 723          element.setSelectionRange(0, element.value.length);
 724  
 725          if (!isReadOnly) {
 726              element.removeAttribute('readonly');
 727          }
 728  
 729          selectedText = element.value;
 730      }
 731      else {
 732          if (element.hasAttribute('contenteditable')) {
 733              element.focus();
 734          }
 735  
 736          var selection = window.getSelection();
 737          var range = document.createRange();
 738  
 739          range.selectNodeContents(element);
 740          selection.removeAllRanges();
 741          selection.addRange(range);
 742  
 743          selectedText = selection.toString();
 744      }
 745  
 746      return selectedText;
 747  }
 748  
 749  module.exports = select;
 750  
 751  
 752  /***/ }),
 753  
 754  /***/ 279:
 755  /***/ (function(module) {
 756  
 757  function E () {
 758    // Keep this empty so it's easier to inherit from
 759    // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
 760  }
 761  
 762  E.prototype = {
 763    on: function (name, callback, ctx) {
 764      var e = this.e || (this.e = {});
 765  
 766      (e[name] || (e[name] = [])).push({
 767        fn: callback,
 768        ctx: ctx
 769      });
 770  
 771      return this;
 772    },
 773  
 774    once: function (name, callback, ctx) {
 775      var self = this;
 776      function listener () {
 777        self.off(name, listener);
 778        callback.apply(ctx, arguments);
 779      };
 780  
 781      listener._ = callback
 782      return this.on(name, listener, ctx);
 783    },
 784  
 785    emit: function (name) {
 786      var data = [].slice.call(arguments, 1);
 787      var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
 788      var i = 0;
 789      var len = evtArr.length;
 790  
 791      for (i; i < len; i++) {
 792        evtArr[i].fn.apply(evtArr[i].ctx, data);
 793      }
 794  
 795      return this;
 796    },
 797  
 798    off: function (name, callback) {
 799      var e = this.e || (this.e = {});
 800      var evts = e[name];
 801      var liveEvents = [];
 802  
 803      if (evts && callback) {
 804        for (var i = 0, len = evts.length; i < len; i++) {
 805          if (evts[i].fn !== callback && evts[i].fn._ !== callback)
 806            liveEvents.push(evts[i]);
 807        }
 808      }
 809  
 810      // Remove event from queue to prevent memory leak
 811      // Suggested by https://github.com/lazd
 812      // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910
 813  
 814      (liveEvents.length)
 815        ? e[name] = liveEvents
 816        : delete e[name];
 817  
 818      return this;
 819    }
 820  };
 821  
 822  module.exports = E;
 823  module.exports.TinyEmitter = E;
 824  
 825  
 826  /***/ })
 827  
 828  /******/     });
 829  /************************************************************************/
 830  /******/     // The module cache
 831  /******/     var __webpack_module_cache__ = {};
 832  /******/     
 833  /******/     // The require function
 834  /******/ 	function __webpack_require__(moduleId) {
 835  /******/         // Check if module is in cache
 836  /******/         if(__webpack_module_cache__[moduleId]) {
 837  /******/             return __webpack_module_cache__[moduleId].exports;
 838  /******/         }
 839  /******/         // Create a new module (and put it into the cache)
 840  /******/         var module = __webpack_module_cache__[moduleId] = {
 841  /******/             // no module.id needed
 842  /******/             // no module.loaded needed
 843  /******/             exports: {}
 844  /******/         };
 845  /******/     
 846  /******/         // Execute the module function
 847  /******/         __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
 848  /******/     
 849  /******/         // Return the exports of the module
 850  /******/         return module.exports;
 851  /******/     }
 852  /******/     
 853  /************************************************************************/
 854  /******/     /* webpack/runtime/compat get default export */
 855  /******/     !function() {
 856  /******/         // getDefaultExport function for compatibility with non-harmony modules
 857  /******/         __webpack_require__.n = function(module) {
 858  /******/             var getter = module && module.__esModule ?
 859  /******/                 function() { return module['default']; } :
 860  /******/                 function() { return module; };
 861  /******/             __webpack_require__.d(getter, { a: getter });
 862  /******/             return getter;
 863  /******/         };
 864  /******/     }();
 865  /******/     
 866  /******/     /* webpack/runtime/define property getters */
 867  /******/     !function() {
 868  /******/         // define getter functions for harmony exports
 869  /******/         __webpack_require__.d = function(exports, definition) {
 870  /******/             for(var key in definition) {
 871  /******/                 if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
 872  /******/                     Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
 873  /******/                 }
 874  /******/             }
 875  /******/         };
 876  /******/     }();
 877  /******/     
 878  /******/     /* webpack/runtime/hasOwnProperty shorthand */
 879  /******/     !function() {
 880  /******/         __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
 881  /******/     }();
 882  /******/     
 883  /************************************************************************/
 884  /******/     // module exports must be returned from runtime so entry inlining is disabled
 885  /******/     // startup
 886  /******/     // Load entry module and return exports
 887  /******/     return __webpack_require__(686);
 888  /******/ })()
 889  .default;
 890  });


Generated : Sat Dec 21 08:20:01 2024 Cross-referenced by PHPXref