vendor/assets/javascripts/clipboard.js in clipboard-rails-1.6.1 vs vendor/assets/javascripts/clipboard.js in clipboard-rails-1.7.1

- old
+ new

@@ -1,7 +1,7 @@ /*! - * clipboard.js v1.6.1 + * clipboard.js v1.7.1 * https://zenorocha.github.io/clipboard.js * * Licensed MIT © Zeno Rocha */ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Clipboard = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ @@ -27,11 +27,14 @@ * @param {String} selector * @return {Function} */ function closest (element, selector) { while (element && element.nodeType !== DOCUMENT_NODE_TYPE) { - if (element.matches(selector)) return element; + if (typeof element.matches === 'function' && + element.matches(selector)) { + return element; + } element = element.parentNode; } } module.exports = closest; @@ -418,10 +421,11 @@ key: 'resolveOptions', value: function resolveOptions() { var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; this.action = options.action; + this.container = options.container; this.emitter = options.emitter; this.target = options.target; this.text = options.text; this.trigger = options.trigger; @@ -446,11 +450,11 @@ this.removeFake(); this.fakeHandlerCallback = function () { return _this.removeFake(); }; - this.fakeHandler = document.body.addEventListener('click', this.fakeHandlerCallback) || true; + this.fakeHandler = this.container.addEventListener('click', this.fakeHandlerCallback) || true; this.fakeElem = document.createElement('textarea'); // Prevent zooming on iOS this.fakeElem.style.fontSize = '12pt'; // Reset box model @@ -465,26 +469,26 @@ this.fakeElem.style.top = yPosition + 'px'; this.fakeElem.setAttribute('readonly', ''); this.fakeElem.value = this.text; - document.body.appendChild(this.fakeElem); + this.container.appendChild(this.fakeElem); this.selectedText = (0, _select2.default)(this.fakeElem); this.copyText(); } }, { key: 'removeFake', value: function removeFake() { if (this.fakeHandler) { - document.body.removeEventListener('click', this.fakeHandlerCallback); + this.container.removeEventListener('click', this.fakeHandlerCallback); this.fakeHandler = null; this.fakeHandlerCallback = null; } if (this.fakeElem) { - document.body.removeChild(this.fakeElem); + this.container.removeChild(this.fakeElem); this.fakeElem = null; } } }, { key: 'selectTarget', @@ -516,12 +520,12 @@ }); } }, { key: 'clearSelection', value: function clearSelection() { - if (this.target) { - this.target.blur(); + if (this.trigger) { + this.trigger.focus(); } window.getSelection().removeAllRanges(); } }, { @@ -599,10 +603,16 @@ return obj && obj.__esModule ? obj : { default: obj }; } + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { + return typeof obj; + } : function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -679,10 +689,11 @@ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; this.action = typeof options.action === 'function' ? options.action : this.defaultAction; this.target = typeof options.target === 'function' ? options.target : this.defaultTarget; this.text = typeof options.text === 'function' ? options.text : this.defaultText; + this.container = _typeof(options.container) === 'object' ? options.container : document.body; } }, { key: 'listenClick', value: function listenClick(trigger) { var _this2 = this; @@ -702,9 +713,10 @@ this.clipboardAction = new _clipboardAction2.default({ action: this.action(trigger), target: this.target(trigger), text: this.text(trigger), + container: this.container, trigger: trigger, emitter: this }); } }, { \ No newline at end of file