clipboard.min.js

!function(e){if("object"==typeofexports&&"undefined"!=typeofmodule)module.exports=e();elseif("function"==typeofdefine&&define.amd)define([],e);else{vart;t="undefined"!=typeofwindow?window:"undefined"!=typeofglobal?global:"undefined"!=typeofself?self:this,t.Clipboard=e()}}(function(){vare,t,n;returnfunctione(t,n,o){functioni(a,c){if(!n[a]){if(!t[a]){varl="function"==typeofrequire&&require;if(!c&&l)returnl(a,!0);if(r)returnr(a,!0);varu=newError("Cannot find module '"+a+"'");throwu.code="MODULE_NOT_FOUND",u}vars=n[a]={exports:{}};t[a][0].call(s.exports,function(e){varn=t[a][1][e];returni(n?n:e)},s,s.exports,e,t,n,o)}returnn[a].exports}for(varr="function"==typeofrequire&&require,a=0;a<o.length;a++)i(o[a]);returni}({1:[function(e,t,n){functiono(e,t){for(;e&&e.nodeType!==i;){if(e.matches(t))returne;e=e.parentNode}}vari=9;if("undefined"!=typeofElement&&!Element.prototype.matches){varr=Element.prototype;r.matches=r.matchesSelector||r.mozMatchesSelector||r.msMatchesSelector||r.oMatchesSelector||r.webkitMatchesSelector}t.exports=o},{}],2:[function(e,t,n){functiono(e,t,n,o,r){vara=i.apply(this,arguments);returne.addEventListener(n,a,r),{destroy:function(){e.removeEventListener(n,a,r)}}}functioni(e,t,n,o){returnfunction(n){n.delegateTarget=r(n.target,t),n.delegateTarget&&o.call(e,n)}}varr=e("./closest");t.exports=o},{"./closest":1}],3:[function(e,t,n){n.node=function(e){returnvoid0!==e&&einstanceofHTMLElement&&1===e.nodeType},n.nodeList=function(e){vart=Object.prototype.toString.call(e);returnvoid0!==e&&("[object NodeList]"===t||"[object HTMLCollection]"===t)&&"length"ine&&(0===e.length||n.node(e[0]))},n.string=function(e){return"string"==typeofe||einstanceofString},n.fn=function(e){vart=Object.prototype.toString.call(e);return"[object Function]"===t}},{}],4:[function(e,t,n){functiono(e,t,n){if(!e&&!t&&!n)thrownewError("Missing required arguments");if(!c.string(t))thrownewTypeError("Second argument must be a String");if(!c.fn(n))thrownewTypeError("Third argument must be a Function");if(c.node(e))returni(e,t,n);if(c.nodeList(e))returnr(e,t,n);if(c.string(e))returna(e,t,n);thrownewTypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}functioni(e,t,n){returne.addEventListener(t,n),{destroy:function(){e.removeEventListener(t,n)}}}functionr(e,t,n){returnArray.prototype.forEach.call(e,function(e){e.addEventListener(t,n)}),{destroy:function(){Array.prototype.forEach.call(e,function(e){e.removeEventListener(t,n)})}}}functiona(e,t,n){returnl(document.body,e,t,n)}varc=e("./is"),l=e("delegate");t.exports=o},{"./is":3,delegate:2}],5:[function(e,t,n){functiono(e){vart;if("SELECT"===e.nodeName)e.focus(),t=e.value;elseif("INPUT"===e.nodeName||"TEXTAREA"===e.nodeName){varn=e.hasAttribute("readonly");n||e.setAttribute("readonly",""),e.select(),e.setSelectionRange(0,e.value.length),n||e.removeAttribute("readonly"),t=e.value}else{e.hasAttribute("contenteditable")&&e.focus();varo=window.getSelection(),i=document.createRange();i.selectNodeContents(e),o.removeAllRanges(),o.addRange(i),t=o.toString()}returnt}t.exports=o},{}],6:[function(e,t,n){functiono(){}o.prototype={on:function(e,t,n){varo=this.e||(this.e={});return(o[e]||(o[e]=[])).push({fn:t,ctx:n}),this},once:function(e,t,n){functiono(){i.off(e,o),t.apply(n,arguments)}vari=this;returno._=t,this.on(e,o,n)},emit:function(e){vart=[].slice.call(arguments,1),n=((this.e||(this.e={}))[e]||[]).slice(),o=0,i=n.length;for(o;o<i;o++)n[o].fn.apply(n[o].ctx,t);returnthis},off:function(e,t){varn=this.e||(this.e={}),o=n[e],i=[];if(o&&t)for(varr=0,a=o.length;r<a;r++)o[r].fn!==t&&o[r].fn._!==t&&i.push(o[r]);returni.length?n[e]=i:deleten[e],this}},t.exports=o},{}],7:[function(t,n,o){!function(i,r){if("function"==typeofe&&e.amd)e(["module","select"],r);elseif("undefined"!=typeofo)r(n,t("select"));else{vara={exports:{}};r(a,i.select),i.clipboardAction=a.exports}}(this,function(e,t){"use strict";functionn(e){returne&&e.__esModule?e:{default:e}}functiono(e,t){if(!(einstanceoft))thrownewTypeError("Cannot call a class as a function")}vari=n(t),r="function"==typeofSymbol&&"symbol"==typeofSymbol.iterator?function(e){returntypeofe}:function(e){returne&&"function"==typeofSymbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeofe},a=function(){functione(e,t){for(varn=0;n<t.length;n++){varo=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"ino&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}returnfunction(t,n,o){returnn&&e(t.prototype,n),o&&e(t,o),t}}(),c=function(){functione(t){o(this,e),this.resolveOptions(t),this.initSelection()}returna(e,[{key:"resolveOptions",value:functione(){vart=arguments.length>0&&void0!==arguments[0]?arguments[0]:{};this.action=t.action,this.emitter=t.emitter,this.target=t.target,this.text=t.text,this.trigger=t.trigger,this.selectedText=""}},{key:"initSelection",value:functione(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"selectFake",value:functione(){vart=this,n="rtl"==document.documentElement.getAttribute("dir");this.removeFake(),this.fakeHandlerCallback=function(){returnt.removeFake()},this.fakeHandler=document.body.addEventListener("click",this.fakeHandlerCallback)||!0,this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[n?"right":"left"]="-9999px";varo=window.pageYOffset||document.documentElement.scrollTop;this.fakeElem.style.top=o+"px",this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,document.body.appendChild(this.fakeElem),this.selectedText=(0,i.default)(this.fakeElem),this.copyText()}},{key:"removeFake",value:functione(){this.fakeHandler&&(document.body.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(document.body.removeChild(this.fakeElem),this.fakeElem=null)}},{key:"selectTarget",value:functione(){this.selectedText=(0,i.default)(this.target),this.copyText()}},{key:"copyText",value:functione(){vart=void0;try{t=document.execCommand(this.action)}catch(e){t=!1}this.handleResult(t)}},{key:"handleResult",value:functione(t){this.emitter.emit(t?"success":"error",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})}},{key:"clearSelection",value:functione(){this.target&&this.target.blur(),window.getSelection().removeAllRanges()}},{key:"destroy",value:functione(){this.removeFake()}},{key:"action",set:functione(){vart=arguments.length>0&&void0!==arguments[0]?arguments[0]:"copy";if(this._action=t,"copy"!==this._action&&"cut"!==this._action)thrownewError('Invalid "action" value, use either "copy" or "cut"')},get:functione(){returnthis._action}},{key:"target",set:functione(t){if(void0!==t){if(!t||"object"!==("undefined"==typeoft?"undefined":r(t))||1!==t.nodeType)thrownewError('Invalid "target" value, use a valid Element');if("copy"===this.action&&t.hasAttribute("disabled"))thrownewError('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(t.hasAttribute("readonly")||t.hasAttribute("disabled")))thrownewError('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');this._target=t}},get:functione(){returnthis._target}}]),e}();e.exports=c})},{select:5}],8:[function(t,n,o){!function(i,r){if("function"==typeofe&&e.amd)e(["module","./clipboard-action","tiny-emitter","good-listener"],r);elseif("undefined"!=typeofo)r(n,t("./clipboard-action"),t("tiny-emitter"),t("good-listener"));else{vara={exports:{}};r(a,i.clipboardAction,i.tinyEmitter,i.goodListener),i.clipboard=a.exports}}(this,function(e,t,n,o){"use strict";functioni(e){returne&&e.__esModule?e:{default:e}}functionr(e,t){if(!(einstanceoft))thrownewTypeError("Cannot call a class as a function")}functiona(e,t){if(!e)thrownewReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeoft&&"function"!=typeoft?e:t}functionc(e,t){if("function"!=typeoft&&null!==t)thrownewTypeError("Super expression must either be null or a function, not "+typeoft);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}functionl(e,t){varn="data-clipboard-"+e;if(t.hasAttribute(n))returnt.getAttribute(n)}varu=i(t),s=i(n),f=i(o),d=function(){functione(e,t){for(varn=0;n<t.length;n++){varo=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"ino&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}returnfunction(t,n,o){returnn&&e(t.prototype,n),o&&e(t,o),t}}(),h=function(e){functiont(e,n){r(this,t);varo=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));returno.resolveOptions(n),o.listenClick(e),o}returnc(t,e),d(t,[{key:"resolveOptions",value:functione(){vart=arguments.length>0&&void0!==arguments[0]?arguments[0]:{};this.action="function"==typeoft.action?t.action:this.defaultAction,this.target="function"==typeoft.target?t.target:this.defaultTarget,this.text="function"==typeoft.text?t.text:this.defaultText}},{key:"listenClick",value:functione(t){varn=this;this.listener=(0,f.default)(t,"click",function(e){returnn.onClick(e)})}},{key:"onClick",value:functione(t){varn=t.delegateTarget||t.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=newu.default({action:this.action(n),target:this.target(n),text:this.text(n),trigger:n,emitter:this})}},{key:"defaultAction",value:functione(t){returnl("action",t)}},{key:"defaultTarget",value:functione(t){varn=l("target",t);if(n)returndocument.querySelector(n)}},{key:"defaultText",value:functione(t){returnl("text",t)}},{key:"destroy",value:functione(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}],[{key:"isSupported",value:functione(){vart=arguments.length>0&&void0!==arguments[0]?arguments[0]:["copy","cut"],n="string"==typeoft?[t]:t,o=!!document.queryCommandSupported;returnn.forEach(function(e){o=o&&!!document.queryCommandSupported(e)}),o}}]),t}(s.default);e.exports=h})},{"./clipboard-action":7,"good-listener":4,"tiny-emitter":6}]},{},[8])(8)});